Completed
Push — master ( 198cf5...10cd03 )
by frank
01:51
created
tests/bootstrap.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,50 +3,50 @@  discard block
 block discarded – undo
3 3
  * WP tests bootstrap.
4 4
  */
5 5
 
6
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
7
-if ( ! $_tests_dir ) {
8
-    $tmp_dir = getenv( 'TMPDIR' );
9
-    if ( ! empty( $tmp_dir ) ) {
10
-        $_tests_dir = rtrim( $tmp_dir, '/' ) . '/wordpress-tests-lib';
11
-        if ( ! is_dir( $_tests_dir ) ) {
6
+$_tests_dir = getenv('WP_TESTS_DIR');
7
+if (!$_tests_dir) {
8
+    $tmp_dir = getenv('TMPDIR');
9
+    if (!empty($tmp_dir)) {
10
+        $_tests_dir = rtrim($tmp_dir, '/').'/wordpress-tests-lib';
11
+        if (!is_dir($_tests_dir)) {
12 12
             $_tests_dir = null;
13 13
         }
14 14
     }
15 15
 }
16 16
 
17
-if ( ! $_tests_dir ) {
17
+if (!$_tests_dir) {
18 18
     $_tests_dir = '/tmp/wordpress-tests-lib';
19 19
 }
20 20
 
21
-require_once $_tests_dir . '/includes/functions.php';
21
+require_once $_tests_dir.'/includes/functions.php';
22 22
 
23 23
 function _manually_load_plugin() {
24
-    define( 'AUTOPTIMIZE_INIT_EARLIER', true );
24
+    define('AUTOPTIMIZE_INIT_EARLIER', true);
25 25
 
26 26
     // For overriding cache dirs and whatnot. Kinda works if you keep a few things in mind.
27
-    if ( getenv('CUSTOM_CONSTANTS' ) ) {
28
-        define( 'AUTOPTIMIZE_CACHE_CHILD_DIR', '/c/ao/' );
29
-        $pathname = WP_CONTENT_DIR . AUTOPTIMIZE_CACHE_CHILD_DIR;
30
-        if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches', true ) ) {
27
+    if (getenv('CUSTOM_CONSTANTS')) {
28
+        define('AUTOPTIMIZE_CACHE_CHILD_DIR', '/c/ao/');
29
+        $pathname = WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR;
30
+        if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) {
31 31
             $blog_id   = get_current_blog_id();
32
-            $pathname .= $blog_id . '/';
32
+            $pathname .= $blog_id.'/';
33 33
         }
34
-        define( 'AUTOPTIMIZE_CACHE_DIR', $pathname );
34
+        define('AUTOPTIMIZE_CACHE_DIR', $pathname);
35 35
 
36 36
         $custom_site_url = 'http://localhost/wordpress';
37
-        define( 'AUTOPTIMIZE_WP_SITE_URL', $custom_site_url );
38
-        add_filter( 'site_url', function( $url, $path, $scheme, $blog_id ) use ( $custom_site_url ) {
37
+        define('AUTOPTIMIZE_WP_SITE_URL', $custom_site_url);
38
+        add_filter('site_url', function($url, $path, $scheme, $blog_id) use ($custom_site_url) {
39 39
             return $custom_site_url;
40
-        }, 10, 4 );
41
-        add_filter( 'content_url', function( $url, $path ) use ( $custom_site_url ) {
42
-            return $custom_site_url . '/wp-content';
43
-        }, 10, 2 );
44
-        define( 'AO_TEST_SUBFOLDER_INSTALL', true );
40
+        }, 10, 4);
41
+        add_filter('content_url', function($url, $path) use ($custom_site_url) {
42
+            return $custom_site_url.'/wp-content';
43
+        }, 10, 2);
44
+        define('AO_TEST_SUBFOLDER_INSTALL', true);
45 45
 
46
-        define( 'CUSTOM_CONSTANTS_USED', true );
46
+        define('CUSTOM_CONSTANTS_USED', true);
47 47
     } else {
48
-        define( 'CUSTOM_CONSTANTS_USED', false );
49
-        define( 'AO_TEST_SUBFOLDER_INSTALL', false );
48
+        define('CUSTOM_CONSTANTS_USED', false);
49
+        define('AO_TEST_SUBFOLDER_INSTALL', false);
50 50
     }
51 51
 
52 52
     /*
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
     update_option( 'active_plugins', $active_plugins );
55 55
     */
56 56
 
57
-    update_option( 'autoptimize_js', 1 );
58
-    update_option( 'autoptimize_css', 1 );
59
-    update_option( 'autoptimize_html', 0 );
60
-    update_option( 'autoptimize_cdn_url', 'http://cdn.example.org' );
61
-    update_option( 'autoptimize_cache_nogzip', 1 );
57
+    update_option('autoptimize_js', 1);
58
+    update_option('autoptimize_css', 1);
59
+    update_option('autoptimize_html', 0);
60
+    update_option('autoptimize_cdn_url', 'http://cdn.example.org');
61
+    update_option('autoptimize_cache_nogzip', 1);
62 62
 
63
-    add_filter( 'autoptimize_css_include_inline', function( $include_inline ) {
63
+    add_filter('autoptimize_css_include_inline', function($include_inline) {
64 64
         return true;
65 65
     });
66 66
 
67
-    require dirname( dirname( __FILE__ ) ) . '/autoptimize.php';
67
+    require dirname(dirname(__FILE__)).'/autoptimize.php';
68 68
 }
69
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
69
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
70 70
 
71
-require $_tests_dir . '/includes/bootstrap.php';
71
+require $_tests_dir.'/includes/bootstrap.php';
Please login to merge, or discard this patch.
php/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php 2 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -29,131 +29,131 @@
 block discarded – undo
29 29
  * Exit if called directly.
30 30
  */
31 31
 if ( ! defined( 'ABSPATH' ) ) {
32
-	die;
32
+    die;
33 33
 }
34 34
 
35 35
 if ( ! class_exists( 'PAnD' ) ) {
36 36
 
37
-	/**
38
-	 * Class PAnD
39
-	 */
40
-	class PAnD {
41
-
42
-		/**
43
-		 * Init hooks.
44
-		 */
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' ) );
48
-		}
49
-
50
-		/**
51
-		 * Enqueue javascript and variables.
52
-		 */
53
-		public static function load_script() {
54
-
55
-			if ( is_customize_preview() ) {
56
-				return;
57
-			}
58
-
59
-			wp_enqueue_script(
60
-				'dismissible-notices',
61
-				plugins_url( 'dismiss-notice.js', __FILE__ ),
62
-				array( 'jquery', 'common' ),
63
-				false,
64
-				true
65
-			);
66
-
67
-			wp_localize_script(
68
-				'dismissible-notices',
69
-				'dismissible_notice',
70
-				array(
71
-					'nonce' => wp_create_nonce( 'dismissible-notice' ),
72
-				)
73
-			);
74
-		}
75
-
76
-		/**
77
-		 * Handles Ajax request to persist notices dismissal.
78
-		 * Uses check_ajax_referer to verify nonce.
79
-		 */
80
-		public static function dismiss_admin_notice() {
81
-			$option_name        = sanitize_text_field( $_POST['option_name'] );
82
-			$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
83
-
84
-			if ( 'forever' != $dismissible_length ) {
85
-				// If $dismissible_length is not an integer default to 1
86
-				$dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
87
-				$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
88
-			}
89
-
90
-			check_ajax_referer( 'dismissible-notice', 'nonce' );
91
-			self::set_admin_notice_cache( $option_name, $dismissible_length );
92
-			wp_die();
93
-		}
94
-
95
-		/**
96
-		 * Is admin notice active?
97
-		 *
98
-		 * @param string $arg data-dismissible content of notice.
99
-		 *
100
-		 * @return bool
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   = self::get_admin_notice_cache( $option_name );
107
-			if ( 'forever' == $db_record ) {
108
-				return false;
109
-			} elseif ( absint( $db_record ) >= time() ) {
110
-				return false;
111
-			} else {
112
-				return true;
113
-			}
114
-		}
115
-
116
-		/**
117
-		 * Returns admin notice cached timeout.
118
-		 *
119
-		 * @access public
120
-		 *
121
-		 * @param string|bool $id admin notice name or false.
122
-		 *
123
-		 * @return array|bool The timeout. False if expired.
124
-		 */
125
-		public static function get_admin_notice_cache( $id = false ) {
126
-			if ( ! $id ) {
127
-				return false;
128
-			}
129
-			$cache_key = 'pand-' . md5( $id );
130
-			$timeout   = get_site_option( $cache_key );
131
-			$timeout   = 'forever' === $timeout ? time() + 60 : $timeout;
132
-
133
-			if ( empty( $timeout ) || time() > $timeout ) {
134
-				return false;
135
-			}
136
-
137
-			return $timeout;
138
-		}
139
-
140
-		/**
141
-		 * Sets admin notice timeout in site option.
142
-		 *
143
-		 * @access public
144
-		 *
145
-		 * @param string      $id       Data Identifier.
146
-		 * @param string|bool $timeout  Timeout for admin notice.
147
-		 *
148
-		 * @return bool
149
-		 */
150
-		public static function set_admin_notice_cache( $id, $timeout ) {
151
-			$cache_key = 'pand-' . md5( $id );
152
-			update_site_option( $cache_key, $timeout );
153
-
154
-			return true;
155
-		}
156
-
157
-	}
37
+    /**
38
+     * Class PAnD
39
+     */
40
+    class PAnD {
41
+
42
+        /**
43
+         * Init hooks.
44
+         */
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' ) );
48
+        }
49
+
50
+        /**
51
+         * Enqueue javascript and variables.
52
+         */
53
+        public static function load_script() {
54
+
55
+            if ( is_customize_preview() ) {
56
+                return;
57
+            }
58
+
59
+            wp_enqueue_script(
60
+                'dismissible-notices',
61
+                plugins_url( 'dismiss-notice.js', __FILE__ ),
62
+                array( 'jquery', 'common' ),
63
+                false,
64
+                true
65
+            );
66
+
67
+            wp_localize_script(
68
+                'dismissible-notices',
69
+                'dismissible_notice',
70
+                array(
71
+                    'nonce' => wp_create_nonce( 'dismissible-notice' ),
72
+                )
73
+            );
74
+        }
75
+
76
+        /**
77
+         * Handles Ajax request to persist notices dismissal.
78
+         * Uses check_ajax_referer to verify nonce.
79
+         */
80
+        public static function dismiss_admin_notice() {
81
+            $option_name        = sanitize_text_field( $_POST['option_name'] );
82
+            $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
83
+
84
+            if ( 'forever' != $dismissible_length ) {
85
+                // If $dismissible_length is not an integer default to 1
86
+                $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
87
+                $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
88
+            }
89
+
90
+            check_ajax_referer( 'dismissible-notice', 'nonce' );
91
+            self::set_admin_notice_cache( $option_name, $dismissible_length );
92
+            wp_die();
93
+        }
94
+
95
+        /**
96
+         * Is admin notice active?
97
+         *
98
+         * @param string $arg data-dismissible content of notice.
99
+         *
100
+         * @return bool
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   = self::get_admin_notice_cache( $option_name );
107
+            if ( 'forever' == $db_record ) {
108
+                return false;
109
+            } elseif ( absint( $db_record ) >= time() ) {
110
+                return false;
111
+            } else {
112
+                return true;
113
+            }
114
+        }
115
+
116
+        /**
117
+         * Returns admin notice cached timeout.
118
+         *
119
+         * @access public
120
+         *
121
+         * @param string|bool $id admin notice name or false.
122
+         *
123
+         * @return array|bool The timeout. False if expired.
124
+         */
125
+        public static function get_admin_notice_cache( $id = false ) {
126
+            if ( ! $id ) {
127
+                return false;
128
+            }
129
+            $cache_key = 'pand-' . md5( $id );
130
+            $timeout   = get_site_option( $cache_key );
131
+            $timeout   = 'forever' === $timeout ? time() + 60 : $timeout;
132
+
133
+            if ( empty( $timeout ) || time() > $timeout ) {
134
+                return false;
135
+            }
136
+
137
+            return $timeout;
138
+        }
139
+
140
+        /**
141
+         * Sets admin notice timeout in site option.
142
+         *
143
+         * @access public
144
+         *
145
+         * @param string      $id       Data Identifier.
146
+         * @param string|bool $timeout  Timeout for admin notice.
147
+         *
148
+         * @return bool
149
+         */
150
+        public static function set_admin_notice_cache( $id, $timeout ) {
151
+            $cache_key = 'pand-' . md5( $id );
152
+            update_site_option( $cache_key, $timeout );
153
+
154
+            return true;
155
+        }
156
+
157
+    }
158 158
 
159 159
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 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,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		 */
53 53
 		public static function load_script() {
54 54
 
55
-			if ( is_customize_preview() ) {
55
+			if (is_customize_preview()) {
56 56
 				return;
57 57
 			}
58 58
 
59 59
 			wp_enqueue_script(
60 60
 				'dismissible-notices',
61
-				plugins_url( 'dismiss-notice.js', __FILE__ ),
62
-				array( 'jquery', 'common' ),
61
+				plugins_url('dismiss-notice.js', __FILE__),
62
+				array('jquery', 'common'),
63 63
 				false,
64 64
 				true
65 65
 			);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				'dismissible-notices',
69 69
 				'dismissible_notice',
70 70
 				array(
71
-					'nonce' => wp_create_nonce( 'dismissible-notice' ),
71
+					'nonce' => wp_create_nonce('dismissible-notice'),
72 72
 				)
73 73
 			);
74 74
 		}
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
 		 * Uses check_ajax_referer to verify nonce.
79 79
 		 */
80 80
 		public static function dismiss_admin_notice() {
81
-			$option_name        = sanitize_text_field( $_POST['option_name'] );
82
-			$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
81
+			$option_name        = sanitize_text_field($_POST['option_name']);
82
+			$dismissible_length = sanitize_text_field($_POST['dismissible_length']);
83 83
 
84
-			if ( 'forever' != $dismissible_length ) {
84
+			if ('forever' != $dismissible_length) {
85 85
 				// If $dismissible_length is not an integer default to 1
86
-				$dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
87
-				$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
86
+				$dismissible_length = (0 == absint($dismissible_length)) ? 1 : $dismissible_length;
87
+				$dismissible_length = strtotime(absint($dismissible_length).' days');
88 88
 			}
89 89
 
90
-			check_ajax_referer( 'dismissible-notice', 'nonce' );
91
-			self::set_admin_notice_cache( $option_name, $dismissible_length );
90
+			check_ajax_referer('dismissible-notice', 'nonce');
91
+			self::set_admin_notice_cache($option_name, $dismissible_length);
92 92
 			wp_die();
93 93
 		}
94 94
 
@@ -99,14 +99,14 @@  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   = self::get_admin_notice_cache( $option_name );
107
-			if ( 'forever' == $db_record ) {
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   = self::get_admin_notice_cache($option_name);
107
+			if ('forever' == $db_record) {
108 108
 				return false;
109
-			} elseif ( absint( $db_record ) >= time() ) {
109
+			} elseif (absint($db_record) >= time()) {
110 110
 				return false;
111 111
 			} else {
112 112
 				return true;
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 		 *
123 123
 		 * @return array|bool The timeout. False if expired.
124 124
 		 */
125
-		public static function get_admin_notice_cache( $id = false ) {
126
-			if ( ! $id ) {
125
+		public static function get_admin_notice_cache($id = false) {
126
+			if (!$id) {
127 127
 				return false;
128 128
 			}
129
-			$cache_key = 'pand-' . md5( $id );
130
-			$timeout   = get_site_option( $cache_key );
129
+			$cache_key = 'pand-'.md5($id);
130
+			$timeout   = get_site_option($cache_key);
131 131
 			$timeout   = 'forever' === $timeout ? time() + 60 : $timeout;
132 132
 
133
-			if ( empty( $timeout ) || time() > $timeout ) {
133
+			if (empty($timeout) || time() > $timeout) {
134 134
 				return false;
135 135
 			}
136 136
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 		 *
148 148
 		 * @return bool
149 149
 		 */
150
-		public static function set_admin_notice_cache( $id, $timeout ) {
151
-			$cache_key = 'pand-' . md5( $id );
152
-			update_site_option( $cache_key, $timeout );
150
+		public static function set_admin_notice_cache($id, $timeout) {
151
+			$cache_key = 'pand-'.md5($id);
152
+			update_site_option($cache_key, $timeout);
153 153
 
154 154
 			return true;
155 155
 		}
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)))) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 if ($this->a === "'" || $this->a === '"' || $this->a === '`') { // string/template literal
200 200
                     $delimiter = $this->a;
201 201
                     $str = $this->a; // in case needed for exception
202
-                    for(;;) {
202
+                    for (;;) {
203 203
                         $this->output .= $this->a;
204 204
                         $this->lastByteOut = $this->a;
205 205
 
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
             case self::ACTION_DELETE_A_B: // 3
230 230
                 $this->b = $this->next();
231 231
                 if ($this->b === '/' && $this->isRegexpLiteral()) {
232
-                    $this->output .= $this->a . $this->b;
232
+                    $this->output .= $this->a.$this->b;
233 233
                     $pattern = '/'; // keep entire pattern in case we need to report it in the exception
234
-                    for(;;) {
234
+                    for (;;) {
235 235
                         $this->a = $this->get();
236 236
                         $pattern .= $this->a;
237 237
                         if ($this->a === '[') {
238
-                            for(;;) {
238
+                            for (;;) {
239 239
                                 $this->output .= $this->a;
240 240
                                 $this->a = $this->get();
241 241
                                 $pattern .= $this->a;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                                 if ($this->isEOF($this->a)) {
251 251
                                     throw new JSMin_UnterminatedRegExpException(
252 252
                                         "JSMin: Unterminated set in RegExp at byte "
253
-                                            . $this->inputIndex .": {$pattern}");
253
+                                            . $this->inputIndex.": {$pattern}");
254 254
                                 }
255 255
                             }
256 256
                         }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
         // if the "/" follows a keyword, it must be a regexp, otherwise it's best to assume division
297 297
 
298
-        $subject = $this->output . trim($this->a);
298
+        $subject = $this->output.trim($this->a);
299 299
         if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) {
300 300
             // not a keyword
301 301
             return false;
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     {
407 407
         $this->get();
408 408
         $comment = '';
409
-        for(;;) {
409
+        for (;;) {
410 410
             $get = $this->get();
411 411
             if ($get === '*') {
412 412
                 if ($this->peek() === '/') { // end of comment reached
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                             // don't prepend a newline if two comments right after one another
418 418
                             $this->keptComment = "\n";
419 419
                         }
420
-                        $this->keptComment .= "/*!" . substr($comment, 1) . "*/\n";
420
+                        $this->keptComment .= "/*!".substr($comment, 1)."*/\n";
421 421
                     } else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
422 422
                         // IE conditional
423 423
                         $this->keptComment .= "/*{$comment}*/";
Please login to merge, or discard this patch.
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.1' );
23
+define('AUTOPTIMIZE_PLUGIN_VERSION', '2.4.1');
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.
classes/autoptimizeCacheChecker.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Checks if cachesize is > 0.5GB (size is filterable), if so, an option is set which controls showing an admin notice.
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
     exit;
11 11
 }
12 12
 
@@ -25,48 +25,48 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function add_hooks()
27 27
     {
28
-        if ( is_admin() ) {
29
-            add_action( 'plugins_loaded', array( $this, 'setup' ) );
28
+        if (is_admin()) {
29
+            add_action('plugins_loaded', array($this, 'setup'));
30 30
         }
31
-        add_action( self::SCHEDULE_HOOK, array( $this, 'cronjob' ) );
32
-        add_action( 'admin_notices', array( $this, 'show_admin_notice' ) );
31
+        add_action(self::SCHEDULE_HOOK, array($this, 'cronjob'));
32
+        add_action('admin_notices', array($this, 'show_admin_notice'));
33 33
     }
34 34
 
35 35
     public function setup()
36 36
     {
37
-        $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
38
-        $schedule       = wp_get_schedule( self::SCHEDULE_HOOK );
39
-        $frequency      = apply_filters( 'autoptimize_filter_cachecheck_frequency', 'twicedaily' );
40
-        if ( ! in_array( $frequency, array( 'hourly', 'twicedaily', 'daily', 'weekly', 'monthly' ) ) ) {
37
+        $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true);
38
+        $schedule       = wp_get_schedule(self::SCHEDULE_HOOK);
39
+        $frequency      = apply_filters('autoptimize_filter_cachecheck_frequency', 'twicedaily');
40
+        if (!in_array($frequency, array('hourly', 'twicedaily', 'daily', 'weekly', 'monthly'))) {
41 41
             $frequency = 'twicedaily';
42 42
         }
43
-        if ( $do_cache_check && ( ! $schedule || $schedule !== $frequency ) ) {
44
-            wp_schedule_event( time(), $frequency, self::SCHEDULE_HOOK );
45
-        } elseif ( $schedule && ! $do_cache_check ) {
46
-            wp_clear_scheduled_hook( self::SCHEDULE_HOOK );
43
+        if ($do_cache_check && (!$schedule || $schedule !== $frequency)) {
44
+            wp_schedule_event(time(), $frequency, self::SCHEDULE_HOOK);
45
+        } elseif ($schedule && !$do_cache_check) {
46
+            wp_clear_scheduled_hook(self::SCHEDULE_HOOK);
47 47
         }
48 48
     }
49 49
 
50 50
     public function cronjob()
51 51
     {
52 52
         // Check cachesize and act accordingly.
53
-        $max_size       = (int) apply_filters( 'autoptimize_filter_cachecheck_maxsize', 536870912 );
54
-        $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
53
+        $max_size       = (int) apply_filters('autoptimize_filter_cachecheck_maxsize', 536870912);
54
+        $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true);
55 55
         $stat_array     = autoptimizeCache::stats();
56
-        $cache_size     = round( $stat_array[1] );
57
-        if ( ( $cache_size > $max_size ) && ( $do_cache_check ) ) {
58
-            update_option( 'autoptimize_cachesize_notice', true );
59
-            if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) {
60
-                $site_url  = esc_url( site_url() );
61
-                $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', get_option( 'admin_email', '' ) );
62
-
63
-                $ao_mailsubject = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $site_url . ')';
64
-                $ao_mailbody    = __( 'Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize' ) . ' (site: ' . $site_url . ')';
65
-
66
-                if ( ! empty( $ao_mailto ) ) {
67
-                    $ao_mailresult = wp_mail( $ao_mailto, $ao_mailsubject, $ao_mailbody );
68
-                    if ( ! $ao_mailresult ) {
69
-                        error_log( 'Autoptimize could not send cache size warning mail.' );
56
+        $cache_size     = round($stat_array[1]);
57
+        if (($cache_size > $max_size) && ($do_cache_check)) {
58
+            update_option('autoptimize_cachesize_notice', true);
59
+            if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) {
60
+                $site_url  = esc_url(site_url());
61
+                $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', get_option('admin_email', ''));
62
+
63
+                $ao_mailsubject = __('Autoptimize cache size warning', 'autoptimize').' ('.$site_url.')';
64
+                $ao_mailbody    = __('Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize').' (site: '.$site_url.')';
65
+
66
+                if (!empty($ao_mailto)) {
67
+                    $ao_mailresult = wp_mail($ao_mailto, $ao_mailsubject, $ao_mailbody);
68
+                    if (!$ao_mailresult) {
69
+                        error_log('Autoptimize could not send cache size warning mail.');
70 70
                     }
71 71
                 }
72 72
             }
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
     public function show_admin_notice()
86 86
     {
87 87
         // fixme: make notices dismissable.
88
-        if ( (bool) get_option( 'autoptimize_cachesize_notice', false ) && current_user_can( 'manage_options' ) ) {
88
+        if ((bool) get_option('autoptimize_cachesize_notice', false) && current_user_can('manage_options')) {
89 89
             echo '<div class="notice notice-warning"><p>';
90
-            _e( '<strong>Autoptimize\'s cache size is getting big</strong>, consider purging the cache. Have a look at <a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank" rel="noopener noreferrer">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize' );
90
+            _e('<strong>Autoptimize\'s cache size is getting big</strong>, consider purging the cache. Have a look at <a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank" rel="noopener noreferrer">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize');
91 91
             echo '</p></div>';
92
-            update_option( 'autoptimize_cachesize_notice', false );
92
+            update_option('autoptimize_cachesize_notice', false);
93 93
         }
94 94
 
95 95
         // Notice for image proxy usage.
96 96
         $_imgopt_notice = autoptimizeExtra::get_imgopt_status_notice_wrapper();
97
-        if ( current_user_can( 'manage_options' ) && is_array( $_imgopt_notice ) && array_key_exists( 'status', $_imgopt_notice ) && in_array( $_imgopt_notice['status'], array( 1, -1, -2 ) ) ) {
97
+        if (current_user_can('manage_options') && is_array($_imgopt_notice) && array_key_exists('status', $_imgopt_notice) && in_array($_imgopt_notice['status'], array(1, -1, -2))) {
98 98
             $_dismissible = 'ao-img-opt-notice-';
99 99
             $_hide_notice = '7';
100 100
 
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
                 $_hide_notice = '1';
103 103
             }
104 104
 
105
-            $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
105
+            $_imgopt_notice_dismissible = apply_filters('autoptimize_filter_imgopt_notice_dismissable', $_dismissible.$_hide_notice);
106 106
 
107
-            if ( $_imgopt_notice && PAnD::is_admin_notice_active( $_imgopt_notice_dismissible ) ) {
108
-                echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p>' . $_imgopt_notice['notice'] . '</p></div>';
107
+            if ($_imgopt_notice && PAnD::is_admin_notice_active($_imgopt_notice_dismissible)) {
108
+                echo '<div class="notice notice-warning is-dismissible" data-dismissible="'.$_imgopt_notice_dismissible.'"><p>'.$_imgopt_notice['notice'].'</p></div>';
109 109
             }
110 110
         }
111 111
     }
Please login to merge, or discard this patch.