Created
December 23, 2016 15:50
-
-
Save alexstandiford/6a6bc9de749302913390539836b5ebe3 to your computer and use it in GitHub Desktop.
Alters oembed querystring parameters
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
<?php | |
/** | |
* Cleans up YouTube Video Embeds | |
**/ | |
function imp_custom_youtube_querystring( $html, $url, $args ) { | |
if(strpos($html, 'youtube')!= FALSE) { | |
$args = [ | |
'rel' => 0, | |
'controls' => 0, | |
'showinfo' => 0, | |
'modestbranding' => 1, | |
]; | |
$params = '?feature=oembed&'; | |
foreach($args as $arg => $value){ | |
$params .= $arg; | |
$params .= '='; | |
$params .= $value; | |
$params .= '&'; | |
} | |
$result = str_replace( '?feature=oembed', $params, $html ); | |
} | |
return $result; | |
} | |
add_filter('oembed_result', 'imp_custom_youtube_querystring', 10, 3); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment