Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Vimeo oembed hotfix
Plugin Name: Vimeo oembed hotfix
Plugin URI:
Description: Enable https vimeo embeds. <strong>Note</strong>: If for any reason videos are not embedding properly, simply deactivate, and then reactivate this plugin.
Author: gluten
Version: 2.0
Author URI:
function oembed_hotfix_vimeo_oembed_providers( $providers ) {
$providers['#https?://(www\.)?vimeo\.com/.*#i'] = array( '{format}', true );
return $providers;
add_filter('oembed_providers', 'oembed_hotfix_vimeo_oembed_providers');
// based on this patch:
function oembed_hotfix_delete_all_oembed_caches() {
// Based on delete_post_meta_by_key()
global $wpdb;
$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
if ( $post_ids ) {
$postmetaids = $wpdb->get_col( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" );
$in = implode( ',', array_fill( 1, count($postmetaids), '%d' ) );
do_action( 'delete_postmeta', $postmetaids );
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ) );
do_action( 'deleted_postmeta', $postmetaids );
foreach ( $post_ids as $post_id )
wp_cache_delete( $post_id, 'post_meta' );
return true;
return false;
register_activation_hook( __FILE__, 'oembed_hotfix_delete_all_oembed_caches' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment