Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
/**
* Plugin Name: Disable Embeds posts for me
* Description: Don't want to fetch external emebed posts?
* Version: 1.0
* Author: Julio Potier
* Author URI: https://wp-rocket.me
* License: GPLv2+
*
*/
add_filter( 'embed_oembed_html', 'hack_embed_oembed_html', 10, 2 );
function hack_embed_oembed_html( $html, $url ) {
if ( ! class_exists( 'WP_oEmbed' ) ) {
include( ABSPATH . WPINC . '/class-oembed.php' );
}
$WP_oEmbed = new WP_oEmbed();
if ( ! $WP_oEmbed->get_provider( $url, array( 'discover' => false ) ) ) {
return '';
}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment