Skip to content

Instantly share code, notes, and snippets.

@tannerm
Forked from flowdee/functions.php
Last active August 29, 2015 13:57
Show Gist options
  • Save tannerm/9534016 to your computer and use it in GitHub Desktop.
Save tannerm/9534016 to your computer and use it in GitHub Desktop.
<?php
/**
* Remove trailing parenthesis from youtube oembed
*
* @param $html
* @param $url
*
* @return mixed
*/
function trm_remove_youtube_parenthesis ($html, $url ) {
if ( preg_match('#https?://(www\.)?youtu#i', $url) ) {
$html = trim( $html, ')' );
}
return $html;
}
add_filter( 'oembed_result', 'trm_remove_youtube_parenthesis', 10, 2 );
add_filter( 'embed_oembed_html', 'trm_remove_youtube_parenthesis', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment