Merge pull request #763 from louisremi/preserve_media
Only display media if it is meaningful
This commit is contained in:
@@ -99,8 +99,8 @@ add_filter('wp_title', 'roots_wp_title', 10);
|
|||||||
*/
|
*/
|
||||||
function roots_clean_style_tag($input) {
|
function roots_clean_style_tag($input) {
|
||||||
preg_match_all("!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches);
|
preg_match_all("!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches);
|
||||||
// Only display media if it's print
|
// Only display media if it is meaningful
|
||||||
$media = $matches[3][0] === 'print' ? ' media="print"' : '';
|
$media = $matches[3][0] !== '' && $matches[3][0] !== 'all' ? ' media="' . $matches[3][0] . '"' : '';
|
||||||
return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n";
|
return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n";
|
||||||
}
|
}
|
||||||
add_filter('style_loader_tag', 'roots_clean_style_tag');
|
add_filter('style_loader_tag', 'roots_clean_style_tag');
|
||||||
|
|||||||
Reference in New Issue
Block a user