Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created January 21, 2014 19:08
Show Gist options
  • Save kovshenin/8546196 to your computer and use it in GitHub Desktop.
Save kovshenin/8546196 to your computer and use it in GitHub Desktop.
<?php
function get_my_video_embed( $post_id, $video_url ) {
global $wp_embed;
$key = '_my_video_' . md5( $video_url );
$cache = get_post_meta( $post_id, $key, true );
if ( ! empty( $cache ) )
return $cache;
$content = $wp_embed->run_shortcode( sprintf( '[embed]%s[/embed]', esc_url_raw( $video_url ) ) );
update_post_meta( $post_id, $key, $content );
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment