Skip to content

Instantly share code, notes, and snippets.

@wp-kitten
Created June 10, 2016 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-kitten/912d239320fe93d3bdee2a6fa0c781d2 to your computer and use it in GitHub Desktop.
Save wp-kitten/912d239320fe93d3bdee2a6fa0c781d2 to your computer and use it in GitHub Desktop.
[WordPress] Cleanup wp head tag
// removes <link rel="EditURI" type="application/rsd xml" title="RSD" href="http://bhoover.com/wp/xmlrpc.php?rsd
remove_action( 'wp_head', 'rsd_link' );
// removes <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://bhoover.com/wp/wp-includes/wlwmanifest.xml">
remove_action( 'wp_head', 'wlwmanifest_link' );
// removes Ex: <meta name="generator" content="WordPress 4.5">
remove_action( 'wp_head', 'wp_generator' );
// removes Ex: <link rel='shortlink' href="http://example.com/?p=42">
remove_action( 'wp_head', 'wp_shortlink_wp_head');
// remove adjacent post links
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
// Remove feed links
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
// Remove Emoji scripts
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
// Do not store a comment cookie. tracking cookies are forbidden in Europe (without user's consent)
remove_action('set_comment_cookies', 'wp_set_comment_cookies');
function wpkRemoveWpVersionFromUrl( $src ) {
parse_str(parse_url($src, PHP_URL_QUERY), $query);
if ( !empty($query['ver'])) {
$src = remove_query_arg('ver', $src);
}
return $src;
}
add_filter( 'script_loader_src', 'wpkRemoveWpVersionFromUrl', 100 );
add_filter( 'style_loader_src', 'wpkRemoveWpVersionFromUrl', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment