Completed
Push — master ( 4e28ab...a3ebdc )
by frank
07:39
created
autoptimize.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,66 +16,66 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if (!defined('ABSPATH')) {
20 20
     exit;
21 21
 }
22 22
 
23
-define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.4.0' );
23
+define('AUTOPTIMIZE_PLUGIN_VERSION', '2.4.0');
24 24
 
25 25
 // plugin_dir_path() returns the trailing slash!
26
-define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
27
-define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ );
26
+define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__));
27
+define('AUTOPTIMIZE_PLUGIN_FILE', __FILE__);
28 28
 
29 29
 // Bail early if attempting to run on non-supported php versions.
30
-if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
30
+if (version_compare(PHP_VERSION, '5.3', '<')) {
31 31
     function autoptimize_incompatible_admin_notice() {
32
-        echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>';
33
-        if ( isset( $_GET['activate'] ) ) {
34
-            unset( $_GET['activate'] );
32
+        echo '<div class="error"><p>'.__('Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize').'</p></div>';
33
+        if (isset($_GET['activate'])) {
34
+            unset($_GET['activate']);
35 35
         }
36 36
     }
37 37
     function autoptimize_deactivate_self() {
38
-        deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) );
38
+        deactivate_plugins(plugin_basename(AUTOPTIMIZE_PLUGIN_FILE));
39 39
     }
40
-    add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' );
41
-    add_action( 'admin_init', 'autoptimize_deactivate_self' );
40
+    add_action('admin_notices', 'autoptimize_incompatible_admin_notice');
41
+    add_action('admin_init', 'autoptimize_deactivate_self');
42 42
     return;
43 43
 }
44 44
 
