mirror of
https://github.com/mrclay/minify.git
synced 2025-09-07 04:30:45 +02:00
Compare commits
1 Commits
2.3.1
...
bubble_fil
Author | SHA1 | Date | |
---|---|---|---|
|
5d4c45ad8c |
39
min/lib/Minify/CSS/Filter/BubbleImports.php
Normal file
39
min/lib/Minify/CSS/Filter/BubbleImports.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS_Filter_BubbleImports
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* CSS filter that moves @import statements to the top of the CSS
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
class Minify_CSS_Filter_BubbleImports {
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
* @return string
|
||||
*/
|
||||
public static function filter($css) {
|
||||
|
||||
$importStatements = array();
|
||||
|
||||
$collect = function($matches) use (&$importStatements) {
|
||||
$importStatements[] = $matches[0];
|
||||
$media = '';
|
||||
if (trim($matches[2])) {
|
||||
$media = ' for media:' . $matches[2];
|
||||
}
|
||||
return '/* replaced import "'.$matches[1].'"'.$media.' */';
|
||||
};
|
||||
|
||||
$css = preg_replace_callback(Minify_ImportProcessor::IMPORT_STATEMENT_REGEX, $collect, $css);
|
||||
|
||||
if ($importStatements) {
|
||||
$css = join("\n", $importStatements) . "\n" . $css;
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user