@@ -1,10 +1,12 @@ discard block |
||
1 | 1 | <?php exit; |
2 | 2 | |
3 | 3 | //Check everything exists before using it |
4 | -if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
4 | +if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { |
|
5 | 5 | $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; |
6 | -if(!isset($_SERVER['HTTP_USER_AGENT'])) |
|
6 | +} |
|
7 | +if(!isset($_SERVER['HTTP_USER_AGENT'])) { |
|
7 | 8 | $_SERVER['HTTP_USER_AGENT'] = ''; |
9 | +} |
|
8 | 10 | |
9 | 11 | // Determine supported compression method |
10 | 12 | $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
@@ -19,16 +21,19 @@ discard block |
||
19 | 21 | { |
20 | 22 | $version = floatval($matches[1]); |
21 | 23 | |
22 | - if ($version < 6) |
|
23 | - $encoding = 'none'; |
|
24 | + if ($version < 6) { |
|
25 | + $encoding = 'none'; |
|
26 | + } |
|
24 | 27 | |
25 | - if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) |
|
26 | - $encoding = 'none'; |
|
27 | -} |
|
28 | + if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) { |
|
29 | + $encoding = 'none'; |
|
30 | + } |
|
31 | + } |
|
28 | 32 | |
29 | 33 | //Some servers compress the output of PHP - Don't break in those cases |
30 | -if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) |
|
34 | +if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) { |
|
31 | 35 | $encoding = 'none'; |
36 | +} |
|
32 | 37 | |
33 | 38 | //Get data |
34 | 39 | $contents = file_get_contents(__FILE__.'.'.$encoding); |
@@ -1,10 +1,12 @@ discard block |
||
1 | 1 | <?php exit; |
2 | 2 | |
3 | 3 | //Check everything exists before using it |
4 | -if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) |
|
4 | +if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { |
|
5 | 5 | $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; |
6 | -if(!isset($_SERVER['HTTP_USER_AGENT'])) |
|
6 | +} |
|
7 | +if(!isset($_SERVER['HTTP_USER_AGENT'])) { |
|
7 | 8 | $_SERVER['HTTP_USER_AGENT'] = ''; |
9 | +} |
|
8 | 10 | |
9 | 11 | // Determine supported compression method |
10 | 12 | $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
@@ -19,16 +21,19 @@ discard block |
||
19 | 21 | { |
20 | 22 | $version = floatval($matches[1]); |
21 | 23 | |
22 | - if ($version < 6) |
|
23 | - $encoding = 'none'; |
|
24 | + if ($version < 6) { |
|
25 | + $encoding = 'none'; |
|
26 | + } |
|
24 | 27 | |
25 | - if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) |
|
26 | - $encoding = 'none'; |
|
27 | -} |
|
28 | + if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) { |
|
29 | + $encoding = 'none'; |
|
30 | + } |
|
31 | + } |
|
28 | 32 | |
29 | 33 | //Some servers compress the output of PHP - Don't break in those cases |
30 | -if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) |
|
34 | +if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) { |
|
31 | 35 | $encoding = 'none'; |
36 | +} |
|
32 | 37 | |
33 | 38 | $iscompressed = file_exists(__FILE__.'.'.$encoding); |
34 | 39 | if($encoding != 'none' && $iscompressed == false) |
@@ -36,7 +41,7 @@ discard block |
||
36 | 41 | $flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE); |
37 | 42 | $code = file_get_contents(__FILE__.'.none'); |
38 | 43 | $contents = gzencode($code,9,$flag); |
39 | -}else{ |
|
44 | +} else{ |
|
40 | 45 | //Get data |
41 | 46 | $contents = file_get_contents(__FILE__.'.'.$encoding); |
42 | 47 | } |
@@ -1,5 +1,8 @@ |
||
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 autoptimizeCache { |
5 | 8 | private $filename; |
@@ -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 autoptimizeHTML extends autoptimizeBase { |
5 | 8 | private $keepcomments = false; |
@@ -26,8 +29,9 @@ discard block |
||
26 | 29 | //Joins and optimizes CSS |
27 | 30 | public function minify() { |
28 | 31 | $noptimizeHTML = apply_filters( 'autoptimize_filter_html_noptimize', false, $this->content ); |
29 | - if ($noptimizeHTML) |
|
30 | - return false; |
|
32 | + if ($noptimizeHTML) { |
|
33 | + return false; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | if(class_exists('Minify_HTML')) { |
33 | 37 | // wrap the to-be-excluded strings in noptimize tags |
@@ -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 autoptimizeScripts extends autoptimizeBase { |
5 | 8 | private $scripts = array(); |
@@ -22,7 +25,9 @@ discard block |
||
22 | 25 | //Reads the page and collects script tags |
23 | 26 | public function read($options) { |
24 | 27 | $noptimizeJS = apply_filters( 'autoptimize_filter_js_noptimize', false, $this->content ); |
25 | - if ($noptimizeJS) return false; |
|
28 | + if ($noptimizeJS) { |
|
29 | + return false; |
|
30 | + } |
|
26 | 31 | |
27 | 32 | // only optimize known good JS? |
28 | 33 | $whitelistJS = apply_filters( 'autoptimize_filter_js_whitelist', "" ); |
@@ -65,8 +70,9 @@ discard block |
||
65 | 70 | } |
66 | 71 | |
67 | 72 | //Should we add try-catch? |
68 | - if($options['trycatch'] == true) |
|
69 | - $this->trycatch = true; |
|
73 | + if($options['trycatch'] == true) { |
|
74 | + $this->trycatch = true; |
|
75 | + } |
|
70 | 76 | |
71 | 77 | // force js in head? |
72 | 78 | if($options['forcehead'] == true) { |
@@ -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 | abstract class autoptimizeBase { |
5 | 8 | protected $content = ''; |
@@ -106,7 +109,9 @@ discard block |
||
106 | 109 | $out = parse_url($in,PHP_URL_HOST); |
107 | 110 | |
108 | 111 | // fallback if parse_url does not understand the url is in fact a url |
109 | - if (empty($out)) $out=$in; |
|
112 | + if (empty($out)) { |
|
113 | + $out=$in; |
|
114 | + } |
|
110 | 115 | |
111 | 116 | return $out; |
112 | 117 | } |
@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | default: |
192 | 192 | if ($this->isAlphaNum($this->b)) { |
193 | 193 | $this->action(1); |
194 | - } |
|
195 | - else { |
|
194 | + } else { |
|
196 | 195 | $this->action(2); |
197 | 196 | } |
198 | 197 | } |
@@ -224,8 +223,7 @@ discard block |
||
224 | 223 | default: |
225 | 224 | if ($this->isAlphaNum($this->a)) { |
226 | 225 | $this->action(1); |
227 | - } |
|
228 | - else { |
|
226 | + } else { |
|
229 | 227 | $this->action(3); |
230 | 228 | } |
231 | 229 | } |
@@ -689,9 +689,15 @@ |
||
689 | 689 | private function hue_to_rgb($v1, $v2, $vh) |
690 | 690 | { |
691 | 691 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
692 | - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
|
693 | - if ($vh * 2 < 1) return $v2; |
|
694 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
692 | + if ($vh * 6 < 1) { |
|
693 | + return $v1 + ($v2 - $v1) * 6 * $vh; |
|
694 | + } |
|
695 | + if ($vh * 2 < 1) { |
|
696 | + return $v2; |
|
697 | + } |
|
698 | + if ($vh * 3 < 2) { |
|
699 | + return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
700 | + } |
|
695 | 701 | return $v1; |
696 | 702 | } |
697 | 703 |
@@ -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 | } |
@@ -199,8 +204,9 @@ discard block |
||
199 | 204 | } |
200 | 205 | |
201 | 206 | foreach($media as $elem) { |
202 | - if(!isset($this->csscode[$elem])) |
|
203 | - $this->csscode[$elem] = ''; |
|
207 | + if(!isset($this->csscode[$elem])) { |
|
208 | + $this->csscode[$elem] = ''; |
|
209 | + } |
|
204 | 210 | $this->csscode[$elem] .= "\n/*FILESTART*/".$css; |
205 | 211 | } |
206 | 212 | } |