<?php 
define("YOUTUBE_WIDTH", 720); 
define("YOUTUBE_HEIGHT", 480); 
define("YOUTUBE_REGEXP", "/\[youtube ([[:print:]]+)\]/"); 
define("YOUTUBE_TARGET", "<iframe width=\"".YOUTUBE_WIDTH."\" height=\"".YOUTUBE_HEIGHT."\" src="https://www.youtube.com/embed/###URL###\" frameborder="\0\" allowfullscreen></iframe>"); 

function youtube_plugin_callback($match) 
{ 
    $output = YOUTUBE_TARGET; 
    $output = str_replace("###URL###", $match[1], $output); 
    return ($output); 
} 

function youtube_plugin($content) 
{ 
    return (preg_replace_callback(YOUTUBE_REGEXP, 'youtube_plugin_callback', $content)); 
} 

add_filter('the_content', 'youtube_plugin'); 
add_filter('comment_text', 'youtube_plugin'); 

?>