PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
← All changes | classes/autoptimizeCSSmin.php +12 -0 2.4.2 → trunk View file →
@@ -35,9 +35,21 @@
35 35 * @return string
36 36 */
37 37 public function run( $css )
38 38 {
39 + // hide calc() if filter says yes (as YUI CSS compressor PHP port has problems retaining spaces around + and - operators).
40 + // regex see tests at https://regex101.com/r/ofGQG9/1
41 + if ( apply_filters( 'autoptimize_filter_css_hide_calc', true ) ) {
42 + $css = autoptimizeBase::replace_contents_with_marker_if_exists( 'CALC', 'calc(', '#(calc|min|max|clamp)\([^;}]*\)#m', $css );
43 + }
44 +
45 + // minify.
39 46 $result = $this->minifier->run( $css );
47 +
48 + // restore calc() if filter says yes.
49 + if ( apply_filters( 'autoptimize_filter_css_hide_calc', true ) ) {
50 + $result = autoptimizeBase::restore_marked_content( 'CALC', $result );
51 + }
40 52
41 53 return $result;
42 54 }
43 55