@@ -287,12 +287,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
287287 * @since 6.4.0
288288 * @since 6.6.0 Returns `static` instead of `self` so it can create subclass instances.
289289 *
290- * @param string $html Input HTML fragment to process.
291- * @param string $context Context element for the fragment, must be default of `<body>`.
292- * @param string $encoding Text encoding of the document; must be default of 'UTF-8'.
290+ * @param string $html Input HTML fragment to process.
291+ * @param string $context Context element for the fragment, must be default of `<body>`.
292+ * @param string $encoding Optional. Text encoding of the document; must be default of 'UTF-8'.
293+ * @param string $compat_mode Optional. Set document compatibility mode (quirks). Should be
294+ * 'quirks-mode' or 'no-quirks-mode'. Default: 'no-quirks-mode'.
293295 * @return static|null The created processor if successful, otherwise null.
294296 */
295- public static function create_fragment ( $ html , $ context = '<body> ' , $ encoding = 'UTF-8 ' ) {
297+ public static function create_fragment ( $ html , $ context = '<body> ' , $ encoding = 'UTF-8 ' , $ compat_mode = WP_HTML_Processor_State:: NO_QUIRKS_MODE ) {
296298 if ( '<body> ' !== $ context || 'UTF-8 ' !== $ encoding ) {
297299 return null ;
298300 }
@@ -303,6 +305,10 @@ public static function create_fragment( $html, $context = '<body>', $encoding =
303305 $ processor ->state ->encoding = $ encoding ;
304306 $ processor ->state ->encoding_confidence = 'certain ' ;
305307
308+ if ( WP_HTML_Processor_State::QUIRKS_MODE === $ compat_mode ) {
309+ $ processor ->state ->compat_mode = WP_HTML_Processor_State::QUIRKS_MODE ;
310+ }
311+
306312 // @todo Create "fake" bookmarks for non-existent but implied nodes.
307313 $ processor ->bookmarks ['root-node ' ] = new WP_HTML_Span ( 0 , 0 );
308314 $ processor ->bookmarks ['context-node ' ] = new WP_HTML_Span ( 0 , 0 );
0 commit comments