@@ -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 | /* |
5 | 8 | * cachechecker code |
@@ -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) { |
@@ -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 |
@@ -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 autoptimizeConfig { |
5 | 8 | private $config = null; |
@@ -562,8 +565,9 @@ discard block |
||
562 | 565 | //Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/ |
563 | 566 | //Do it only once - saves time |
564 | 567 | static $plugin; |
565 | - if(empty($plugin)) |
|
566 | - $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php'); |
|
568 | + if(empty($plugin)) { |
|
569 | + $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php'); |
|
570 | + } |
|
567 | 571 | |
568 | 572 | if($file===null) { |
569 | 573 | //2.7 |
@@ -619,8 +623,9 @@ discard block |
||
619 | 623 | $this->config = $config; |
620 | 624 | } |
621 | 625 | |
622 | - if(isset($this->config[$key])) |
|
623 | - return $this->config[$key]; |
|
626 | + if(isset($this->config[$key])) { |
|
627 | + return $this->config[$key]; |
|
628 | + } |
|
624 | 629 | |
625 | 630 | return false; |
626 | 631 | } |
@@ -638,10 +643,13 @@ discard block |
||
638 | 643 | <ul> |
639 | 644 | <?php if ( $maxitems == 0 ) : ?> |
640 | 645 | <li><?php _e( 'No items', 'autoptimize' ); ?></li> |
641 | - <?php else : ?> |
|
646 | + <?php else { |
|
647 | + : ?> |
|
642 | 648 | <?php foreach ( $rss_items as $item ) : ?> |
643 | 649 | <li> |
644 | - <a href="<?php echo esc_url( $item->get_permalink() ); ?>" |
|
650 | + <a href="<?php echo esc_url( $item->get_permalink() ); |
|
651 | +} |
|
652 | +?>" |
|
645 | 653 | title="<?php printf( __( 'Posted %s', 'autoptimize' ), $item->get_date('j F Y | g:i a') ); ?>"> |
646 | 654 | <?php echo esc_html( $item->get_title() ); ?> |
647 | 655 | </a> |