Only display media if it is meaningful

This commit is contained in:
Louis-Rémi Babé
2013-05-14 20:06:33 +03:00
parent ecfaefd751
commit de206a2cf7

View File

@@ -94,6 +94,17 @@ function roots_wp_title($title) {
}
add_filter('wp_title', 'roots_wp_title', 10);
/**
* Clean up output of stylesheet <link> tags
*/
function roots_clean_style_tag($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] . '"' : '';
return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n";
}
add_filter('style_loader_tag', 'roots_clean_style_tag');
/**
* Add and remove body_class() classes
*/