I'm sure there could be exceptions to the way someone embeds the code and my regex is never great.
I've also added DailyMotion to the list of full web filtered. However I can't find any easy way to find a translation to their rather weird french mobile site.
<?php
/*
Plugin Name: XHTML Safe Videos
Plugin URI: http://blog.artesea.co.uk/
Description: Converts YouTube and DailyMotion embed code into correctly formed XHTML (and even displays a mobile YouTube link instead on Mobile themes)
Author: Ryan Cullen
Version: 0.3
Author URI: http://blog.artesea.co.uk/
*/
function rtc_xhtml_youtube($content) {
//Get the name of the Wordpress Template being used
$theme = get_template();
//If this *isn't* a mobile theme
if(stristr($theme, 'mobile') === FALSE) {
$content = preg_replace('|<object(.*?)(.*?)|',
'',
$content);
$content = preg_replace('|<object(.*?)(.*?)|',
'',
$content);
$content = preg_replace('|<object(.*?)(.*?)|',
'',
$content);
}
else {
$content = preg_replace('|<object(.*?)(.*?)|',
'',
$content);
$content = preg_replace('|<object(.*?)(.*?)|',
'',
$content);
}
return $content;
}
add_filter('the_content', 'rtc_xhtml_youtube');
?>