retesere20

wp-remove-all-heads

Dec 23rd, 2020 (edited)
16
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function removeExtraHeadTags()
  2. {
  3. add_action( 'wp_enqueue_scripts', function () { wp_dequeue_style( 'wc-block-style' ); wp_dequeue_style( 'storefront-gutenberg-blocks' ); } );
  4.  
  5. // remove s.w.org dns prefetch tag
  6. add_filter( 'wp_resource_hints', function ( $hints, $relation_type ) { return ('dns-prefetch' === $relation_type && array_pop($hints ) ) ? $hints : $hints; } , 10, 2 );
  7. // remove feeds, etc
  8. remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
  9. remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
  10. remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
  11. remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
  12. remove_action( 'wp_head', 'index_rel_link' ); // index link
  13. add_filter('after_setup_theme', function () { remove_action('wp_head', 'wp_shortlink_wp_head', 10); if(0) remove_action( 'template_redirect', 'wp_shortlink_header', 11); });
  14. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
  15. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
  16. remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
  17. remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
  18. // emojis
  19. remove_action('wp_head', 'print_emoji_detection_script', 7);
  20. remove_action('wp_print_styles', 'print_emoji_styles');
  21. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  22. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  23. //
  24. remove_action( 'wp_head', 'rest_output_link_wp_head' );
  25. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
  26. remove_action( 'template_redirect', 'rest_output_link_header', 11 );
  27.  
  28. add_filter( 'xmlrpc_enabled', '__return_false' );
  29. add_filter( 'xmlrpc_methods', function () { return []; }, 99999 );
  30.  
  31. $remove_json_api = function () {
  32. // Remove the REST API lines from the HTML Header
  33. remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
  34. remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
  35. // Remove the REST API endpoint.
  36. remove_action( 'rest_api_init', 'wp_oembed_register_route' );
  37. // Turn off oEmbed auto discovery.
  38. add_filter( 'embed_oembed_discover', '__return_false' );
  39. // Don't filter oEmbed results.
  40. remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
  41. // Remove oEmbed discovery links.
  42. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
  43. // Remove oEmbed-specific JavaScript from the front-end and back-end.
  44. remove_action( 'wp_head', 'wp_oembed_add_host_js' );
  45. // Remove all embeds rewrite rules.
  46. //add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
  47. };
  48. add_action( 'after_setup_theme', $remove_json_api );
  49. }
RAW Paste Data