45
-function autoptimize_autoload( $class_name ) {
46
-    if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) {
47
-        $file     = strtolower( $class_name );
48
-        $file     = str_replace( '_', '-', $file );
49
-        $path     = dirname( __FILE__ ) . '/classes/external/php/';
50
-        $filepath = $path . $file . '.php';
51
-    } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) {
52
-        $file     = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name );
53
-        $path     = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/';
54
-        $filepath = $path . $file . '.php';
55
-    } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) {
45
+function autoptimize_autoload($class_name) {
46
+    if (in_array($class_name, array('Minify_HTML', 'JSMin'))) {
47
+        $file     = strtolower($class_name);
48
+        $file     = str_replace('_', '-', $file);
49
+        $path     = dirname(__FILE__).'/classes/external/php/';
50
+        $filepath = $path.$file.'.php';
51
+    } elseif (false !== strpos($class_name, 'Autoptimize\\tubalmartin\\CssMin')) {
52
+        $file     = str_replace('Autoptimize\\tubalmartin\\CssMin\\', '', $class_name);
53
+        $path     = dirname(__FILE__).'/classes/external/php/yui-php-cssmin-bundled/';
54
+        $filepath = $path.$file.'.php';
55
+    } elseif ('autoptimize' === substr($class_name, 0, 11)) {
56 56
         // One of our "old" classes.
57 57
         $file     = $class_name;
58
-        $path     = dirname( __FILE__ ) . '/classes/';
59
-        $filepath = $path . $file . '.php';
60
-    } elseif ( 'PAnD' === $class_name ) {
58
+        $path     = dirname(__FILE__).'/classes/';
59
+        $filepath = $path.$file.'.php';
60
+    } elseif ('PAnD' === $class_name) {
61 61
         $file     = 'persist-admin-notices-dismissal';
62
-        $path     = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/';
63
-        $filepath = $path . $file . '.php';
62
+        $path     = dirname(__FILE__).'/classes/external/php/persist-admin-notices-dismissal/';
63
+        $filepath = $path.$file.'.php';
64 64
     }
65 65
 
66 66
     // If we didn't match one of our rules, bail!
67
-    if ( ! isset( $filepath ) ) {
67
+    if (!isset($filepath)) {
68 68
         return;
69 69
     }
70 70
 
71 71
     require $filepath;
72 72
 }
73 73
 
74
-spl_autoload_register( 'autoptimize_autoload' );
74
+spl_autoload_register('autoptimize_autoload');
75 75
 
76 76
 // Load WP CLI command(s) on demand.
77
-if ( defined( 'WP_CLI' ) && WP_CLI ) {
78
-    require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php';
77
+if (defined('WP_CLI') && WP_CLI) {
78
+    require AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php';
79 79
 }
80 80
 
81 81
 /**
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 function autoptimize() {
87 87
     static $plugin = null;
88 88
 
89
-    if ( null === $plugin ) {
90
-        $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE );
89
+    if (null === $plugin) {
90
+        $plugin = new autoptimizeMain(AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE);
91 91
     }
92 92
 
93 93
     return $plugin;
Please login to merge, or discard this patch.
config/default.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
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
+if (!isset($_SERVER['HTTP_USER_AGENT']))
7 7
 	$_SERVER['HTTP_USER_AGENT'] = '';
8 8
 
9 9
 // Determine supported compression method
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 }
28 28
 
29 29
 //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)
30
+if (ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1)
31 31
 	$encoding = 'none';
32 32
 
33 33
 $iscompressed = file_exists(__FILE__.'.'.$encoding);
34
-if($encoding != 'none' && $iscompressed == false)
34
+if ($encoding != 'none' && $iscompressed == false)
35 35
 {
36 36
 	$flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
37 37
 	$code = file_get_contents(__FILE__.'.none');
38
-	$contents = gzencode($code,9,$flag);
39
-}else{
38
+	$contents = gzencode($code, 9, $flag);
39
+} else {
40 40
 	//Get data
41 41
 	$contents = file_get_contents(__FILE__.'.'.$encoding);
42 42
 }
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 // first check if we have to send 304
45 45
 // inspired by http://www.jonasjohn.de/snippets/php/caching.htm
46 46
 
47
-$eTag=md5($contents);
48
-$modTime=filemtime(__FILE__.'.none');
47
+$eTag = md5($contents);
48
+$modTime = filemtime(__FILE__.'.none');
49 49
 
50 50
 date_default_timezone_set("UTC");
51
-$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'],$eTag));
51
+$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'], $eTag));
52 52
 $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime);
53 53
 
54
-if (($modTimeMatch)||($eTagMatch)) {
54
+if (($modTimeMatch) || ($eTagMatch)) {
55 55
 	header('HTTP/1.1 304 Not Modified');
56 56
 	header('Connection: close');
57 57
 } else {
58 58
 	// send all sorts of headers
59
-	$expireTime=60*60*24*355; // 1y max according to RFC
59
+	$expireTime = 60*60*24*355; // 1y max according to RFC
60 60
 	if ($encoding != 'none') {
61 61
 		header('Content-Encoding: '.$encoding);
62 62
 	}
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
 	header('Cache-Control: max-age='.$expireTime.', public, must-revalidate');
67 67
 	header('Cache-Control: max-age='.$expireTime.', public, immutable');
68 68
 	header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT');
69
-	header('ETag: ' . $eTag);
69
+	header('ETag: '.$eTag);
70 70
 	header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT');
71 71
 
72 72
 	// send output
73 73
 	echo $contents;
74 74
 
75 75
 	//And write to filesystem cache if not done yet
76
-	if($encoding != 'none' && $iscompressed == false)
76
+	if ($encoding != 'none' && $iscompressed == false)
77 77
 	{
78 78
 		//Write the content we sent
79
-		file_put_contents(__FILE__.'.'.$encoding,$contents);
79
+		file_put_contents(__FILE__.'.'.$encoding, $contents);
80 80
 
81 81
 		//And write the new content
82 82
 		$flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
83 83
 		$ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
84
-		$contents = gzencode($code,9,$flag);
85
-		file_put_contents(__FILE__.'.'.$ext,$contents);
84
+		$contents = gzencode($code, 9, $flag);
85
+		file_put_contents(__FILE__.'.'.$ext, $contents);
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
php/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 /**
29 29
  * Exit if called directly.
30 30
  */
31
-if ( ! defined( 'ABSPATH' ) ) {
31
+if (!defined('ABSPATH')) {
32 32
 	die;
33 33
 }
34 34
 
35
-if ( ! class_exists( 'PAnD' ) ) {
35
+if (!class_exists('PAnD')) {
36 36
 
37 37
 	/**
38 38
 	 * Class PAnD
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 		 * Init hooks.
44 44
 		 */
45 45
 		public static function init() {
46
-			add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
47
-			add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
46
+			add_action('admin_enqueue_scripts', array(__CLASS__, 'load_script'));
47
+			add_action('wp_ajax_dismiss_admin_notice', array(__CLASS__, 'dismiss_admin_notice'));
48 48
 		}
49 49
 
50 50
 		/**
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 		 */
53 53
 		public static function load_script() {
54 54
 
55
-		    if(is_customize_preview()) return;
55
+		    if (is_customize_preview()) return;
56 56
 
57 57
 			wp_enqueue_script(
58 58
 				'dismissible-notices',
59
-				plugins_url( 'dismiss-notice.js', __FILE__ ),
60
-				array( 'jquery', 'common' ),
59
+				plugins_url('dismiss-notice.js', __FILE__),
60
+				array('jquery', 'common'),
61 61
 				false,
62 62
 				true
63 63
 			);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 				'dismissible-notices',
67 67
 				'dismissible_notice',
68 68
 				array(
69
-					'nonce' => wp_create_nonce( 'dismissible-notice' ),
69
+					'nonce' => wp_create_nonce('dismissible-notice'),
70 70
 				)
71 71
 			);
72 72
 		}
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		 * Uses check_ajax_referer to verify nonce.
77 77
 		 */
78 78
 		public static function dismiss_admin_notice() {
79
-			$option_name        = sanitize_text_field( $_POST['option_name'] );
80
-			$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
79
+			$option_name        = sanitize_text_field($_POST['option_name']);
80
+			$dismissible_length = sanitize_text_field($_POST['dismissible_length']);
81 81
 			$transient          = 0;
82 82
 
83
-			if ( 'forever' != $dismissible_length ) {
83
+			if ('forever' != $dismissible_length) {
84 84
 				// If $dismissible_length is not an integer default to 1
85
-				$dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
86
-				$transient          = absint( $dismissible_length ) * DAY_IN_SECONDS;
87
-				$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
85
+				$dismissible_length = (0 == absint($dismissible_length)) ? 1 : $dismissible_length;
86
+				$transient          = absint($dismissible_length)*DAY_IN_SECONDS;
87
+				$dismissible_length = strtotime(absint($dismissible_length).' days');
88 88
 			}
89 89
 
90
-			check_ajax_referer( 'dismissible-notice', 'nonce' );
91
-			set_site_transient( $option_name, $dismissible_length, $transient );
90
+			check_ajax_referer('dismissible-notice', 'nonce');
91
+			set_site_transient($option_name, $dismissible_length, $transient);
92 92
 			wp_die();
93 93
 		}
94 94
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @return bool
101 101
 		 */
102
-		public static function is_admin_notice_active( $arg ) {
103
-			$array       = explode( '-', $arg );
104
-			$length      = array_pop( $array );
105
-			$option_name = implode( '-', $array );
106
-			$db_record   = get_site_transient( $option_name );
102
+		public static function is_admin_notice_active($arg) {
103
+			$array       = explode('-', $arg);
104
+			$length      = array_pop($array);
105
+			$option_name = implode('-', $array);
106
+			$db_record   = get_site_transient($option_name);
107 107
 
108
-			if ( 'forever' == $db_record ) {
108
+			if ('forever' == $db_record) {
109 109
 				return false;
110
-			} elseif ( absint( $db_record ) >= time() ) {
110
+			} elseif (absint($db_record) >= time()) {
111 111
 				return false;
112 112
 			} else {
113 113
 				return true;
Please login to merge, or discard this patch.
classes/external/php/yui-php-cssmin-bundled/Utils.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
         $l = floatval(str_replace('%', '', $hslValues[2]));
39 39
 
40 40
         // Wrap and clamp, then fraction!
41
-        $h = ((($h % 360) + 360) % 360) / 360;
42
-        $s = self::clampNumber($s, 0, 100) / 100;
43
-        $l = self::clampNumber($l, 0, 100) / 100;
41
+        $h = ((($h%360) + 360)%360)/360;
42
+        $s = self::clampNumber($s, 0, 100)/100;
43
+        $l = self::clampNumber($l, 0, 100)/100;
44 44
 
45 45
         if ($s == 0) {
46
-            $r = $g = $b = self::roundNumber(255 * $l);
46
+            $r = $g = $b = self::roundNumber(255*$l);
47 47
         } else {
48
-            $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
49
-            $v1 = (2 * $l) - $v2;
50
-            $r = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h + (1/3)));
51
-            $g = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h));
52
-            $b = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h - (1/3)));
48
+            $v2 = $l < 0.5 ? $l*(1 + $s) : ($l + $s) - ($s*$l);
49
+            $v1 = (2*$l) - $v2;
50
+            $r = self::roundNumber(255*self::hueToRgb($v1, $v2, $h + (1/3)));
51
+            $g = self::roundNumber(255*self::hueToRgb($v1, $v2, $h));
52
+            $b = self::roundNumber(255*self::hueToRgb($v1, $v2, $h - (1/3)));
53 53
         }
54 54
 
55 55
         return array($r, $g, $b);
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     {
67 67
         $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
68 68
 
69
-        if ($vh * 6 < 1) {
70
-            return $v1 + ($v2 - $v1) * 6 * $vh;
69
+        if ($vh*6 < 1) {
70
+            return $v1 + ($v2 - $v1)*6*$vh;
71 71
         }
72 72
 
73
-        if ($vh * 2 < 1) {
73
+        if ($vh*2 < 1) {
74 74
             return $v2;
75 75
         }
76 76
 
77
-        if ($vh * 3 < 2) {
78
-            return $v1 + ($v2 - $v1) * ((2 / 3) - $vh) * 6;
77
+        if ($vh*3 < 2) {
78
+            return $v1 + ($v2 - $v1)*((2/3) - $vh)*6;
79 79
         }
80 80
 
81 81
         return $v1;
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
             switch ($letter) {
95 95
                 case 'M':
96 96
                 case 'm':
97
-                    return (int) $size * 1048576;
97
+                    return (int) $size*1048576;
98 98
                 case 'K':
99 99
                 case 'k':
100
-                    return (int) $size * 1024;
100
+                    return (int) $size*1024;
101 101
                 case 'G':
102 102
                 case 'g':
103
-                    return (int) $size * 1073741824;
103
+                    return (int) $size*1073741824;
104 104
             }
105 105
         }
106 106
         return (int) $size;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     public static function rgbPercentageToRgbInteger($rgbPercentage)
115 115
     {
116 116
         if (strpos($rgbPercentage, '%') !== false) {
117
-            $rgbPercentage = self::roundNumber(floatval(str_replace('%', '', $rgbPercentage)) * 2.55);
117
+            $rgbPercentage = self::roundNumber(floatval(str_replace('%', '', $rgbPercentage))*2.55);
118 118
         }
119 119
 
120 120
         return intval($rgbPercentage, 10);
Please login to merge, or discard this patch.
classes/external/php/jsmin.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     protected $inputLength = 0;
71 71
     protected $lookAhead   = null;
72 72
     protected $output      = '';
73
-    protected $lastByteOut  = '';
73
+    protected $lastByteOut = '';
74 74
     protected $keptComment = '';
75 75
 
76 76
     /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         }
107 107
 
108 108
         $mbIntEnc = null;
109
-        if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
109
+        if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
110 110
             $mbIntEnc = mb_internal_encoding();
111 111
             mb_internal_encoding('8bit');
112 112
         }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                         && ($this->b === $this->lastByteOut)) {
129 129
                     // Don't delete this space. If we do, the addition/subtraction
130 130
                     // could be parsed as a post-increment
131
-                } elseif (! $this->isAlphaNum($this->b)) {
131
+                } elseif (!$this->isAlphaNum($this->b)) {
132 132
                     $command = self::ACTION_DELETE_A;
133 133
                 }
134 134
             } elseif ($this->a === "\n") {
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
                     // otherwise mb_strpos will give WARNING
140 140
                 } elseif ($this->b === null
141 141
                           || (false === strpos('{[(+-!~', $this->b)
142
-                              && ! $this->isAlphaNum($this->b))) {
142
+                              && !$this->isAlphaNum($this->b))) {
143 143
                     $command = self::ACTION_DELETE_A;
144 144
                 }
145
-            } elseif (! $this->isAlphaNum($this->a)) {
145
+            } elseif (!$this->isAlphaNum($this->a)) {
146 146
                 if ($this->b === ' '
147 147
                     || ($this->b === "\n"
148 148
                         && (false === strpos('}])+-"\'', $this->a)))) {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                 $this->a = $this->b;
199 199
                 if ($this->a === "'" || $this->a === '"') { // string literal
200 200
                     $str = $this->a; // in case needed for exception
201
-                    for(;;) {
201
+                    for (;;) {
202 202
                         $this->output .= $this->a;
203 203
                         $this->lastByteOut = $this->a;
204 204
 
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
             case self::ACTION_DELETE_A_B: // 3
227 227
                 $this->b = $this->next();
228 228
                 if ($this->b === '/' && $this->isRegexpLiteral()) {
229
-                    $this->output .= $this->a . $this->b;
229
+                    $this->output .= $this->a.$this->b;
230 230
                     $pattern = '/'; // keep entire pattern in case we need to report it in the exception
231
-                    for(;;) {
231
+                    for (;;) {
232 232
                         $this->a = $this->get();
233 233
                         $pattern .= $this->a;
234 234
                         if ($this->a === '[') {
235
-                            for(;;) {
235
+                            for (;;) {
236 236
                                 $this->output .= $this->a;
237 237
                                 $this->a = $this->get();
238 238
                                 $pattern .= $this->a;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                                 if ($this->isEOF($this->a)) {
248 248
                                     throw new JSMin_UnterminatedRegExpException(
249 249
                                         "JSMin: Unterminated set in RegExp at byte "
250
-                                            . $this->inputIndex .": {$pattern}");
250
+                                            . $this->inputIndex.": {$pattern}");
251 251
                                 }
252 252
                             }
253 253
                         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
         // if the "/" follows a keyword, it must be a regexp, otherwise it's best to assume division
294 294
 
295
-        $subject = $this->output . trim($this->a);
295
+        $subject = $this->output.trim($this->a);
296 296
         if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) {
297 297
             // not a keyword
298 298
             return false;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     {
404 404
         $this->get();
405 405
         $comment = '';
406
-        for(;;) {
406
+        for (;;) {
407 407
             $get = $this->get();
408 408
             if ($get === '*') {
409 409
                 if ($this->peek() === '/') { // end of comment reached
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
                             // don't prepend a newline if two comments right after one another
415 415
                             $this->keptComment = "\n";
416 416
                         }
417
-                        $this->keptComment .= "/*!" . substr($comment, 1) . "*/\n";
417
+                        $this->keptComment .= "/*!".substr($comment, 1)."*/\n";
418 418
                     } else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
419 419
                         // IE conditional
420 420
                         $this->keptComment .= "/*{$comment}*/";
Please login to merge, or discard this patch.
classes/external/php/minify-html.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $this->_html = str_replace("\r\n", "\n", trim($html));
72 72
         if (isset($options['xhtml'])) {
73
-            $this->_isXhtml = (bool)$options['xhtml'];
73
+            $this->_isXhtml = (bool) $options['xhtml'];
74 74
         }
75 75
         if (isset($options['cssMinifier'])) {
76 76
             $this->_cssMinifier = $options['cssMinifier'];
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             $this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
96 96
         }
97 97
 
98
-        $this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
98
+        $this->_replacementHash = 'MINIFYHTML'.md5($_SERVER['REQUEST_TIME']);
99 99
         $this->_placeholders = array();
100 100
 
101 101
         // replace SCRIPTs (and minify) with placeholders
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             ,$this->_html);
112 112
 
113 113
         // remove HTML comments (not containing IE conditional comments).
114
-        if  ($this->_keepComments == false) {
114
+        if ($this->_keepComments == false) {
115 115
             $this->_html = preg_replace_callback(
116 116
                 '/<!--([\\s\\S]*?)-->/'
117 117
                 ,array($this, '_commentCB')
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
     protected function _reservePlace($content)
175 175
     {
176
-        $placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
176
+        $placeholder = '%'.$this->_replacementHash.count($this->_placeholders).'%';
177 177
         $this->_placeholders[$placeholder] = $content;
178 178
         return $placeholder;
179 179
     }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
     protected function _outsideTagCB($m)
189 189
     {
190
-        return '>' . preg_replace('/^\\s+|\\s+$/', ' ', $m[1]) . '<';
190
+        return '>'.preg_replace('/^\\s+|\\s+$/', ' ', $m[1]).'<';
191 191
     }
192 192
 
193 193
     protected function _removePreCB($m)
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
     protected function _removeCdata($str)
260 260
     {
261 261
         return (false !== strpos($str, '<![CDATA['))
262
-            ? str_replace(array('/* <![CDATA[ */','/* ]]> */','/*<![CDATA[*/','/*]]>*/','<![CDATA[', ']]>'), '', $str)
262
+            ? str_replace(array('/* <![CDATA[ */', '/* ]]> */', '/*<![CDATA[*/', '/*]]>*/', '<![CDATA[', ']]>'), '', $str)
263 263
             : $str;
264 264
     }
265 265
 
Please login to merge, or discard this patch.
classes/autoptimizeHTML.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Handles minifying HTML markup.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
         '<!--/noindex-->',
28 28
     );
29 29
 
30
-    public function read( $options )
30
+    public function read($options)
31 31
     {
32 32
         // Remove the HTML comments?
33 33
         $this->keepcomments = (bool) $options['keepcomments'];
34 34
 
35 35
         // Filter to force xhtml.
36
-        $this->forcexhtml = (bool) apply_filters( 'autoptimize_filter_html_forcexhtml', false );
36
+        $this->forcexhtml = (bool) apply_filters('autoptimize_filter_html_forcexhtml', false);
37 37
 
38 38
         // Filterable strings to be excluded from HTML minification.
39
-        $exclude = apply_filters( 'autoptimize_filter_html_exclude', '' );
40
-        if ( '' !== $exclude ) {
41
-            $exclude_arr   = array_filter( array_map( 'trim', explode( ',', $exclude ) ) );
42
-            $this->exclude = array_merge( $exclude_arr, $this->exclude );
39
+        $exclude = apply_filters('autoptimize_filter_html_exclude', '');
40
+        if ('' !== $exclude) {
41
+            $exclude_arr   = array_filter(array_map('trim', explode(',', $exclude)));
42
+            $this->exclude = array_merge($exclude_arr, $this->exclude);
43 43
         }
44 44
 
45 45
         // Nothing else for HTML!
@@ -53,49 +53,49 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function minify()
55 55
     {
56
-        $noptimize = apply_filters( 'autoptimize_filter_html_noptimize', false, $this->content );
57
-        if ( $noptimize ) {
56
+        $noptimize = apply_filters('autoptimize_filter_html_noptimize', false, $this->content);
57
+        if ($noptimize) {
58 58
             return false;
59 59
         }
60 60
 
61 61
         // Wrap the to-be-excluded strings in noptimize tags.
62
-        foreach ( $this->exclude as $str ) {
63
-            if ( false !== strpos( $this->content, $str ) ) {
64
-                $replacement   = '<!--noptimize-->' . $str . '<!--/noptimize-->';
65
-                $this->content = str_replace( $str, $replacement, $this->content );
62
+        foreach ($this->exclude as $str) {
63
+            if (false !== strpos($this->content, $str)) {
64
+                $replacement   = '<!--noptimize-->'.$str.'<!--/noptimize-->';
65
+                $this->content = str_replace($str, $replacement, $this->content);
66 66
             }
67 67
         }
68 68
 
69 69
         // Noptimize.
70
-        $this->content = $this->hide_noptimize( $this->content );
70
+        $this->content = $this->hide_noptimize($this->content);
71 71
 
72 72
         // Preparing options for Minify_HTML.
73
-        $options = array( 'keepComments' => $this->keepcomments );
74
-        if ( $this->forcexhtml ) {
73
+        $options = array('keepComments' => $this->keepcomments);
74
+        if ($this->forcexhtml) {
75 75
             $options['xhtml'] = true;
76 76
         }
77 77
 
78
-        $tmp_content = Minify_HTML::minify( $this->content, $options );
79
-        if ( ! empty( $tmp_content ) ) {
78
+        $tmp_content = Minify_HTML::minify($this->content, $options);
79
+        if (!empty($tmp_content)) {
80 80
             $this->content = $tmp_content;
81
-            unset( $tmp_content );
81
+            unset($tmp_content);
82 82
         }
83 83
 
84 84
         // Restore noptimize.
85
-        $this->content = $this->restore_noptimize( $this->content );
85
+        $this->content = $this->restore_noptimize($this->content);
86 86
 
87 87
         // Remove the noptimize-wrapper from around the excluded strings.
88
-        foreach ( $this->exclude as $str ) {
89
-            $replacement = '<!--noptimize-->' . $str . '<!--/noptimize-->';
90
-            if ( false !== strpos( $this->content, $replacement ) ) {
91
-                $this->content = str_replace( $replacement, $str, $this->content );
88
+        foreach ($this->exclude as $str) {
89
+            $replacement = '<!--noptimize-->'.$str.'<!--/noptimize-->';
90
+            if (false !== strpos($this->content, $replacement)) {
91
+                $this->content = str_replace($replacement, $str, $this->content);
92 92
             }
93 93
         }
94 94
 
95 95
         // Revslider data attribs somehow suffer from HTML optimization, this fixes that!
96
-        if ( class_exists( 'RevSlider' ) && apply_filters( 'autoptimize_filter_html_dataattrib_cleanup', false ) ) {
97
-            $this->content = preg_replace( '#\n(data-.*$)\n#Um', ' $1 ', $this->content );
98
-            $this->content = preg_replace( '#<[^>]*(=\"[^"\'<>\s]*\")(\w)#', '$1 $2', $this->content );
96
+        if (class_exists('RevSlider') && apply_filters('autoptimize_filter_html_dataattrib_cleanup', false)) {
97
+            $this->content = preg_replace('#\n(data-.*$)\n#Um', ' $1 ', $this->content);
98
+            $this->content = preg_replace('#<[^>]*(=\"[^"\'<>\s]*\")(\w)#', '$1 $2', $this->content);
99 99
         }
100 100
 
101 101
         return true;
Please login to merge, or discard this patch.
classes/autoptimizeCLI.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
  * WP-CLI commands for Autoptimize.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
10 10
 // This is a WP-CLI command, so bail if it's not available.
11
-if ( ! defined( 'WP_CLI' ) ) {
11
+if (!defined('WP_CLI')) {
12 12
     return;
13 13
 }
14 14
 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @return void
26 26
      */
27
-    public function clear( $args, $args_assoc ) {
28
-        WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) );
27
+    public function clear($args, $args_assoc) {
28
+        WP_CLI::line(esc_html__('Flushing the cache...', 'autoptimize'));
29 29
         autoptimizeCache::clearall();
30
-        WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) );
30
+        WP_CLI::success(esc_html__('Cache flushed.', 'autoptimize'));
31 31
     }
32 32
 }
33 33
 
34
-WP_CLI::add_command( 'autoptimize', 'autoptimizeCLI' );
34
+WP_CLI::add_command('autoptimize', 'autoptimizeCLI');
Please login to merge, or discard this patch.
classes/autoptimizeCache.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Handles disk-cache-related operations.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
      * @param string $md5 Hash.
39 39
      * @param string $ext Extension.
40 40
      */
41
-    public function __construct( $md5, $ext = 'php' )
41
+    public function __construct($md5, $ext = 'php')
42 42
     {
43 43
         $this->cachedir = AUTOPTIMIZE_CACHE_DIR;
44 44
         $this->nogzip   = AUTOPTIMIZE_CACHE_NOGZIP;
45
-        if ( ! $this->nogzip ) {
46
-            $this->filename = AUTOPTIMIZE_CACHEFILE_PREFIX . $md5 . '.php';
45
+        if (!$this->nogzip) {
46
+            $this->filename = AUTOPTIMIZE_CACHEFILE_PREFIX.$md5.'.php';
47 47
         } else {
48
-            if ( in_array( $ext, array( 'js', 'css' ) ) ) {
49
-                $this->filename = $ext . '/' . AUTOPTIMIZE_CACHEFILE_PREFIX . $md5 . '.' . $ext;
48
+            if (in_array($ext, array('js', 'css'))) {
49
+                $this->filename = $ext.'/'.AUTOPTIMIZE_CACHEFILE_PREFIX.$md5.'.'.$ext;
50 50
             } else {
51
-                $this->filename = AUTOPTIMIZE_CACHEFILE_PREFIX . $md5 . '.' . $ext;
51
+                $this->filename = AUTOPTIMIZE_CACHEFILE_PREFIX.$md5.'.'.$ext;
52 52
             }
53 53
         }
54 54
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function check()
62 62
     {
63
-        return file_exists( $this->cachedir . $this->filename );
63
+        return file_exists($this->cachedir.$this->filename);
64 64
     }
65 65
 
66 66
     /**
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function retrieve()
72 72
     {
73
-        if ( $this->check() ) {
74
-            if ( false == $this->nogzip ) {
75
-                return file_get_contents( $this->cachedir . $this->filename . '.none' );
73
+        if ($this->check()) {
74
+            if (false == $this->nogzip) {
75
+                return file_get_contents($this->cachedir.$this->filename.'.none');
76 76
             } else {
77
-                return file_get_contents( $this->cachedir . $this->filename );
77
+                return file_get_contents($this->cachedir.$this->filename);
78 78
             }
79 79
         }
80 80
         return false;
@@ -88,22 +88,22 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return void
90 90
      */
91
-    public function cache( $data, $mime )
91
+    public function cache($data, $mime)
92 92
     {
93
-        if ( false === $this->nogzip ) {
93
+        if (false === $this->nogzip) {
94 94
             // We handle gzipping ourselves.
95 95
             $file    = 'default.php';
96
-            $phpcode = file_get_contents( AUTOPTIMIZE_PLUGIN_DIR . 'config/' . $file );
97
-            $phpcode = str_replace( array( '%%CONTENT%%', 'exit;' ), array( $mime, '' ), $phpcode );
96
+            $phpcode = file_get_contents(AUTOPTIMIZE_PLUGIN_DIR.'config/'.$file);
97
+            $phpcode = str_replace(array('%%CONTENT%%', 'exit;'), array($mime, ''), $phpcode);
98 98
 
99
-            file_put_contents( $this->cachedir . $this->filename, $phpcode );
100
-            file_put_contents( $this->cachedir . $this->filename . '.none', $data );
99
+            file_put_contents($this->cachedir.$this->filename, $phpcode);
100
+            file_put_contents($this->cachedir.$this->filename.'.none', $data);
101 101
         } else {
102 102
             // Write code to cache without doing anything else.
103
-            file_put_contents( $this->cachedir . $this->filename, $data );
104
-            if ( apply_filters( 'autoptimize_filter_cache_create_static_gzip', false ) ) {
103
+            file_put_contents($this->cachedir.$this->filename, $data);
104
+            if (apply_filters('autoptimize_filter_cache_create_static_gzip', false)) {
105 105
                 // Create an additional cached gzip file.
106
-                file_put_contents( $this->cachedir . $this->filename . '.gz', gzencode( $data, 9, FORCE_GZIP ) );
106
+                file_put_contents($this->cachedir.$this->filename.'.gz', gzencode($data, 9, FORCE_GZIP));
107 107
             }
108 108
         }
109 109
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         // The original idea here was to provide 3rd party code a hook so that
121 121
         // it can "listen" to all the complete autoptimized-urls that the page
122 122
         // will emit... Or something to that effect I think?
123
-        apply_filters( 'autoptimize_filter_cache_getname', AUTOPTIMIZE_CACHE_URL . $this->filename );
123
+        apply_filters('autoptimize_filter_cache_getname', AUTOPTIMIZE_CACHE_URL.$this->filename);
124 124
 
125 125
         return $this->filename;
126 126
     }
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
      * @param string $file Filename.
134 134
      * @return bool
135 135
      */
136
-    protected static function is_valid_cache_file( $dir, $file )
136
+    protected static function is_valid_cache_file($dir, $file)
137 137
     {
138
-        if ( '.' !== $file && '..' !== $file &&
139
-            false !== strpos( $file, AUTOPTIMIZE_CACHEFILE_PREFIX ) &&
140
-            is_file( $dir . $file ) ) {
138
+        if ('.' !== $file && '..' !== $file &&
139
+            false !== strpos($file, AUTOPTIMIZE_CACHEFILE_PREFIX) &&
140
+            is_file($dir.$file)) {
141 141
 
142 142
             // It's a valid file!
143 143
             return true;
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
     protected static function clear_cache_classic()
156 156
     {
157 157
         $contents = self::get_cache_contents();
158
-        foreach ( $contents as $name => $files ) {
159
-            $dir = rtrim( AUTOPTIMIZE_CACHE_DIR . $name, '/' ) . '/';
160
-            foreach ( $files as $file ) {
161
-                if ( self::is_valid_cache_file( $dir, $file ) ) {
162
-                    @unlink( $dir . $file ); // @codingStandardsIgnoreLine
158
+        foreach ($contents as $name => $files) {
159
+            $dir = rtrim(AUTOPTIMIZE_CACHE_DIR.$name, '/').'/';
160
+            foreach ($files as $file) {
161
+                if (self::is_valid_cache_file($dir, $file)) {
162
+                    @unlink($dir.$file); // @codingStandardsIgnoreLine
163 163
                 }
164 164
             }
165 165
         }
166 166
 
167
-        @unlink( AUTOPTIMIZE_CACHE_DIR . '/.htaccess' ); // @codingStandardsIgnoreLine
167
+        @unlink(AUTOPTIMIZE_CACHE_DIR.'/.htaccess'); // @codingStandardsIgnoreLine
168 168
     }
169 169
 
170 170
     /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
      *
176 176
      * @return bool
177 177
      */
178
-    protected static function rmdir( $pathname )
178
+    protected static function rmdir($pathname)
179 179
     {
180
-        $files = self::get_dir_contents( $pathname );
181
-        foreach ( $files as $file ) {
182
-            $path = $pathname . '/' . $file;
183
-            if ( is_dir( $path ) ) {
184
-                self::rmdir( $path );
180
+        $files = self::get_dir_contents($pathname);
181
+        foreach ($files as $file) {
182
+            $path = $pathname.'/'.$file;
183
+            if (is_dir($path)) {
184
+                self::rmdir($path);
185 185
             } else {
186
-                unlink( $path );
186
+                unlink($path);
187 187
             }
188 188
         }
189 189
 
190
-        return rmdir( $pathname );
190
+        return rmdir($pathname);
191 191
     }
192 192
 
193 193
     /**
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
         $new_name = self::get_unique_name();
205 205
 
206 206
         // Makes sure the new pathname is on the same level...
207
-        $new_pathname = dirname( $dir ) . '/' . $new_name;
208
-        $renamed      = @rename( $dir, $new_pathname ); // @codingStandardsIgnoreLine
207
+        $new_pathname = dirname($dir).'/'.$new_name;
208
+        $renamed      = @rename($dir, $new_pathname); // @codingStandardsIgnoreLine
209 209
 
210 210
         // When renamed, re-create the default cache directory back so it's
211 211
         // available again...
212
-        if ( $renamed ) {
212
+        if ($renamed) {
213 213
             $ok = self::cacheavail();
214 214
         }
215 215
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public static function advanced_cache_clear_enabled()
225 225
     {
226
-        return apply_filters( 'autoptimize_filter_cache_clear_advanced', false );
226
+        return apply_filters('autoptimize_filter_cache_clear_advanced', false);
227 227
     }
228 228
 
229 229
     /**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     protected static function get_unique_name()
235 235
     {
236 236
         $prefix   = self::get_advanced_cache_clear_prefix();
237
-        $new_name = uniqid( $prefix, true );
237
+        $new_name = uniqid($prefix, true);
238 238
 
239 239
         return $new_name;
240 240
     }
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
     protected static function get_advanced_cache_clear_prefix()
248 248
     {
249 249
         $pathname = self::get_pathname_base();
250
-        $basename = basename( $pathname );
251
-        $prefix   = $basename . '-';
250
+        $basename = basename($pathname);
251
+        $prefix   = $basename.'-';
252 252
 
253 253
         return $prefix;
254 254
     }
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
      *
262 262
      * @return array
263 263
      */
264
-    protected static function get_dir_contents( $pathname )
264
+    protected static function get_dir_contents($pathname)
265 265
     {
266
-        return array_slice( scandir( $pathname ), 2 );
266
+        return array_slice(scandir($pathname), 2);
267 267
     }
268 268
 
269 269
     /**
@@ -277,17 +277,17 @@  discard block
 block discarded – undo
277 277
     {
278 278
         $dir    = self::get_pathname_base();
279 279
         $prefix = self::get_advanced_cache_clear_prefix();
280
-        $parent = dirname( $dir );
280
+        $parent = dirname($dir);
281 281
         $ok     = false;
282 282
 
283 283
         // Returns the list of files without '.' and '..' elements.
284
-        $files = self::get_dir_contents( $parent );
285
-        foreach ( $files as $file ) {
286
-            $path     = $parent . '/' . $file;
287
-            $prefixed = ( false !== strpos( $path, $prefix ) );
284
+        $files = self::get_dir_contents($parent);
285
+        foreach ($files as $file) {
286
+            $path     = $parent.'/'.$file;
287
+            $prefixed = (false !== strpos($path, $prefix));
288 288
             // Removing only our own (prefixed) directories...
289
-            if ( is_dir( $path ) && $prefixed ) {
290
-                $ok = self::rmdir( $path );
289
+            if (is_dir($path) && $prefixed) {
290
+                $ok = self::rmdir($path);
291 291
             }
292 292
         }
293 293
 
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
     {
307 307
         $pathname = self::get_pathname_base();
308 308
 
309
-        if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches', true ) ) {
309
+        if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) {
310 310
             $blog_id   = get_current_blog_id();
311
-            $pathname .= $blog_id . '/';
311
+            $pathname .= $blog_id.'/';
312 312
         }
313 313
 
314 314
         return $pathname;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     protected static function get_pathname_base()
323 323
     {
324
-        $pathname = WP_CONTENT_DIR . AUTOPTIMIZE_CACHE_CHILD_DIR;
324
+        $pathname = WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR;
325 325
 
326 326
         return $pathname;
327 327
     }
@@ -333,38 +333,38 @@  discard block
 block discarded – undo
333 333
      *
334 334
      * @return bool
335 335
      */
336
-    public static function clearall( $propagate = true )
336
+    public static function clearall($propagate = true)
337 337
     {
338
-        if ( ! self::cacheavail() ) {
338
+        if (!self::cacheavail()) {
339 339
             return false;
340 340
         }
341 341
 
342 342
         // TODO/FIXME: If cache is big, switch to advanced/new cache clearing automatically?
343
-        if ( self::advanced_cache_clear_enabled() ) {
343
+        if (self::advanced_cache_clear_enabled()) {
344 344
             self::clear_cache_via_rename();
345 345
         } else {
346 346
             self::clear_cache_classic();
347 347
         }
348 348
 
349 349
         // Remove the transient so it gets regenerated...
350
-        delete_transient( 'autoptimize_stats' );
350
+        delete_transient('autoptimize_stats');
351 351
 
352 352
         // Cache was just purged, clear page cache and allow others to hook into our purging...
353
-        if ( true === $propagate ) {
354
-            if ( ! function_exists( 'autoptimize_do_cachepurged_action' ) ) {
353
+        if (true === $propagate) {
354
+            if (!function_exists('autoptimize_do_cachepurged_action')) {
355 355
                 function autoptimize_do_cachepurged_action() {
356
-                    do_action( 'autoptimize_action_cachepurged' );
356
+                    do_action('autoptimize_action_cachepurged');
357 357
                 }
358 358
             }
359
-            add_action( 'shutdown', 'autoptimize_do_cachepurged_action', 11 );
360
-            add_action( 'autoptimize_action_cachepurged', array( 'autoptimizeCache', 'flushPageCache' ), 10, 0 );
359
+            add_action('shutdown', 'autoptimize_do_cachepurged_action', 11);
360
+            add_action('autoptimize_action_cachepurged', array('autoptimizeCache', 'flushPageCache'), 10, 0);
361 361
         }
362 362
 
363 363
         // Warm cache (part of speedupper)!
364
-        if ( apply_filters( 'autoptimize_filter_speedupper', true ) ) {
365
-            $url   = site_url() . '/?ao_speedup_cachebuster=' . rand( 1, 100000 );
366
-            $cache = @wp_remote_get( $url ); // @codingStandardsIgnoreLine
367
-            unset( $cache );
364
+        if (apply_filters('autoptimize_filter_speedupper', true)) {
365
+            $url   = site_url().'/?ao_speedup_cachebuster='.rand(1, 100000);
366
+            $cache = @wp_remote_get($url); // @codingStandardsIgnoreLine
367
+            unset($cache);
368 368
         }
369 369
 
370 370
         return true;
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public static function clearall_actionless()
381 381
     {
382
-        return self::clearall( false );
382
+        return self::clearall(false);
383 383
     }
384 384
 
385 385
     /**
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
     {
392 392
         $contents = array();
393 393
 
394
-        foreach ( array( '', 'js', 'css' ) as $dir ) {
395
-            $contents[ $dir ] = scandir( AUTOPTIMIZE_CACHE_DIR . $dir );
394
+        foreach (array('', 'js', 'css') as $dir) {
395
+            $contents[$dir] = scandir(AUTOPTIMIZE_CACHE_DIR.$dir);
396 396
         }
397 397
 
398 398
         return $contents;
@@ -405,21 +405,21 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public static function stats()
407 407
     {
408
-        $stats = get_transient( 'autoptimize_stats' );
408
+        $stats = get_transient('autoptimize_stats');
409 409
 
410 410
         // If no transient, do the actual scan!
411
-        if ( ! is_array( $stats ) ) {
412
-            if ( ! self::cacheavail() ) {
411
+        if (!is_array($stats)) {
412
+            if (!self::cacheavail()) {
413 413
                 return 0;
414 414
             }
415 415
             $stats = self::stats_scan();
416 416
             $count = $stats[0];
417
-            if ( $count > 100 ) {
417
+            if ($count > 100) {
418 418
                 // Store results in transient.
419 419
                 set_transient(
420 420
                     'autoptimize_stats',
421 421
                     $stats,
422
-                    apply_filters( 'autoptimize_filter_cache_statsexpiry', HOUR_IN_SECONDS )
422
+                    apply_filters('autoptimize_filter_cache_statsexpiry', HOUR_IN_SECONDS)
423 423
                 );
424 424
             }
425 425
         }
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
         $size  = 0;
443 443
 
444 444
         // Scan everything in our cache directories.
445
-        foreach ( self::get_cache_contents() as $name => $files ) {
446
-            $dir = rtrim( AUTOPTIMIZE_CACHE_DIR . $name, '/' ) . '/';
447
-            foreach ( $files as $file ) {
448
-                if ( self::is_valid_cache_file( $dir, $file ) ) {
449
-                    if ( AUTOPTIMIZE_CACHE_NOGZIP &&
445
+        foreach (self::get_cache_contents() as $name => $files) {
446
+            $dir = rtrim(AUTOPTIMIZE_CACHE_DIR.$name, '/').'/';
447
+            foreach ($files as $file) {
448
+                if (self::is_valid_cache_file($dir, $file)) {
449
+                    if (AUTOPTIMIZE_CACHE_NOGZIP &&
450 450
                         (
451
-                            false !== strpos( $file, '.js' ) ||
452
-                            false !== strpos( $file, '.css' ) ||
453
-                            false !== strpos( $file, '.img' ) ||
454
-                            false !== strpos( $file, '.txt' )
451
+                            false !== strpos($file, '.js') ||
452
+                            false !== strpos($file, '.css') ||
453
+                            false !== strpos($file, '.img') ||
454
+                            false !== strpos($file, '.txt')
455 455
                         )
456 456
                     ) {
457 457
                         // Web server is gzipping, we count .js|.css|.img|.txt files.
458 458
                         $count++;
459
-                    } elseif ( ! AUTOPTIMIZE_CACHE_NOGZIP && false !== strpos( $file, '.none' ) ) {
459
+                    } elseif (!AUTOPTIMIZE_CACHE_NOGZIP && false !== strpos($file, '.none')) {
460 460
                         // We are gzipping ourselves via php, counting only .none files.
461 461
                         $count++;
462 462
                     }
463
-                    $size += filesize( $dir . $file );
463
+                    $size += filesize($dir.$file);
464 464
                 }
465 465
             }
466 466
         }
467 467
 
468
-        $stats = array( $count, $size, time() );
468
+        $stats = array($count, $size, time());
469 469
 
470 470
         return $stats;
471 471
     }
@@ -479,29 +479,29 @@  discard block
 block discarded – undo
479 479
      */
480 480
     public static function cacheavail()
481 481
     {
482
-        if ( ! defined( 'AUTOPTIMIZE_CACHE_DIR' ) ) {
482
+        if (!defined('AUTOPTIMIZE_CACHE_DIR')) {
483 483
             // We didn't set a cache.
484 484
             return false;
485 485
         }
486 486
 
487
-        foreach ( array( '', 'js', 'css' ) as $dir ) {
488
-            if ( ! self::check_cache_dir( AUTOPTIMIZE_CACHE_DIR . $dir ) ) {
487
+        foreach (array('', 'js', 'css') as $dir) {
488
+            if (!self::check_cache_dir(AUTOPTIMIZE_CACHE_DIR.$dir)) {
489 489
                 return false;
490 490
             }
491 491
         }
492 492
 
493 493
         // Using .htaccess inside our cache folder to overrule wp-super-cache.
494
-        $htaccess = AUTOPTIMIZE_CACHE_DIR . '/.htaccess';
495
-        if ( ! is_file( $htaccess ) ) {
494
+        $htaccess = AUTOPTIMIZE_CACHE_DIR.'/.htaccess';
495
+        if (!is_file($htaccess)) {
496 496
             /**
497 497
              * Create `wp-content/AO_htaccess_tmpl` file with
498 498
              * whatever htaccess rules you might need
499 499
              * if you want to override default AO htaccess
500 500
              */
501
-            $htaccess_tmpl = WP_CONTENT_DIR . '/AO_htaccess_tmpl';
502
-            if ( is_file( $htaccess_tmpl ) ) {
503
-                $content = file_get_contents( $htaccess_tmpl );
504
-            } elseif ( is_multisite() || ! AUTOPTIMIZE_CACHE_NOGZIP ) {
501
+            $htaccess_tmpl = WP_CONTENT_DIR.'/AO_htaccess_tmpl';
502
+            if (is_file($htaccess_tmpl)) {
503
+                $content = file_get_contents($htaccess_tmpl);
504
+            } elseif (is_multisite() || !AUTOPTIMIZE_CACHE_NOGZIP) {
505 505
                 $content = '<IfModule mod_expires.c>
506 506
         ExpiresActive On
507 507
         ExpiresByType text/css A30672000
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
     </Files>
555 555
 </IfModule>';
556 556
             }
557
-            @file_put_contents( $htaccess, $content ); // @codingStandardsIgnoreLine
557
+            @file_put_contents($htaccess, $content); // @codingStandardsIgnoreLine
558 558
         }
559 559
 
560 560
         // All OK!
@@ -569,25 +569,25 @@  discard block
 block discarded – undo
569 569
      *
570 570
      * @return bool
571 571
      */
572
-    protected static function check_cache_dir( $dir )
572
+    protected static function check_cache_dir($dir)
573 573
     {
574 574
         // Try creating the dir if it doesn't exist.
575
-        if ( ! file_exists( $dir ) ) {
576
-            @mkdir( $dir, 0775, true ); // @codingStandardsIgnoreLine
577
-            if ( ! file_exists( $dir ) ) {
575
+        if (!file_exists($dir)) {
576
+            @mkdir($dir, 0775, true); // @codingStandardsIgnoreLine
577
+            if (!file_exists($dir)) {
578 578
                 return false;
579 579
             }
580 580
         }
581 581
 
582 582
         // If we still cannot write, bail.
583
-        if ( ! is_writable( $dir ) ) {
583
+        if (!is_writable($dir)) {
584 584
             return false;
585 585
         }
586 586
 
587 587
         // Create an index.html in there to avoid prying eyes!
588
-        $idx_file = rtrim( $dir, '/\\' ) . '/index.html';
589
-        if ( ! is_file( $idx_file ) ) {
590
-            @file_put_contents( $idx_file, '<html><head><meta name="robots" content="noindex, nofollow"></head><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/" rel="nofollow">Autoptimize</a></body></html>' ); // @codingStandardsIgnoreLine
588
+        $idx_file = rtrim($dir, '/\\').'/index.html';
589
+        if (!is_file($idx_file)) {
590
+            @file_put_contents($idx_file, '<html><head><meta name="robots" content="noindex, nofollow"></head><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/" rel="nofollow">Autoptimize</a></body></html>'); // @codingStandardsIgnoreLine
591 591
         }
592 592
 
593 593
         return true;
@@ -601,59 +601,59 @@  discard block
 block discarded – undo
601 601
     // @codingStandardsIgnoreStart
602 602
     public static function flushPageCache()
603 603
     {
604
-        if ( function_exists( 'wp_cache_clear_cache' ) ) {
605
-            if ( is_multisite() ) {
604
+        if (function_exists('wp_cache_clear_cache')) {
605
+            if (is_multisite()) {
606 606
                 $blog_id = get_current_blog_id();
607
-                wp_cache_clear_cache( $blog_id );
607
+                wp_cache_clear_cache($blog_id);
608 608
             } else {
609 609
                 wp_cache_clear_cache();
610 610
             }
611
-        } elseif ( has_action( 'cachify_flush_cache' ) ) {
612
-            do_action( 'cachify_flush_cache' );
613
-        } elseif ( function_exists( 'w3tc_pgcache_flush' ) ) {
611
+        } elseif (has_action('cachify_flush_cache')) {
612
+            do_action('cachify_flush_cache');
613
+        } elseif (function_exists('w3tc_pgcache_flush')) {
614 614
             w3tc_pgcache_flush();
615
-        } elseif ( function_exists( 'wp_fast_cache_bulk_delete_all' ) ) {
615
+        } elseif (function_exists('wp_fast_cache_bulk_delete_all')) {
616 616
             wp_fast_cache_bulk_delete_all();
617
-        } elseif ( class_exists( 'WpFastestCache' ) ) {
617
+        } elseif (class_exists('WpFastestCache')) {
618 618
             $wpfc = new WpFastestCache();
619 619
             $wpfc->deleteCache();
620
-        } elseif ( class_exists( 'c_ws_plugin__qcache_purging_routines' ) ) {
620
+        } elseif (class_exists('c_ws_plugin__qcache_purging_routines')) {
621 621
             c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache
622
-        } elseif ( class_exists( 'zencache' ) ) {
622
+        } elseif (class_exists('zencache')) {
623 623
             zencache::clear();
624
-        } elseif ( class_exists( 'comet_cache' ) ) {
624
+        } elseif (class_exists('comet_cache')) {
625 625
             comet_cache::clear();
626
-        } elseif ( class_exists( 'WpeCommon' ) ) {
626
+        } elseif (class_exists('WpeCommon')) {
627 627
             // WPEngine cache purge/flush methods to call by default
628 628
             $wpe_methods = array(
629 629
                 'purge_varnish_cache',
630 630
             );
631 631
 
632 632
             // More agressive clear/flush/purge behind a filter
633
-            if ( apply_filters( 'autoptimize_flush_wpengine_aggressive', false ) ) {
634
-                $wpe_methods = array_merge( $wpe_methods, array( 'purge_memcached', 'clear_maxcdn_cache' ) );
633
+            if (apply_filters('autoptimize_flush_wpengine_aggressive', false)) {
634
+                $wpe_methods = array_merge($wpe_methods, array('purge_memcached', 'clear_maxcdn_cache'));
635 635
             }
636 636
 
637 637
             // Filtering the entire list of WpeCommon methods to be called (for advanced usage + easier testing)
638
-            $wpe_methods = apply_filters( 'autoptimize_flush_wpengine_methods', $wpe_methods );
638
+            $wpe_methods = apply_filters('autoptimize_flush_wpengine_methods', $wpe_methods);
639 639
 
640
-            foreach ( $wpe_methods as $wpe_method ) {
641
-                if ( method_exists( 'WpeCommon', $wpe_method ) ) {
640
+            foreach ($wpe_methods as $wpe_method) {
641
+                if (method_exists('WpeCommon', $wpe_method)) {
642 642
                     WpeCommon::$wpe_method();
643 643
                 }
644 644
             }
645
-        } elseif ( function_exists( 'sg_cachepress_purge_cache' ) ) {
645
+        } elseif (function_exists('sg_cachepress_purge_cache')) {
646 646
             sg_cachepress_purge_cache();
647
-        } elseif ( file_exists( WP_CONTENT_DIR . '/wp-cache-config.php' ) && function_exists( 'prune_super_cache' ) ) {
647
+        } elseif (file_exists(WP_CONTENT_DIR.'/wp-cache-config.php') && function_exists('prune_super_cache')) {
648 648
             // fallback for WP-Super-Cache
649 649
             global $cache_path;
650
-            if ( is_multisite() ) {
650
+            if (is_multisite()) {
651 651
                 $blog_id = get_current_blog_id();
652
-                prune_super_cache( get_supercache_dir( $blog_id ), true );
653
-                prune_super_cache( $cache_path . 'blogs/', true );
652
+                prune_super_cache(get_supercache_dir($blog_id), true);
653
+                prune_super_cache($cache_path.'blogs/', true);
654 654
             } else {
655
-                prune_super_cache( $cache_path . 'supercache/', true );
656
-                prune_super_cache( $cache_path, true );
655
+                prune_super_cache($cache_path.'supercache/', true);
656
+                prune_super_cache($cache_path, true);
657 657
             }
658 658
         }
659 659
     }
Please login to merge, or discard this patch.