Skip to content

Instantly share code, notes, and snippets.

@coinso
Forked from barbareshet/wp_remove_header_junk.php
Last active February 21, 2017 08:29
Show Gist options
  • Save coinso/52f3b95f1b9764e84513d6bdf3bae15e to your computer and use it in GitHub Desktop.
Save coinso/52f3b95f1b9764e84513d6bdf3bae15e to your computer and use it in GitHub Desktop.
Remove All Unwanted Meta, Scripts and Styles (including Emoji) from the WordPress Header.
// =========================================================================
// REMOVE JUNK FROM WORDPRESS HEAD
// =========================================================================
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_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
remove_action('wp_head', 'rest_output_link_wp_head', 10); // Disable REST API link tag
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10); // oEmbed Discovery Links
remove_action('template_redirect', 'rest_output_link_header', 11, 0); // REST API link in HTTP headers
add_filter('xmlrpc_enabled', '__return_false'); // disabling XML-RPC
add_filter('json_enabled', '__return_false');// disabling JSON REST api
add_filter('json_jsonp_enabled', '__return_false');// disabling JSON REST api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment