@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | class autoptimizeStyles extends autoptimizeBase {
|
| 5 | 8 | private $css = array(); |
@@ -22,7 +25,9 @@ discard block |
||
| 22 | 25 | //Reads the page and collects style tags |
| 23 | 26 | public function read($options) {
|
| 24 | 27 | $noptimizeCSS = apply_filters( 'autoptimize_filter_css_noptimize', false, $this->content ); |
| 25 | - if ($noptimizeCSS) return false; |
|
| 28 | + if ($noptimizeCSS) { |
|
| 29 | + return false; |
|
| 30 | + } |
|
| 26 | 31 | |
| 27 | 32 | $whitelistCSS = apply_filters( 'autoptimize_filter_css_whitelist', '' ); |
| 28 | 33 | if (!empty($whitelistCSS)) {
|
@@ -136,7 +141,7 @@ discard block |
||
| 136 | 141 | if($path!==false && preg_match('#\.css$#',$path)) {
|
| 137 | 142 | // Good link |
| 138 | 143 | $this->css[] = array($media,$path); |
| 139 | - }else{
|
|
| 144 | + } else{
|
|
| 140 | 145 | // Link is dynamic (.php etc) |
| 141 | 146 | $tag = ''; |
| 142 | 147 | } |
@@ -200,8 +205,9 @@ discard block |
||
| 200 | 205 | } |
| 201 | 206 | |
| 202 | 207 | foreach($media as $elem) {
|
| 203 | - if(!isset($this->csscode[$elem])) |
|
| 204 | - $this->csscode[$elem] = ''; |
|
| 208 | + if(!isset($this->csscode[$elem])) { |
|
| 209 | + $this->csscode[$elem] = ''; |
|
| 210 | + } |
|
| 205 | 211 | $this->csscode[$elem] .= "\n/*FILESTART*/".$css; |
| 206 | 212 | } |
| 207 | 213 | } |
@@ -331,11 +337,11 @@ discard block |
||
| 331 | 337 | preg_match_all('#url\((?!\s?"?\'?\s?data)(.*)\)#Usm',$matches[0][$index],$multi_matches);
|
| 332 | 338 | if( $multi_matches ){
|
| 333 | 339 | $image_urls_to_replace[ $index ] = $multi_matches[1]; |
| 334 | - }else{
|
|
| 340 | + } else{
|
|
| 335 | 341 | // my regex failed for some reason. default to single url matching like before. |
| 336 | 342 | $image_urls_to_replace[ $index ] = array($url); |
| 337 | 343 | } |
| 338 | - }else{
|
|
| 344 | + } else{
|
|
| 339 | 345 | // just a single image to replace this time: |
| 340 | 346 | $image_urls_to_replace[ $index ] = array($url); |
| 341 | 347 | } |