wordpress removes the wp-json link and the wp-embed.min.js file

Recently updated the latest version of the wordpress 4.4, update what function I do not know, I know I do not have access to, but found that there are several functions inside the link function, I do not have access. So we removed him, mainly more REST API (through the REST API can easily access the site’s data), wp-json link, embeds function (embeds function can allow more convenient reference to third-party resources) wp-embed.min.js file.
We do not have to load it to do what, but also affect the site to read the speed, then we talk about how to prohibit out.
First talk about the disabled REST API, remove the wp-json link method, add the following code to the theme functions.php file to disable the REST API and remove the head inside the output of the link information:

  1. add_filter(‘rest_enabled’, ‘_return_false’);
  2. add_filter(‘rest_jsonp_enabled’, ‘_return_false’);
  3. remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10 );
  4. remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’, 10 );

Disable embeds is actually more complex (code more), the official and even developed a plug-in for this, we can use the plug-in to disable: Disable Embeds, if you do not want to use plug-ins, then plug the code inside the copy to the theme functions.php File can be.

  1. function disable_emojis() {
  2. remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
  3. remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
  4. remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
  5. remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
  6. remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
  7. remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
  8. remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
  9. add_filter( ‘tiny_mce_plugins’, ‘disable_emojis_tinymce’ );
  10. }
  11. add_action( ‘init’, ‘disable_emojis’ );
  12. /** 
  13. * Filter function used to remove the tinymce emoji plugin. 
  14. */
  15. function disable_emojis_tinymce( $plugins ) {
  16. if ( is_array$plugins ) ) {
  17. return array_diff$pluginsarray( ‘wpemoji’ ) );
  18. else {
  19. return array();
  20. }
  21. }
  22. function disable_embeds_init() {
  23. global $wp;
  24. $wp->public_query_vars = array_diff$wp->public_query_vars, array( ’embed’, ) );
  25. remove_action( ‘rest_api_init’, ‘wp_oembed_register_route’ );
  26. add_filter( ’embed_oembed_discover’, ‘__return_false’ );
  27. remove_filter( ‘oembed_dataparse’, ‘wp_filter_oembed_result’, 10 );
  28. remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’ );
  29. remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ );
  30. add_filter( ‘tiny_mce_plugins’, ‘disable_embeds_tiny_mce_plugin’ );
  31. add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); }
  32. add_action( ‘init’, ‘disable_embeds_init’, 9999 );
  33. function disable_embeds_tiny_mce_plugin( $plugins ) { return array_diff$pluginsarray( ‘wpembed’ ) ); }
  34. function disable_embeds_rewrites( $rules ) { foreach ( $rules as $rule => $rewrite ) { if ( false !== strpos$rewrite, ’embed=true’ ) ) { unset( $rules$rule ] ); } }
  35. return $rules; }
  36. function disable_embeds_remove_rewrite_rules() { add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); flush_rewrite_rules(); }
  37. register_activation_hook( __FILE__, ‘disable_embeds_remove_rewrite_rules’ );
  38. function disable_embeds_flush_rewrite_rules() { remove_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); flush_rewrite_rules(); }
  39. register_deactivation_hook( __FILE__, ‘disable_embeds_flush_rewrite_rules’ );

Every time you update the wordpress version will be more things, such as the previous emoji, and are input on the page content, more or less will affect the speed, our blog is basically updated under the article, engage in too much responsibility for the excessive, Not to get rid of REST API and embeds, for the user experience, so that the website faster display of our code on the OK.