Created
March 12, 2021 11:57
-
-
Save marcelo2605/24ee8e6cf4b254694a388750eb430a7a to your computer and use it in GitHub Desktop.
Use Lite YouTube in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use Lite YouTube in posts embeds | |
* https://github.com/paulirish/lite-youtube-embed | |
*/ | |
add_filter('embed_oembed_html', function($cached_html, $url, $attr, $post_id) { | |
$querystring = parse_url($url, PHP_URL_QUERY); | |
parse_str($querystring, $params); | |
if (isset($params['v'])) { | |
$format = '<lite-youtube videoid="%s"></lite-youtube>'; | |
$cached_html = sprintf($format, $params['v']); | |
} | |
return $cached_html; | |
}, 99, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment