$iframe_lazyload = apply_filters('rocket_lazyload_iframe_html', $iframe_lazyload); $iframe_lazyload .= ''; return $iframe_lazyload; } /** * Replaces the iframe provided by the Youtube thumbnail * * @param array $iframe Array of matched elements. * @return bool|string */ private function replaceYoutubeThumbnail($iframe) { $youtube_id = $this->getYoutubeIDFromURL($iframe['src']); if (! $youtube_id) { return false; } $query = wp_parse_url(htmlspecialchars_decode($iframe['src']), PHP_URL_QUERY); $youtube_url = $this->changeYoutubeUrlForYoutuDotBe( $iframe['src'] ); $youtube_url = $this->cleanYoutubeUrl( $iframe['src'] ); /** * Filter the LazyLoad HTML output on Youtube iframes * * @since 2.11 * * @param array $html Output that will be printed. */ $youtube_lazyload = apply_filters('rocket_lazyload_youtube_html', '
'); $youtube_lazyload .= ''; return $youtube_lazyload; } /** * Gets the Youtube ID from the URL provided * * @param string $url URL to search. * @return bool|string */ public function getYoutubeIDFromURL($url) { $pattern = '#^(?:https?:)?(?://)?(?:www\.)?(?:youtu\.be|youtube\.com|youtube-nocookie\.com)/(?:embed/|v/|watch/?\?v=)?([\w-]{11})#iU'; $result = preg_match($pattern, $url, $matches); if (! $result) { return false; } // exclude playlist. if ('videoseries' === $matches[1]) { return false; } return $matches[1]; } /** * Changes URL youtu.be/ID to youtube.com/embed/ID * * @param string $url URL to replace. * @return string Unchanged URL or modified URL. */ public function changeYoutubeUrlForYoutuDotBe( $url ) { $pattern = '#^(?:https?:)?(?://)?(?:www\.)?(?:youtu\.be)/(?:embed/|v/|watch/?\?v=)?([\w-]{11})#iU'; $result = preg_match( $pattern, $url, $matches ); if ( ! $result ) { return $url; } return 'https://www.youtube.com/embed/' . $matches[1]; } /** * Cleans Youtube URL. Keeps only scheme, host and path. * * @param string $url URL to be cleaned. * @return string Cleaned URL */ public function cleanYoutubeUrl ( $url ) { $parsed_url = wp_parse_url( $url, -1 ); $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '//'; $host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : ''; $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; return $scheme . $host . $path; } }
Fatal error: Uncaught TypeError: Argument 4 passed to WP_Rocket\Subscriber\Optimization\Lazyload_Subscriber::__construct() must be an instance of RocketLazyload\Iframe, string given in /home/payon/public_html/wp-content/plugins/wp-rocket/inc/classes/subscriber/Optimization/class-lazyload-subscriber.php:75 Stack trace: #0 [internal function]: WP_Rocket\Subscriber\Optimization\Lazyload_Subscriber->__construct(Object(WP_Rocket\Admin\Options_Data), Object(RocketLazyload\Assets), Object(RocketLazyload\Image), 'RocketLazyload\\...') #1 /home/payon/public_html/wp-content/plugins/wp-rocket/vendor/league/container/src/Definition/ClassDefinition.php(47): ReflectionClass->newInstanceArgs(Array) #2 /home/payon/public_html/wp-content/plugins/wp-rocket/vendor/league/container/src/Container.php(290): League\Container\Definition\ClassDefinition->build() #3 /home/payon/public_html/wp-content/plugins/wp-rocket/vendor/league/container/src/Container.php(90): League\Container\Container->getFromThisContainer('lazyload_subscr...', Array) #4 /ho in /home/payon/public_html/wp-content/plugins/wp-rocket/inc/classes/subscriber/Optimization/class-lazyload-subscriber.php on line 75