@@ -162,32 +162,32 @@ discard block |
||
162 | 162 | // Remove the original style tag |
163 | 163 | $this->content = str_replace($tag,'',$this->content); |
164 | 164 | } else { |
165 | - // excluded CSS, minify if getpath |
|
166 | - if (preg_match('#<link.*href=("|\')(.*)("|\')#Usmi',$tag,$source)) { |
|
167 | - $explUrl = explode('?',$source[2],2); |
|
165 | + // excluded CSS, minify if getpath |
|
166 | + if (preg_match('#<link.*href=("|\')(.*)("|\')#Usmi',$tag,$source)) { |
|
167 | + $explUrl = explode('?',$source[2],2); |
|
168 | 168 | $url = $explUrl[0]; |
169 | 169 | $path = $this->getpath($url); |
170 | 170 | |
171 | - if ($path && apply_filters('autoptimize_filter_css_minify_excluded',false)) { |
|
172 | - $_CachedMinifiedUrl = $this->minify_single($path); |
|
173 | - |
|
174 | - if (!empty($_CachedMinifiedUrl)) { |
|
175 | - // replace orig URL with URL to cache |
|
176 | - $newTag = str_replace($url, $_CachedMinifiedUrl, $tag); |
|
177 | - } else { |
|
178 | - $newTag = $tag; |
|
179 | - } |
|
171 | + if ($path && apply_filters('autoptimize_filter_css_minify_excluded',false)) { |
|
172 | + $_CachedMinifiedUrl = $this->minify_single($path); |
|
173 | + |
|
174 | + if (!empty($_CachedMinifiedUrl)) { |
|
175 | + // replace orig URL with URL to cache |
|
176 | + $newTag = str_replace($url, $_CachedMinifiedUrl, $tag); |
|
177 | + } else { |
|
178 | + $newTag = $tag; |
|
179 | + } |
|
180 | 180 | |
181 | - // remove querystring from URL |
|
182 | - if ( !empty($explUrl[1]) ) { |
|
183 | - $newTag = str_replace("?".$explUrl[1],"",$newTag); |
|
184 | - } |
|
185 | - |
|
186 | - // and replace |
|
187 | - $this->content = str_replace($tag,$newTag,$this->content); |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
181 | + // remove querystring from URL |
|
182 | + if ( !empty($explUrl[1]) ) { |
|
183 | + $newTag = str_replace("?".$explUrl[1],"",$newTag); |
|
184 | + } |
|
185 | + |
|
186 | + // and replace |
|
187 | + $this->content = str_replace($tag,$newTag,$this->content); |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | 191 | } |
192 | 192 | return true; |
193 | 193 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | // just cdn the URL if applicable |
405 | 405 | if (!empty($this->cdn_url)) { |
406 | 406 | $imgreplace[$matches[0][$count]] = str_replace($quotedurl,$this->maybe_cdn_urls($quotedurl),$matches[0][$count]); |
407 | - } |
|
407 | + } |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else if ((is_array($matches)) && (!empty($this->cdn_url))) { |
@@ -611,8 +611,8 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | private function ismovable($tag) { |
614 | - if (apply_filters('autoptimize_filter_css_dontaggregate',false)) { |
|
615 | - return false; |
|
614 | + if (apply_filters('autoptimize_filter_css_dontaggregate',false)) { |
|
615 | + return false; |
|
616 | 616 | } else if (!empty($this->whitelist)) { |
617 | 617 | foreach ($this->whitelist as $match) { |
618 | 618 | if(strpos($tag,$match)!==false) { |
@@ -637,13 +637,13 @@ discard block |
||
637 | 637 | } |
638 | 638 | |
639 | 639 | private function can_inject_late($cssPath,$css) { |
640 | - $consider_minified_array = apply_filters('autoptimize_filter_css_consider_minified',false); |
|
640 | + $consider_minified_array = apply_filters('autoptimize_filter_css_consider_minified',false); |
|
641 | 641 | if ( $this->inject_min_late !== true ) { |
642 | 642 | // late-inject turned off |
643 | 643 | return false; |
644 | 644 | } else if ( (strpos($cssPath,"min.css") === false) && ( str_replace($consider_minified_array, '', $cssPath) === $cssPath ) ) { |
645 | - // file not minified based on filename & filter |
|
646 | - return false; |
|
645 | + // file not minified based on filename & filter |
|
646 | + return false; |
|
647 | 647 | } else if ( strpos($css,"@import") !== false ) { |
648 | 648 | // can't late-inject files with imports as those need to be aggregated |
649 | 649 | return false; |
@@ -128,27 +128,27 @@ discard block |
||
128 | 128 | // should we add flags? |
129 | 129 | foreach ($excludeJS as $exclTag => $exclFlags) { |
130 | 130 | if ( strpos($origTag,$exclTag)!==false && in_array($exclFlags,array("async","defer")) ) { |
131 | - $newTag = str_replace('<script ','<script '.$exclFlags.' ',$newTag); |
|
131 | + $newTag = str_replace('<script ','<script '.$exclFlags.' ',$newTag); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - // should we minify the non-aggregated script? |
|
137 | - if ($path && apply_filters('autoptimize_filter_js_minify_excluded',false)) { |
|
138 | - $_CachedMinifiedUrl = $this->minify_single($path); |
|
136 | + // should we minify the non-aggregated script? |
|
137 | + if ($path && apply_filters('autoptimize_filter_js_minify_excluded',false)) { |
|
138 | + $_CachedMinifiedUrl = $this->minify_single($path); |
|
139 | 139 | |
140 | - // replace orig URL with minified URL from cache if so |
|
141 | - if (!empty($_CachedMinifiedUrl)) { |
|
142 | - $newTag = str_replace($url, $_CachedMinifiedUrl, $newTag); |
|
143 | - } |
|
140 | + // replace orig URL with minified URL from cache if so |
|
141 | + if (!empty($_CachedMinifiedUrl)) { |
|
142 | + $newTag = str_replace($url, $_CachedMinifiedUrl, $newTag); |
|
143 | + } |
|
144 | 144 | |
145 | - // remove querystring from URL in newTag |
|
146 | - if ( !empty($explUrl[1]) ) { |
|
147 | - $newTag = str_replace("?".$explUrl[1],"",$newTag); |
|
148 | - } |
|
149 | - } |
|
145 | + // remove querystring from URL in newTag |
|
146 | + if ( !empty($explUrl[1]) ) { |
|
147 | + $newTag = str_replace("?".$explUrl[1],"",$newTag); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - // should we move the non-aggregated script? |
|
151 | + // should we move the non-aggregated script? |
|
152 | 152 | if( $this->ismovable($newTag) ) { |
153 | 153 | // can be moved, flags and all |
154 | 154 | if( $this->movetolast($newTag) ) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | //$this->jscode has all the uncompressed code now. |
263 | 263 | if ($this->alreadyminified!==true) { |
264 | - if (class_exists('JSMin') && apply_filters( 'autoptimize_js_do_minify' , true)) { |
|
264 | + if (class_exists('JSMin') && apply_filters( 'autoptimize_js_do_minify' , true)) { |
|
265 | 265 | if (@is_callable(array("JSMin","minify"))) { |
266 | 266 | $tmp_jscode = trim(JSMin::minify($this->jscode)); |
267 | 267 | if (!empty($tmp_jscode)) { |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | $this->jscode = $this->inject_minified($this->jscode); |
276 | 276 | return false; |
277 | 277 | } |
278 | - } else { |
|
279 | - $this->jscode = $this->inject_minified($this->jscode); |
|
278 | + } else { |
|
279 | + $this->jscode = $this->inject_minified($this->jscode); |
|
280 | 280 | return false; |
281 | - } |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | return true; |
284 | 284 | } |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | |
341 | 341 | // Checks against the white- and blacklists |
342 | 342 | private function ismergeable($tag) { |
343 | - if (apply_filters('autoptimize_filter_js_dontaggregate',false)) { |
|
344 | - return false; |
|
343 | + if (apply_filters('autoptimize_filter_js_dontaggregate',false)) { |
|
344 | + return false; |
|
345 | 345 | } else if (!empty($this->whitelist)) { |
346 | 346 | foreach ($this->whitelist as $match) { |
347 | 347 | if(strpos($tag,$match)!==false) { |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @param string $jsPath |
451 | 451 | * @return bool |
452 | - */ |
|
453 | - private function can_inject_late($jsPath) { |
|
454 | - $consider_minified_array = apply_filters('autoptimize_filter_js_consider_minified',false); |
|
452 | + */ |
|
453 | + private function can_inject_late($jsPath) { |
|
454 | + $consider_minified_array = apply_filters('autoptimize_filter_js_consider_minified',false); |
|
455 | 455 | if ( $this->inject_min_late !== true ) { |
456 | 456 | // late-inject turned off |
457 | 457 | return false; |
458 | 458 | } else if ( (strpos($jsPath,"min.js") === false) && ( strpos($jsPath,"wp-includes/js/jquery/jquery.js") === false ) && ( str_replace($consider_minified_array, '', $jsPath) === $jsPath ) ) { |
459 | - // file not minified based on filename & filter |
|
460 | - return false; |
|
459 | + // file not minified based on filename & filter |
|
460 | + return false; |
|
461 | 461 | } else { |
462 | 462 | // phew, all is safe, we can late-inject |
463 | 463 | return true; |