Skip to content

Instantly share code, notes, and snippets.

@JulioPotier
Created November 9, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulioPotier/5ccf7f11549a4e0f4aaa to your computer and use it in GitHub Desktop.
Save JulioPotier/5ccf7f11549a4e0f4aaa to your computer and use it in GitHub Desktop.
<?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