-
-
Save barbareshet/7f278fb15b610a31e45de7fdece238ca to your computer and use it in GitHub Desktop.
Remove All Unwanted Meta, Scripts and Styles (including Emoji) from the WordPress Header.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================= | |
// REMOVE JUNK FROM WORDPRESS HEAD | |
// ========================================================================= | |
// REMOVE WORDPRESS HEADER META: | |
remove_action('wp_head', 'rsd_link'); // remove really simple discovery link | |
remove_action('wp_head', 'wp_generator'); // remove wordpress version meta tag | |
remove_action('wp_head', 'feed_links', 2); // remove rss feed links (make sure you add them in yourself if youre using feedblitz or an rss service) | |
remove_action('wp_head', 'feed_links_extra', 3); // removes all extra rss feed links | |
remove_action('wp_head', 'index_rel_link'); // remove link to index page | |
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml (needed to support windows live writer) | |
remove_action('wp_head', 'start_post_rel_link', 10); // remove random post link | |
remove_action('wp_head', 'parent_post_rel_link', 10); // remove parent post link | |
remove_action('wp_head', 'adjacent_posts_rel_link', 10); // remove the next and previous post links | |
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10); // remove the next and previous post links | |
remove_action('wp_head', 'wp_shortlink_wp_head', 10); // remove wp shortlink | |
// REMOVE EMOJIS: | |
remove_action('wp_head', 'print_emoji_detection_script', 7); // Emoji Scripts and Styles | |
remove_action('admin_print_scripts', 'print_emoji_detection_script'); // Emoji Scripts and Styles | |
remove_action('wp_print_styles', 'print_emoji_styles'); // Emoji Scripts and Styles | |
remove_action('admin_print_styles', 'print_emoji_styles'); // Emoji Scripts and Styles | |
add_filter('emoji_svg_url', '__return_false'); // Removes the dns-prefetch meta for Emoji (s.w.org) | |
// REMOVE REST API: | |
remove_action('wp_head', 'rest_output_link_wp_head', 10); // Remove the REST API lines from the HTML Header (api.w.org) | |
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10); // Remove the REST API lines from the HTML Header (api.w.org) | |
remove_action('rest_api_init', 'wp_oembed_register_route'); // Remove the REST API endpoint. | |
add_filter( 'embed_oembed_discover', '__return_false'); // Turn off oEmbed auto discovery. | |
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); // Don't filter oEmbed results. | |
remove_action('wp_head', 'wp_oembed_add_discovery_links'); // Remove oEmbed discovery links. | |
remove_action('wp_head', 'wp_oembed_add_host_js'); // Remove oEmbed-specific JavaScript from the front-end and back-end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment