_default_exclusions(); if ( count( $current_list ) < count( $default_list ) ) { return false; } $current_list = array_flip( $current_list ); foreach ( $default_list as $item ) { if ( ! isset( $current_list[ $item ] ) ) { return false; } } return true; } } svg_tags( $result ); $replaced_html = preg_replace_callback( '/<\s*script(?\s*[^>]*?)?>(?.*?)?<\s*\/\s*script\s*>/ims', [ $this, 'replace_scripts', ], $result ); if ( empty( $replaced_html ) ) { return $html; } $replaced_html = $this->restore_xmp_tags( $replaced_html ); return $this->restore_svg_tags( $replaced_html ); } /** * Callback method for preg_replace_callback that is used to adjust attributes for scripts. * * @since 3.9 Use exclusions list & fake type attribute. * @since 3.7 * * @param array $matches Matches array for scripts regex. * * @return string */ public function replace_scripts( $matches ): string { foreach ( $this->excluded as $pattern ) { if ( preg_match( "#{$pattern}#i", $matches[0] ) ) { $this->logger->debug( "DelayJS: Script {$matches[0]} excluded by $pattern" ); return $matches[0]; } } if ( empty( $matches['attr'] ) ) { return ''; } $type_regex = '/type\s*=\s*(["\'])(?.*)\1/i'; preg_match( $type_regex . 'U', $matches['attr'], $type_matches ); if ( ! empty( $type_matches ) && ! empty( trim( $type_matches['type'] ) ) && ! in_array( trim( $type_matches['type'] ), $this->allowed_types, true ) ) { return $matches[0]; } $matches['attr'] = preg_replace( $type_regex, 'data-rocket-type=$1$2$1', $matches['attr'] ); // To remove type attribute without any value. $matches['attr'] = preg_replace( '/(\s+type\s+)|(^type\s+)|(\s+type$)/i', '', $matches['attr'] ); // Checks if script has src attribute so then treat as external script and replace src with data-rocket-src. $src_regex = '/src\s*=\s*(["\'])(.*)\1/i'; $matches['attr'] = preg_replace( $src_regex, 'data-rocket-src=$1$2$1', $matches['attr'] ); return ''; } /** * Move meta charset to head if not found to the top of page content. * * @since 3.9.4 * * @param string $html Html content. * * @return string */ public function move_meta_charset_to_head( $html ): string { $meta_pattern = "#]*|)(charset[^=]*=[ ]*[\'\" ]*[^\'\"> ][^\'\">]+[^\'\"> ][\'\" ]*|charset[^=]*=*[^\'\"> ][^\'\">]+[^\'\"> ])([^>]*|)>(?=.*)#Usmi"; if ( ! preg_match( $meta_pattern, $html, $matches ) ) { return $html; } $replaced_html = preg_replace( "$meta_pattern", '', $html ); if ( empty( $replaced_html ) ) { return $html; } if ( preg_match( '/]*?>)/i', "\${1}{$matches[0]}", $replaced_html, 1 ); if ( empty( $replaced_html ) ) { return $html; } return $replaced_html; } if ( preg_match( '/]*?>)/i', "\${1}{$matches[0]}", $replaced_html, 1 ); if ( empty( $replaced_html ) ) { return $html; } return $replaced_html; } $replaced_html = preg_replace( '/(<\w+)/', "{$matches[0]}\${1}", $replaced_html, 1 ); if ( empty( $replaced_html ) ) { return $html; } return $replaced_html; } /** * Get exclusions * * @return void */ private function set_exclusions() { $lists = $this->data_manager->get_lists(); $this->excluded = isset( $lists->delay_js_exclusions ) ? $lists->delay_js_exclusions : []; } }
Fatal error: Uncaught TypeError: WP_Rocket\Engine\Optimization\DelayJS\Subscriber::__construct(): Argument #1 ($html) must be of type WP_Rocket\Engine\Optimization\DelayJS\HTML, string given in /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Engine/Optimization/DelayJS/Subscriber.php:35 Stack trace: #0 [internal function]: WP_Rocket\Engine\Optimization\DelayJS\Subscriber->__construct('WP_Rocket\\Engin...', Object(WP_Filesystem_Direct)) #1 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Definition/Definition.php(225): ReflectionClass->newInstanceArgs(Array) #2 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Definition/Definition.php(181): WP_Rocket\Dependencies\League\Container\Definition\Definition->resolveClass('WP_Rocket\\Engin...') #3 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Definition/Definition.php(160): WP_Rocket\Dependencies\League\Container\Definition\Definition->resolveNew() #4 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Definition/DefinitionAggregate.php(79): WP_Rocket\Dependencies\League\Container\Definition\Definition->resolve() #5 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Container.php(175): WP_Rocket\Dependencies\League\Container\Definition\DefinitionAggregate->resolve('delay_js_subscr...') #6 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Container.php(198): WP_Rocket\Dependencies\League\Container\Container->resolve('delay_js_subscr...', false) #7 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Container.php(118): WP_Rocket\Dependencies\League\Container\Container->resolve('delay_js_subscr...') #8 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Plugin.php(168): WP_Rocket\Dependencies\League\Container\Container->get('delay_js_subscr...') #9 /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/main.php(47): WP_Rocket\Plugin->load() #10 /htdocs/le-blog.fr/wp-includes/class-wp-hook.php(341): rocket_init('') #11 /htdocs/le-blog.fr/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array) #12 /htdocs/le-blog.fr/wp-includes/plugin.php(522): WP_Hook->do_action(Array) #13 /htdocs/le-blog.fr/wp-settings.php(593): do_action('plugins_loaded') #14 /htdocs/le-blog.fr/wp-config.php(102): require_once('/htdocs/le-blog...') #15 /htdocs/le-blog.fr/wp-load.php(50): require_once('/htdocs/le-blog...') #16 /htdocs/le-blog.fr/wp-blog-header.php(13): require_once('/htdocs/le-blog...') #17 /htdocs/le-blog.fr/index.php(17): require('/htdocs/le-blog...') #18 {main} thrown in /htdocs/le-blog.fr/wp-content/plugins/wp-rocket/inc/Engine/Optimization/DelayJS/Subscriber.php on line 35