Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #102 from rasmusbe/patch-1
Browse files Browse the repository at this point in the history
Fix warnings when input is empty in clean_style_tag
  • Loading branch information
retlehs committed Sep 23, 2015
2 parents 9a23925 + 8904567 commit 9e9f42a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/clean-up.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ function language_attributes() {
*/
function clean_style_tag($input) {
preg_match_all("!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches);
if (empty($matches[2])) {
return $input;
}
// 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";
Expand Down

0 comments on commit 9e9f42a

Please sign in to comment.