add_shortcode( 'youtube', 'my_youtube_shortcode' );
function my_youtube_shortcode( $atts ) {
// We need to use the WP_Embed class instance
global $wp_embed;
// The "id" parameter is required
if ( empty($atts['id']) )
return '';
// Construct the YouTube URL
$url = 'http://www.youtube.com/watch?v=' . $atts['id'];
// Run the URL through the handler.
// This handler handles calling the oEmbed class
// and more importantly will also do the caching!
return $wp_embed->shortcode( $atts, $url );
}