@@ -1,12 +1,17 @@ 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 autoptimizeToolbar { |
5 | 8 | |
6 | 9 | public function __construct() |
7 | 10 | { |
8 | 11 | // If Cache is not available we don't add the Autoptimize Toolbar |
9 | - if( !autoptimizeCache::cacheavail() ) return; |
|
12 | + if( !autoptimizeCache::cacheavail() ) { |
|
13 | + return; |
|
14 | + } |
|
10 | 15 | |
11 | 16 | // Load admin toolbar feature once WordPress, all plugins, and the theme are fully loaded and instantiated. |
12 | 17 | add_action( 'wp_loaded', array( $this, 'load_toolbar' ) ); |
@@ -53,7 +58,9 @@ discard block |
||
53 | 58 | |
54 | 59 | // We calculated the percentage of cache used |
55 | 60 | $percentage = ceil( $bytes / $max_size * 100 ); |
56 | - if( $percentage > 100 ) $percentage = 100; |
|
61 | + if( $percentage > 100 ) { |
|
62 | + $percentage = 100; |
|
63 | + } |
|
57 | 64 | |
58 | 65 | // We define the type of color indicator for the current state of cache size. |
59 | 66 | // "green" if the size is less than 80% of the total recommended |
@@ -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( |
@@ -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 autoptimizeStyles extends autoptimizeBase { |
5 | 8 | |
@@ -25,7 +28,9 @@ discard block |
||
25 | 28 | //Reads the page and collects style tags |
26 | 29 | public function read($options) { |
27 | 30 | $noptimizeCSS = apply_filters( 'autoptimize_filter_css_noptimize', false, $this->content ); |
28 | - if ($noptimizeCSS) return false; |
|
31 | + if ($noptimizeCSS) { |
|
32 | + return false; |
|
33 | + } |
|
29 | 34 | |
30 | 35 | $whitelistCSS = apply_filters( 'autoptimize_filter_css_whitelist', '' ); |
31 | 36 | if (!empty($whitelistCSS)) { |
@@ -139,7 +144,7 @@ discard block |
||
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 | } |
@@ -202,8 +207,9 @@ discard block |
||
202 | 207 | } |
203 | 208 | |
204 | 209 | foreach($media as $elem) { |
205 | - if(!isset($this->csscode[$elem])) |
|
206 | - $this->csscode[$elem] = ''; |
|
210 | + if(!isset($this->csscode[$elem])) { |
|
211 | + $this->csscode[$elem] = ''; |
|
212 | + } |
|
207 | 213 | $this->csscode[$elem] .= "\n/*FILESTART*/".$css; |
208 | 214 | } |
209 | 215 | } |