Completed
Push — master ( 8aecdb...4fae88 )
by frank
02:43
created
classes/autoptimizeStyles.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -162,32 +162,32 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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, $cssPath);
640
+        $consider_minified_array = apply_filters('autoptimize_filter_css_consider_minified', false, $cssPath);
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;
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
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
 
@@ -24,7 +27,9 @@  discard block
 block discarded – undo
24 27
     //Reads the page and collects style tags
25 28
     public function read($options) {
26 29
         $noptimizeCSS = apply_filters( 'autoptimize_filter_css_noptimize', false, $this->content );
27
-        if ($noptimizeCSS) return false;
30
+        if ($noptimizeCSS) {
31
+            return false;
32
+        }
28 33
 
29 34
         $whitelistCSS = apply_filters( 'autoptimize_filter_css_whitelist', '', $this->content );
30 35
         if (!empty($whitelistCSS)) {
@@ -139,7 +144,7 @@  discard block
 block discarded – undo
139 144
                         if($path!==false && preg_match('#\.css$#',$path)) {
140 145
                             // Good link
141 146
                             $this->css[] = array($media,$path);
142
-                        }else{
147
+                        } else{
143 148
                             // Link is dynamic (.php etc)
144 149
                             $tag = '';
145 150
                         }
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
             }
229 234
             
230 235
             foreach($media as $elem) {
231
-                if(!isset($this->csscode[$elem]))
232
-                    $this->csscode[$elem] = '';
236
+                if(!isset($this->csscode[$elem])) {
237
+                                    $this->csscode[$elem] = '';
238
+                }
233 239
                 $this->csscode[$elem] .= "\n/*FILESTART*/".$css;
234 240
             }
235 241
         }
Please login to merge, or discard this patch.