| @@ -42,6 +42,9 @@ discard block | ||
| 42 | 42 | return false; | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | + /** | |
| 46 | + * @param string $mime | |
| 47 | + */ | |
| 45 | 48 |      public function cache($code,$mime) { | 
| 46 | 49 |          if($this->nogzip == false) { | 
| 47 | 50 | $file = ($this->delayed ? 'delayed.php' : 'default.php'); | 
| @@ -240,6 +243,9 @@ discard block | ||
| 240 | 243 | return true; | 
| 241 | 244 | } | 
| 242 | 245 | |
| 246 | + /** | |
| 247 | + * @param string $dir | |
| 248 | + */ | |
| 243 | 249 |      static function checkCacheDir($dir) { | 
| 244 | 250 | // Check and create if not exists | 
| 245 | 251 |          if(!file_exists($dir))    { | 
| @@ -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; | 
| @@ -625,6 +625,9 @@ | ||
| 625 | 625 | return false; | 
| 626 | 626 | } | 
| 627 | 627 | |
| 628 | + /** | |
| 629 | + * @param string $url | |
| 630 | + */ | |
| 628 | 631 |      private function getFutttaFeeds($url) { | 
| 629 | 632 |          if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) { | 
| 630 | 633 | $rss = fetch_feed( $url ); | 
| @@ -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> | 
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | * | 
| 54 | 54 | * @param array $options (currently ignored) | 
| 55 | 55 | * | 
| 56 | - * @return null | |
| 56 | + * @return string | |
| 57 | 57 | */ | 
| 58 | 58 |      private function __construct($options) { | 
| 59 | 59 | $this->_options = $options; | 
| @@ -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 @@ 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 | |
| @@ -686,6 +686,11 @@ discard block | ||
| 686 | 686 | * --------------------------------------------------------------------------------------------- | 
| 687 | 687 | */ | 
| 688 | 688 | |
| 689 | + /** | |
| 690 | + * @param double $v1 | |
| 691 | + * @param double $v2 | |
| 692 | + * @param integer $vh | |
| 693 | + */ | |
| 689 | 694 | private function hue_to_rgb($v1, $v2, $vh) | 
| 690 | 695 |      { | 
| 691 | 696 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); | 
| @@ -700,6 +705,10 @@ discard block | ||
| 700 | 705 | return intval(floor(floatval($n) + 0.5), 10); | 
| 701 | 706 | } | 
| 702 | 707 | |
| 708 | + /** | |
| 709 | + * @param integer $min | |
| 710 | + * @param integer $max | |
| 711 | + */ | |
| 703 | 712 | private function clamp_number($n, $min, $max) | 
| 704 | 713 |      { | 
| 705 | 714 | return min(max($n, $min), $max); | 
| @@ -728,7 +737,7 @@ discard block | ||
| 728 | 737 | * | 
| 729 | 738 | * @param string $str | 
| 730 | 739 | * @param int $start index | 
| 731 | - * @param int|bool $end index (optional) | |
| 740 | + * @param integer $end index (optional) | |
| 732 | 741 | * @return string | 
| 733 | 742 | */ | 
| 734 | 743 | private function str_slice($str, $start = 0, $end = FALSE) |