Merge pull request #763 from louisremi/preserve_media

Only display media if it is meaningful
This commit is contained in:
Ben Word
2013-05-22 16:04:09 -07:00

View File

@@ -99,8 +99,8 @@ add_filter('wp_title', 'roots_wp_title', 10);
*/
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's print
$media = $matches[3][0] === 'print' ? ' media="print"' : '';
// 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');