Created
March 11, 2017 14:07
-
-
Save Manoz/eff06d80da20e8fb8ca2ceefbe6ee686 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Tweaks & utils | |
* Cleanup wp_head() | |
* Use it in your function.php file (or inside a plugin) | |
*/ | |
/** | |
* Clean the <link> tag output in the site header | |
* Removing useless ID's | |
*/ | |
add_filter('style_loader_tag', 'felain_clean_style'); | |
function felain_clean_style( $input ) { | |
preg_match_all("!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches); | |
// Only display media if it is meaningful | |
$media = $matches[3][0] !== '' && $matches[3][0] !== 'all' ? ' media="' . $matches[3][0] . '"' : ''; | |
// Add a 4 spaces indent before <link... | |
return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n"; | |
} | |
/** | |
* Remove WP Emoji feature | |
* Thanks WP for this crappy default thing -_-' | |
* | |
*/ | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
/** | |
* Clean the header to remove what we don't need | |
* RSD link, useless rss, etc... | |
*/ | |
remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
remove_action( 'wp_head', 'feed_links', 2 ); | |
remove_action( 'wp_head', 'rsd_link' ); | |
remove_action( 'wp_head', 'wlwmanifest_link' ); | |
remove_action( 'wp_head', 'index_rel_link' ); | |
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); | |
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); | |
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment