', esc_html($custom)); return self::minifyCss($css); } /** * Removes all comments & space from CSS string. * Source: http://stackoverflow.com/a/15195752/866618 */ private static function minifyCss($css) { # remove comments first (simplifies the other regex) $re1 = << .*? \*/ ) EOS; $re2 = <<~+-] | !important\b ) \s*+ | # spaces right of ( [ : ( [[(:] ) \s++ | # spaces left of ) ] \s++ ( [])] ) | # spaces left (and right) of : \s++ ( : ) \s*+ # but not in selectors: not followed by a { (?! (?> [^{}"']++ | "(?:[^"\\]++|\\.)*+" | '(?:[^'\\]++|\\.)*+' )*+ { ) | # spaces at beginning/end of string ^ \s++ | \s++ \z | # double spaces to single (\s)\s+ EOS; $css = preg_replace("%$re1%", '$1', $css); return preg_replace("%$re2%", '$1$2$3$4$5$6$7', $css); } /** * Blocks instantiation. All functions are static. */ private function __construct() { } } ?>