@@ -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 |
@@ -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 | } |
@@ -701,9 +701,15 @@ |
||
701 | 701 | private function hue_to_rgb($v1, $v2, $vh) |
702 | 702 | { |
703 | 703 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
704 | - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
|
705 | - if ($vh * 2 < 1) return $v2; |
|
706 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
704 | + if ($vh * 6 < 1) { |
|
705 | + return $v1 + ($v2 - $v1) * 6 * $vh; |
|
706 | + } |
|
707 | + if ($vh * 2 < 1) { |
|
708 | + return $v2; |
|
709 | + } |
|
710 | + if ($vh * 3 < 2) { |
|
711 | + return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
712 | + } |
|
707 | 713 | return $v1; |
708 | 714 | } |
709 | 715 |
@@ -12,7 +12,10 @@ discard block |
||
12 | 12 | http://www.gnu.org/licenses/gpl.txt |
13 | 13 | */ |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
15 | +if ( ! defined( 'ABSPATH' ) ) { |
|
16 | + exit; |
|
17 | +} |
|
18 | +// Exit if accessed directly |
|
16 | 19 | |
17 | 20 | define('AUTOPTIMIZE_PLUGIN_DIR',plugin_dir_path(__FILE__)); |
18 | 21 | |
@@ -224,12 +227,15 @@ discard block |
||
224 | 227 | |
225 | 228 | // Choose the classes |
226 | 229 | $classes = array(); |
227 | - if($conf->get('autoptimize_js')) |
|
228 | - $classes[] = 'autoptimizeScripts'; |
|
229 | - if($conf->get('autoptimize_css')) |
|
230 | - $classes[] = 'autoptimizeStyles'; |
|
231 | - if($conf->get('autoptimize_html')) |
|
232 | - $classes[] = 'autoptimizeHTML'; |
|
230 | + if($conf->get('autoptimize_js')) { |
|
231 | + $classes[] = 'autoptimizeScripts'; |
|
232 | + } |
|
233 | + if($conf->get('autoptimize_css')) { |
|
234 | + $classes[] = 'autoptimizeStyles'; |
|
235 | + } |
|
236 | + if($conf->get('autoptimize_html')) { |
|
237 | + $classes[] = 'autoptimizeHTML'; |
|
238 | + } |
|
233 | 239 | |
234 | 240 | // Set some options |
235 | 241 | $classoptions = array( |
@@ -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 | class autoptimizeToolbar |
4 | 7 | { |
5 | 8 | public function __construct() |
@@ -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 = ''; |
@@ -122,7 +125,9 @@ discard block |
||
122 | 125 | $out = parse_url($in,PHP_URL_HOST); |
123 | 126 | |
124 | 127 | // fallback if parse_url does not understand the url is in fact a url |
125 | - if (empty($out)) $out=$in; |
|
128 | + if (empty($out)) { |
|
129 | + $out=$in; |
|
130 | + } |
|
126 | 131 | |
127 | 132 | return $out; |
128 | 133 | } |
@@ -359,7 +364,9 @@ discard block |
||
359 | 364 | |
360 | 365 | // read file, return false if empty |
361 | 366 | $_toMinify = file_get_contents($pathIn); |
362 | - if ( empty($_toMinify) ) return false; |
|
367 | + if ( empty($_toMinify) ) { |
|
368 | + return false; |
|
369 | + } |
|
363 | 370 | |
364 | 371 | // check cache |
365 | 372 | $_md5hash = "single_".md5($_toMinify); |