Skip to content

Instantly share code, notes, and snippets.

@flowdee
Last active August 29, 2015 13:57
Show Gist options
  • Save flowdee/9504587 to your computer and use it in GitHub Desktop.
Save flowdee/9504587 to your computer and use it in GitHub Desktop.
Removes the closing bracket at the end of WordPress' oEmbed using YouTube.
<?php
function remove_youtube_parenthesis ($html, $url ) {
if ( preg_match('#https?://(www\.)?youtu#i', $url) ) {
$html = preg_replace('/\)$/', '', $html);
}
return $html;
}
add_filter( 'oembed_result', 'remove_youtube_parenthesis ', 10, 2 );
add_filter( 'embed_oembed_html', 'remove_youtube_parenthesis ', 10, 2 );
@tannerm
Copy link

tannerm commented Mar 13, 2014

Howdy! I tried to post an edit to your answer on Stackoverflow to include filtering already cached YouTube embeds, but it was rejected (unsure why). Anyway, I don't have enough points to post my own answer so I figured I'd just tell you and let you update the answer if you want to. Here is my gist: https://gist.github.com/tannerm/9534016.

-Tanner

@flowdee
Copy link
Author

flowdee commented Mar 14, 2014

yea updated it! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment