@@ -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( |
@@ -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 | } |
@@ -200,8 +205,9 @@ discard block |
||
| 200 | 205 | } |
| 201 | 206 | |
| 202 | 207 | foreach($media as $elem) {
|
| 203 | - if(!isset($this->csscode[$elem])) |
|
| 204 | - $this->csscode[$elem] = ''; |
|
| 208 | + if(!isset($this->csscode[$elem])) { |
|
| 209 | + $this->csscode[$elem] = ''; |
|
| 210 | + } |
|
| 205 | 211 | $this->csscode[$elem] .= "\n/*FILESTART*/".$css; |
| 206 | 212 | } |
| 207 | 213 | } |
@@ -331,11 +337,11 @@ discard block |
||
| 331 | 337 | preg_match_all('#url\((?!\s?"?\'?\s?data)(.*)\)#Usm',$matches[0][$index],$multi_matches);
|
| 332 | 338 | if( $multi_matches ){
|
| 333 | 339 | $image_urls_to_replace[ $index ] = $multi_matches[1]; |
| 334 | - }else{
|
|
| 340 | + } else{
|
|
| 335 | 341 | // my regex failed for some reason. default to single url matching like before. |
| 336 | 342 | $image_urls_to_replace[ $index ] = array($url); |
| 337 | 343 | } |
| 338 | - }else{
|
|
| 344 | + } else{
|
|
| 339 | 345 | // just a single image to replace this time: |
| 340 | 346 | $image_urls_to_replace[ $index ] = array($url); |
| 341 | 347 | } |
@@ -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 | |