Skip to content

Commit

Permalink
fix styles minification bug with calc()
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 20, 2021
1 parent 7282e26 commit a37b655
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions includes/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ public function block_editor_assets() {
*/
public static function minify( $styles ) {
$re1 = '(?sx)("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')|/\\* (?> .*? \\*/ )';
$re2 = '(?six)("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')|\\s*+ ; \\s*+ ( } ) \\s*+|\\s*+ ( [*$~^|]?+= | [{};,>~+-] | !important\\b ) \\s*+|( [[(:] ) \\s++|\\s++ ( [])] )|\\s++ ( : ) \\s*+(?!(?>[^{}"\']++|"(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')*+{)|^ \\s++ | \\s++ \\z|(\\s)\\s+';

$styles = preg_replace( "%$re1%", '$1', $styles );
return preg_replace( "%$re2%", '$1$2$3$4$5$6$7', $styles );
$re2 = '(?six)("(?:[^"\\\\]++|\\\\.)*+"|\'(?:[^\'\\\\]++|\\\\.)*+\')|\\s*+ ; \\s*+ ( } ) \\s*+|\\s*+ ( [*$~^|]?+= | [{};,>~] | !important\\b ) \\s*+|\\s*([+-])\\s*(?=[^}]*{)|( [[(:] ) \\s++|\\s++ ( [])] )|\\s+(:)(?![^\\}]*\\{)|^ \\s++ | \\s++ \\z|(\\s)\\s+';
return preg_replace( array( "%{$re1}%", "%{$re2}%" ), array( '$1', '$1$2$3$4$5$6$7$8' ), $styles );
}
}

0 comments on commit a37b655

Please sign in to comment.