Skip to content

Instantly share code, notes, and snippets.

@diego-betto
Last active October 20, 2017 13:17
Show Gist options
  • Save diego-betto/b1829ff4900458a6300a0459d265d3eb to your computer and use it in GitHub Desktop.
Save diego-betto/b1829ff4900458a6300a0459d265d3eb to your computer and use it in GitHub Desktop.
Disable default Wordpress embeds in frontend
<?php
// in functions.php
if (!is_admin()){
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
add_filter( 'embed_oembed_discover', '__return_false' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment