Completed
Pull Request — master (#223)
by
unknown
01:56
created
classes/autoptimizeUtils.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * General helpers.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return bool
18 18
      */
19
-    public static function mbstring_available( $override = null )
19
+    public static function mbstring_available($override = null)
20 20
     {
21 21
         static $available = null;
22 22
 
23
-        if ( null === $available ) {
24
-            $available = \extension_loaded( 'mbstring' );
23
+        if (null === $available) {
24
+            $available = \extension_loaded('mbstring');
25 25
         }
26 26
 
27
-        if ( null !== $override ) {
27
+        if (null !== $override) {
28 28
             $available = $override;
29 29
         }
30 30
 
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return int|false
44 44
      */
45
-    public static function strpos( $haystack, $needle, $offset = 0, $encoding = null )
45
+    public static function strpos($haystack, $needle, $offset = 0, $encoding = null)
46 46
     {
47
-        if ( self::mbstring_available() ) {
48
-            return ( null === $encoding ) ? \mb_strpos( $haystack, $needle, $offset ) : \mb_strlen( $haystack, $needle, $offset, $encoding );
47
+        if (self::mbstring_available()) {
48
+            return (null === $encoding) ? \mb_strpos($haystack, $needle, $offset) : \mb_strlen($haystack, $needle, $offset, $encoding);
49 49
         } else {
50
-            return \strpos( $haystack, $needle, $offset );
50
+            return \strpos($haystack, $needle, $offset);
51 51
         }
52 52
     }
53 53
 
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
      * @return int Number of charcters or bytes in given $string
63 63
      *             (characters if/when supported, bytes otherwise).
64 64
      */
65
-    public static function strlen( $string, $encoding = null )
65
+    public static function strlen($string, $encoding = null)
66 66
     {
67
-        if ( self::mbstring_available() ) {
68
-            return ( null === $encoding ) ? \mb_strlen( $string ) : \mb_strlen( $string, $encoding );
67
+        if (self::mbstring_available()) {
68
+            return (null === $encoding) ? \mb_strlen($string) : \mb_strlen($string, $encoding);
69 69
         } else {
70
-            return \strlen( $string );
70
+            return \strlen($string);
71 71
         }
72 72
     }
73 73
 
@@ -85,44 +85,44 @@  discard block
 block discarded – undo
85 85
      *
86 86
      * @return string
87 87
      */
88
-    public static function substr_replace( $string, $replacement, $start, $length = null, $encoding = null )
88
+    public static function substr_replace($string, $replacement, $start, $length = null, $encoding = null)
89 89
     {
90
-        if ( self::mbstring_available() ) {
91
-            $strlen = self::strlen( $string, $encoding );
90
+        if (self::mbstring_available()) {
91
+            $strlen = self::strlen($string, $encoding);
92 92
 
93
-            if ( $start < 0 ) {
93
+            if ($start < 0) {
94 94
                 if ( -$start < $strlen ) {
95 95
                     $start = $strlen + $start;
96 96
                 } else {
97 97
                     $start = 0;
98 98
                 }
99
-            } elseif ( $start > $strlen ) {
99
+            } elseif ($start > $strlen) {
100 100
                 $start = $strlen;
101 101
             }
102 102
 
103
-            if ( null === $length || '' === $length ) {
103
+            if (null === $length || '' === $length) {
104 104
                 $start2 = $strlen;
105
-            } elseif ( $length < 0 ) {
105
+            } elseif ($length < 0) {
106 106
                 $start2 = $strlen + $length;
107
-                if ( $start2 < $start ) {
107
+                if ($start2 < $start) {
108 108
                     $start2 = $start;
109 109
                 }
110 110
             } else {
111 111
                 $start2 = $start + $length;
112 112
             }
113 113
 
114
-            if ( null === $encoding ) {
115
-                $leader  = $start ? \mb_substr( $string, 0, $start ) : '';
116
-                $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null ) : '';
114
+            if (null === $encoding) {
115
+                $leader  = $start ? \mb_substr($string, 0, $start) : '';
116
+                $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null) : '';
117 117
             } else {
118
-                $leader  = $start ? \mb_substr( $string, 0, $start, $encoding ) : '';
119
-                $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null, $encoding ) : '';
118
+                $leader  = $start ? \mb_substr($string, 0, $start, $encoding) : '';
119
+                $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null, $encoding) : '';
120 120
             }
121 121
 
122 122
             return "{$leader}{$replacement}{$trailer}";
123 123
         }
124 124
 
125
-        return ( null === $length ) ? \substr_replace( $string, $replacement, $start ) : \substr_replace( $string, $replacement, $start, $length );
125
+        return (null === $length) ? \substr_replace($string, $replacement, $start) : \substr_replace($string, $replacement, $start, $length);
126 126
     }
127 127
 
128 128
     /**
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return bool
134 134
      */
135
-    public static function siteurl_not_root( $override = null )
135
+    public static function siteurl_not_root($override = null)
136 136
     {
137 137
         static $subdir = null;
138 138
 
139
-        if ( null === $subdir ) {
139
+        if (null === $subdir) {
140 140
             $parts  = self::get_ao_wp_site_url_parts();
141
-            $subdir = ( isset( $parts['path'] ) && ( '/' !== $parts['path'] ) );
141
+            $subdir = (isset($parts['path']) && ('/' !== $parts['path']));
142 142
         }
143 143
 
144
-        if ( null !== $override ) {
144
+        if (null !== $override) {
145 145
             $subdir = $override;
146 146
         }
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     {
159 159
         static $parts = array();
160 160
 
161
-        if ( empty( $parts ) ) {
162
-            $parts = \parse_url( AUTOPTIMIZE_WP_SITE_URL );
161
+        if (empty($parts)) {
162
+            $parts = \parse_url(AUTOPTIMIZE_WP_SITE_URL);
163 163
         }
164 164
 
165 165
         return $parts;
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @return string
176 176
      */
177
-    public static function tweak_cdn_url_if_needed( $cdn_url, $force_cache_miss = false )
177
+    public static function tweak_cdn_url_if_needed($cdn_url, $force_cache_miss = false)
178 178
     {
179 179
         static $results = array();
180 180
 
181
-        if ( ! isset( $results[ $cdn_url ] ) || $force_cache_miss ) {
181
+        if (!isset($results[$cdn_url]) || $force_cache_miss) {
182 182
 
183 183
             // In order to return unmodified input when there's no need to tweak.
184
-            $results[ $cdn_url ] = $cdn_url;
184
+            $results[$cdn_url] = $cdn_url;
185 185
 
186 186
             // Behind a default true filter for backcompat, and only for sites
187 187
             // in a subfolder/subdirectory, but still easily turned off if
188 188
             // not wanted/needed...
189
-            if ( autoptimizeUtils::siteurl_not_root() ) {
190
-                $check = apply_filters( 'autoptimize_filter_cdn_magic_path_check', true, $cdn_url );
191
-                if ( $check ) {
189
+            if (autoptimizeUtils::siteurl_not_root()) {
190
+                $check = apply_filters('autoptimize_filter_cdn_magic_path_check', true, $cdn_url);
191
+                if ($check) {
192 192
                     $site_url_parts = autoptimizeUtils::get_ao_wp_site_url_parts();
193
-                    $cdn_url_parts  = \parse_url( $cdn_url );
194
-                    $schemeless     = self::is_protocol_relative( $cdn_url );
195
-                    $cdn_url_parts  = self::maybe_replace_cdn_path( $site_url_parts, $cdn_url_parts );
196
-                    if ( false !== $cdn_url_parts ) {
197
-                        $results[ $cdn_url ] = self::assemble_parsed_url( $cdn_url_parts, $schemeless );
193
+                    $cdn_url_parts  = \parse_url($cdn_url);
194
+                    $schemeless     = self::is_protocol_relative($cdn_url);
195
+                    $cdn_url_parts  = self::maybe_replace_cdn_path($site_url_parts, $cdn_url_parts);
196
+                    if (false !== $cdn_url_parts) {
197
+                        $results[$cdn_url] = self::assemble_parsed_url($cdn_url_parts, $schemeless);
198 198
                     }
199 199
                 }
200 200
             }
201 201
         }
202 202
 
203
-        return $results[ $cdn_url ];
203
+        return $results[$cdn_url];
204 204
     }
205 205
 
206 206
     /**
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @return array|false
216 216
      */
217
-    public static function maybe_replace_cdn_path( array $site_url_parts, array $cdn_url_parts )
217
+    public static function maybe_replace_cdn_path(array $site_url_parts, array $cdn_url_parts)
218 218
     {
219
-        if ( isset( $site_url_parts['path'] ) && '/' !== $site_url_parts['path'] ) {
220
-            if ( ! isset( $cdn_url_parts['path'] ) || '/' === $cdn_url_parts['path'] ) {
219
+        if (isset($site_url_parts['path']) && '/' !== $site_url_parts['path']) {
220
+            if (!isset($cdn_url_parts['path']) || '/' === $cdn_url_parts['path']) {
221 221
                 $cdn_url_parts['path'] = $site_url_parts['path'];
222 222
                 return $cdn_url_parts;
223 223
             }
@@ -237,20 +237,20 @@  discard block
 block discarded – undo
237 237
      *
238 238
      * @return string
239 239
      */
240
-    public static function assemble_parsed_url( array $parsed_url, $schemeless = false )
240
+    public static function assemble_parsed_url(array $parsed_url, $schemeless = false)
241 241
     {
242
-        $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
243
-        if ( $schemeless ) {
242
+        $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
243
+        if ($schemeless) {
244 244
             $scheme = '//';
245 245
         }
246
-        $host     = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
247
-        $port     = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
248
-        $user     = isset( $parsed_url['user'] ) ? $parsed_url['user'] : '';
249
-        $pass     = isset( $parsed_url['pass'] ) ? ':' . $parsed_url['pass'] : '';
250
-        $pass     = ( $user || $pass ) ? "$pass@" : '';
251
-        $path     = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
252
-        $query    = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
253
-        $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
246
+        $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
247
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
248
+        $user     = isset($parsed_url['user']) ? $parsed_url['user'] : '';
249
+        $pass     = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : '';
250
+        $pass     = ($user || $pass) ? "$pass@" : '';
251
+        $path     = isset($parsed_url['path']) ? $parsed_url['path'] : '';
252
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
253
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
254 254
 
255 255
         return "$scheme$user$pass$host$port$path$query$fragment";
256 256
     }
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
      *
263 263
      * @return bool
264 264
      */
265
-    public static function is_protocol_relative( $url )
265
+    public static function is_protocol_relative($url)
266 266
     {
267 267
         $result = false;
268 268
 
269
-        if ( ! empty( $url ) ) {
270
-            $result = ( 0 === strpos( $url, '//' ) );
269
+        if (!empty($url)) {
270
+            $result = (0 === strpos($url, '//'));
271 271
         }
272 272
 
273 273
         return $result;
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @return string
282 282
      */
283
-    public static function path_canonicalize( $path )
283
+    public static function path_canonicalize($path)
284 284
     {
285
-        $patterns     = array(
285
+        $patterns = array(
286 286
             '~/{2,}~',
287 287
             '~/(\./)+~',
288 288
             '~([^/\.]+/(?R)*\.{2,}/)~',
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             '',
296 296
         );
297 297
 
298
-        return preg_replace( $patterns, $replacements, $path );
298
+        return preg_replace($patterns, $replacements, $path);
299 299
     }
300 300
 
301 301
     /**
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
      *
306 306
      * @return none if $return_result is false (default), array if $return_result is true.
307 307
      */
308
-    public static function check_service_availability( $return_result = false )
308
+    public static function check_service_availability($return_result = false)
309 309
     {
310
-        $service_availability_resp = wp_remote_get( 'https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=' . AUTOPTIMIZE_PLUGIN_VERSION );
311
-        if ( ! is_wp_error( $service_availability_resp ) ) {
312
-            if ( '200' == wp_remote_retrieve_response_code( $service_availability_resp ) ) {
313
-                $availabilities = json_decode( wp_remote_retrieve_body( $service_availability_resp ), true );
314
-                if ( is_array( $availabilities ) ) {
315
-                    update_option( 'autoptimize_service_availablity', $availabilities );
316
-                    if ( $return_result ) {
310
+        $service_availability_resp = wp_remote_get('https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver='.AUTOPTIMIZE_PLUGIN_VERSION);
311
+        if (!is_wp_error($service_availability_resp)) {
312
+            if ('200' == wp_remote_retrieve_response_code($service_availability_resp)) {
313
+                $availabilities = json_decode(wp_remote_retrieve_body($service_availability_resp), true);
314
+                if (is_array($availabilities)) {
315
+                    update_option('autoptimize_service_availablity', $availabilities);
316
+                    if ($return_result) {
317 317
                         return $availabilities;
318 318
                     }
319 319
                 }
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
      *
329 329
      * @return bool
330 330
      */
331
-    public static function str_is_valid_regex( $string )
331
+    public static function str_is_valid_regex($string)
332 332
     {
333
-        set_error_handler( function() {}, E_WARNING );
334
-        $is_regex = ( false !== preg_match( $string, '' ) );
333
+        set_error_handler(function() {}, E_WARNING);
334
+        $is_regex = (false !== preg_match($string, ''));
335 335
         restore_error_handler();
336 336
 
337 337
         return $is_regex;
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
      *
345 345
      * @return bool
346 346
      */
347
-    public static function is_plugin_active( $plugin_file )
347
+    public static function is_plugin_active($plugin_file)
348 348
     {
349 349
         static $ipa_exists = null;
350
-        if ( null === $ipa_exists ) {
351
-            if ( ! function_exists( '\is_plugin_active' ) ) {
352
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
350
+        if (null === $ipa_exists) {
351
+            if (!function_exists('\is_plugin_active')) {
352
+                require_once ABSPATH.'wp-admin/includes/plugin.php';
353 353
             }
354
-            $ipa_exists = function_exists( '\is_plugin_active' );
354
+            $ipa_exists = function_exists('\is_plugin_active');
355 355
         }
356 356
 
357
-        return $ipa_exists && \is_plugin_active( $plugin_file );
357
+        return $ipa_exists && \is_plugin_active($plugin_file);
358 358
     }
359 359
 }
Please login to merge, or discard this patch.
classes/autoptimizeImages.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Handles optimizing images.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected static $instance = null;
25 25
 
26
-    public function __construct( array $options = array() )
26
+    public function __construct(array $options = array())
27 27
     {
28 28
         // If options are not provided, grab them from autoptimizeExtra, as
29 29
         // that's what we're relying on to do image optimizations for now...
30
-        if ( empty( $options ) ) {
30
+        if (empty($options)) {
31 31
             $options = autoptimizeExtra::fetch_options();
32 32
         }
33 33
 
34
-        $this->set_options( $options );
34
+        $this->set_options($options);
35 35
     }
36 36
 
37
-    public function set_options( array $options )
37
+    public function set_options(array $options)
38 38
     {
39 39
         $this->options = $options;
40 40
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function instance()
53 53
     {
54
-        if ( null === self::$instance ) {
54
+        if (null === self::$instance) {
55 55
             self::$instance = new self();
56 56
         }
57 57
 
@@ -60,36 +60,36 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function run()
62 62
     {
63
-        if ( ! $this->should_run() ) {
63
+        if (!$this->should_run()) {
64 64
             return;
65 65
         }
66 66
 
67 67
         $active = false;
68 68
 
69
-        if ( apply_filters( 'autoptimize_filter_extra_imgopt_do', true ) ) {
69
+        if (apply_filters('autoptimize_filter_extra_imgopt_do', true)) {
70 70
             add_filter(
71 71
                 'autoptimize_html_after_minify',
72
-                array( $this, 'filter_optimize_images' ),
72
+                array($this, 'filter_optimize_images'),
73 73
                 10,
74 74
                 1
75 75
             );
76 76
             $active = true;
77 77
         }
78 78
 
79
-        if ( apply_filters( 'autoptimize_filter_extra_imgopt_do_css', true ) ) {
79
+        if (apply_filters('autoptimize_filter_extra_imgopt_do_css', true)) {
80 80
             add_filter(
81 81
                 'autoptimize_filter_base_replace_cdn',
82
-                array( $this, 'filter_optimize_css_images' ),
82
+                array($this, 'filter_optimize_css_images'),
83 83
                 10,
84 84
                 1
85 85
             );
86 86
             $active = true;
87 87
         }
88 88
 
89
-        if ( $active ) {
89
+        if ($active) {
90 90
             add_filter(
91 91
                 'autoptimize_extra_filter_tobepreconn',
92
-                array( $this, 'filter_preconnect_imgopt_url' ),
92
+                array($this, 'filter_preconnect_imgopt_url'),
93 93
                 10,
94 94
                 1
95 95
             );
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
     protected function should_run()
105 105
     {
106 106
         $opts              = $this->options;
107
-        $service_not_down  = ( 'down' !== $opts['availabilities']['extra_imgopt']['status'] );
108
-        $not_launch_status = ( 'launch' !== $opts['availabilities']['extra_imgopt']['status'] );
107
+        $service_not_down  = ('down' !== $opts['availabilities']['extra_imgopt']['status']);
108
+        $not_launch_status = ('launch' !== $opts['availabilities']['extra_imgopt']['status']);
109 109
 
110 110
         $do_cdn     = true;
111 111
         $_userstatus = $this->get_imgopt_provider_userstatus();
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
         }
115 115
 
116 116
         if (
117
-            ! empty( $opts['autoptimize_extra_checkbox_field_5'] )
117
+            !empty($opts['autoptimize_extra_checkbox_field_5'])
118 118
             && $do_cdn 
119 119
             && $service_not_down
120
-            && ( $not_launch_status || $this->launch_ok() )
120
+            && ($not_launch_status || $this->launch_ok())
121 121
         ) {
122 122
             return true;
123 123
         }
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
     {
135 135
         static $launch_status = null;
136 136
 
137
-        if ( null === $launch_status ) {
137
+        if (null === $launch_status) {
138 138
             $avail_imgopt  = $this->options['availabilities']['extra_imgopt'];
139
-            $magic_number  = intval( substr( md5( parse_url( AUTOPTIMIZE_WP_SITE_URL, PHP_URL_HOST ) ), 0, 3 ), 16 );
140
-            $has_launched  = get_option( 'autoptimize_imgopt_launched', '' );
139
+            $magic_number  = intval(substr(md5(parse_url(AUTOPTIMIZE_WP_SITE_URL, PHP_URL_HOST)), 0, 3), 16);
140
+            $has_launched  = get_option('autoptimize_imgopt_launched', '');
141 141
             $launch_status = false;
142
-            if ( $has_launched || ( is_array( $avail_imgopt ) && array_key_exists( 'launch-threshold', $avail_imgopt ) && $magic_number < $avail_imgopt['launch-threshold'] ) ) {
142
+            if ($has_launched || (is_array($avail_imgopt) && array_key_exists('launch-threshold', $avail_imgopt) && $magic_number < $avail_imgopt['launch-threshold'])) {
143 143
                 $launch_status = true;
144
-                if ( ! $has_launched ) {
145
-                    update_option( 'autoptimize_imgopt_launched', 'on' );
144
+                if (!$has_launched) {
145
+                    update_option('autoptimize_imgopt_launched', 'on');
146 146
                 }
147 147
             }
148 148
         }
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
     {
155 155
         static $imgopt_host = null;
156 156
 
157
-        if ( null === $imgopt_host ) {
157
+        if (null === $imgopt_host) {
158 158
             $imgopt_host  = 'https://cdn.shortpixel.ai/';
159 159
             $avail_imgopt = $this->options['availabilities']['extra_imgopt'];
160
-            if ( ! empty( $avail_imgopt ) && array_key_exists( 'hosts', $avail_imgopt ) && is_array( $avail_imgopt['hosts'] ) ) {
161
-                $imgopt_host = array_rand( array_flip( $avail_imgopt['hosts'] ) );
160
+            if (!empty($avail_imgopt) && array_key_exists('hosts', $avail_imgopt) && is_array($avail_imgopt['hosts'])) {
161
+                $imgopt_host = array_rand(array_flip($avail_imgopt['hosts']));
162 162
             }
163 163
         }
164 164
 
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
     public function get_imgopt_provider_userstatus() {
169 169
         static $_provider_userstatus = null;
170 170
 
171
-        if ( is_null( $_provider_userstatus ) ) {
172
-            $_stat = get_option( 'autoptimize_imgopt_provider_stat', '' );
173
-            if ( is_array( $_stat ) ) {
174
-                if ( array_key_exists( 'Status', $_stat ) ) {
171
+        if (is_null($_provider_userstatus)) {
172
+            $_stat = get_option('autoptimize_imgopt_provider_stat', '');
173
+            if (is_array($_stat)) {
174
+                if (array_key_exists('Status', $_stat)) {
175 175
                     $_provider_userstatus['Status'] = $_stat['Status'];
176 176
                 } else {
177 177
                     // if no stats then we assume all is well.
178 178
                     $_provider_userstatus['Status'] = 2;
179 179
                 }
180
-                if ( array_key_exists( 'timestamp', $_stat ) ) {
180
+                if (array_key_exists('timestamp', $_stat)) {
181 181
                     $_provider_userstatus['timestamp'] = $_stat['timestamp'];
182 182
                 } else {
183 183
                     // if no timestamp then we return "".
@@ -192,24 +192,24 @@  discard block
 block discarded – undo
192 192
     public function get_status_notice()
193 193
     {
194 194
         $opts = $this->options;
195
-        if ( ! empty( $opts ) && is_array( $opts ) && array_key_exists( 'autoptimize_extra_checkbox_field_5', $opts ) && ! empty( $opts['autoptimize_extra_checkbox_field_5'] ) ) {
195
+        if (!empty($opts) && is_array($opts) && array_key_exists('autoptimize_extra_checkbox_field_5', $opts) && !empty($opts['autoptimize_extra_checkbox_field_5'])) {
196 196
             $notice = '';
197 197
             $stat   = $this->get_imgopt_provider_userstatus();
198
-            $upsell = 'https://shortpixel.com/aospai/af/GWRGFLW109483/' . AUTOPTIMIZE_SITE_DOMAIN;
198
+            $upsell = 'https://shortpixel.com/aospai/af/GWRGFLW109483/'.AUTOPTIMIZE_SITE_DOMAIN;
199 199
 
200
-            if ( is_array( $stat ) ) {
201
-                if ( 1 == $stat['Status'] ) {
200
+            if (is_array($stat)) {
201
+                if (1 == $stat['Status']) {
202 202
                     // translators: "add more credits" will appear in a "a href".
203
-                    $notice = sprintf( __( 'Your ShortPixel image optimization and CDN quota is almost used, make sure you %1$sadd more credits%2$s to avoid slowing down your website.', 'autoptimize' ), '<a rel="noopener noreferrer" href="' . $upsell . '" target="_blank">', '</a>' );
203
+                    $notice = sprintf(__('Your ShortPixel image optimization and CDN quota is almost used, make sure you %1$sadd more credits%2$s to avoid slowing down your website.', 'autoptimize'), '<a rel="noopener noreferrer" href="'.$upsell.'" target="_blank">', '</a>');
204 204
                 } elseif ( -1 == $stat['Status'] || -2 == $stat['Status'] ) {
205 205
                     // translators: "add more credits" will appear in a "a href".
206
-                    $notice = sprintf( __( 'Your ShortPixel image optimization and CDN quota was used, %1$sadd more credits%2$s to keep fast serving optimized images on your site.', 'autoptimize' ), '<a rel="noopener noreferrer" href="' . $upsell . '" target="_blank">', '</a>' );
206
+                    $notice = sprintf(__('Your ShortPixel image optimization and CDN quota was used, %1$sadd more credits%2$s to keep fast serving optimized images on your site.', 'autoptimize'), '<a rel="noopener noreferrer" href="'.$upsell.'" target="_blank">', '</a>');
207 207
                 } else {
208 208
                     $upsell = 'https://shortpixel.com/g/af/GWRGFLW109483';
209 209
                     // translators: "log in to check your account" will appear in a "a href".
210
-                    $notice = sprintf( __( 'Your ShortPixel image optimization and CDN quota are in good shape, %1$slog in to check your account%2$s.', 'autoptimize' ), '<a rel="noopener noreferrer" href="' . $upsell . '" target="_blank">', '</a>' );
210
+                    $notice = sprintf(__('Your ShortPixel image optimization and CDN quota are in good shape, %1$slog in to check your account%2$s.', 'autoptimize'), '<a rel="noopener noreferrer" href="'.$upsell.'" target="_blank">', '</a>');
211 211
                 }
212
-                $notice = apply_filters( 'autoptimize_filter_imgopt_notice', $notice );
212
+                $notice = apply_filters('autoptimize_filter_imgopt_notice', $notice);
213 213
 
214 214
                 return array(
215 215
                     'status' => $stat['Status'],
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 
223 223
     public static function get_service_url_suffix()
224 224
     {
225
-        $suffix = '/af/GWRGFLW109483/' . AUTOPTIMIZE_SITE_DOMAIN;
225
+        $suffix = '/af/GWRGFLW109483/'.AUTOPTIMIZE_SITE_DOMAIN;
226 226
 
227 227
         return $suffix;
228 228
     }
229 229
 
230 230
     public function query_img_provider_stats()
231 231
     {
232
-        if ( ! empty( $this->options['autoptimize_extra_checkbox_field_5'] ) ) {
232
+        if (!empty($this->options['autoptimize_extra_checkbox_field_5'])) {
233 233
             $url      = '';
234
-            $endpoint = $this->get_imgopt_host() . 'read-domain/';
234
+            $endpoint = $this->get_imgopt_host().'read-domain/';
235 235
             $domain   = AUTOPTIMIZE_SITE_DOMAIN;
236 236
 
237 237
             // make sure parse_url result makes sense, keeping $url empty if not.
238
-            if ( $domain && ! empty( $domain ) ) {
239
-                $url = $endpoint . $domain;
238
+            if ($domain && !empty($domain)) {
239
+                $url = $endpoint.$domain;
240 240
             }
241 241
 
242 242
             $url = apply_filters(
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 
247 247
             // only do the remote call if $url is not empty to make sure no parse_url
248 248
             // weirdness results in useless calls.
249
-            if ( ! empty( $url ) ) {
250
-                $response = wp_remote_get( $url );
251
-                if ( ! is_wp_error( $response ) ) {
252
-                    if ( '200' == wp_remote_retrieve_response_code( $response ) ) {
253
-                        $stats = json_decode( wp_remote_retrieve_body( $response ), true );
254
-                        update_option( 'autoptimize_imgopt_provider_stat', $stats );
249
+            if (!empty($url)) {
250
+                $response = wp_remote_get($url);
251
+                if (!is_wp_error($response)) {
252
+                    if ('200' == wp_remote_retrieve_response_code($response)) {
253
+                        $stats = json_decode(wp_remote_retrieve_body($response), true);
254
+                        update_option('autoptimize_imgopt_provider_stat', $stats);
255 255
                     }
256 256
                 }
257 257
             }
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
     {
263 263
         static $quality = null;
264 264
 
265
-        if ( null === $quality ) {
265
+        if (null === $quality) {
266 266
             $q_array = $this->get_img_quality_array();
267 267
             $setting = $this->get_img_quality_setting();
268 268
             $quality = apply_filters(
269 269
                 'autoptimize_filter_extra_imgopt_quality',
270
-                'q_' . $q_array[ $setting ]
270
+                'q_'.$q_array[$setting]
271 271
             );
272 272
         }
273 273
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     {
279 279
         static $map = null;
280 280
 
281
-        if ( null === $map ) {
281
+        if (null === $map) {
282 282
             $map = array(
283 283
                 '1' => 'lossy',
284 284
                 '2' => 'glossy',
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
     {
298 298
         static $q = null;
299 299
 
300
-        if ( null === $q ) {
301
-            if ( is_array( $this->options ) && array_key_exists( 'autoptimize_extra_select_field_6', $this->options ) ) {
300
+        if (null === $q) {
301
+            if (is_array($this->options) && array_key_exists('autoptimize_extra_select_field_6', $this->options)) {
302 302
                 $_setting = $this->options['autoptimize_extra_select_field_6'];
303 303
             }
304 304
 
305
-            if ( ! isset( $setting ) || empty( $setting ) || ( '1' !== $setting && '3' !== $setting ) ) {
305
+            if (!isset($setting) || empty($setting) || ('1' !== $setting && '3' !== $setting)) {
306 306
                 // default image opt. value is 2 ("glossy").
307 307
                 $q = '2';
308 308
             } else {
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
         return $q;
314 314
     }
315 315
 
316
-    public function filter_preconnect_imgopt_url( array $in )
316
+    public function filter_preconnect_imgopt_url(array $in)
317 317
     {
318
-        $url_parts = parse_url( $this->get_imgopt_base_url() );
319
-        $in[]      = $url_parts['scheme'] . '://' . $url_parts['host'];
318
+        $url_parts = parse_url($this->get_imgopt_base_url());
319
+        $in[]      = $url_parts['scheme'].'://'.$url_parts['host'];
320 320
 
321 321
         return $in;
322 322
     }
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @return string
331 331
      */
332
-    private function normalize_img_url( $in )
332
+    private function normalize_img_url($in)
333 333
     {
334 334
         // Only parse the site url once.
335 335
         static $parsed_site_url = null;
336
-        if ( null === $parsed_site_url ) {
337
-            $parsed_site_url = parse_url( site_url() );
336
+        if (null === $parsed_site_url) {
337
+            $parsed_site_url = parse_url(site_url());
338 338
         }
339 339
 
340 340
         // get CDN domain once.
341 341
         static $cdn_domain = null;
342
-        if ( is_null( $cdn_domain ) ) {
343
-            $cdn_url = apply_filters( 'autoptimize_filter_base_cdnurl', get_option( 'autoptimize_cdn_url', '' ) );
344
-            if ( ! empty( $cdn_url ) ) {
345
-                $cdn_domain = parse_url( $cdn_url, PHP_URL_HOST );
342
+        if (is_null($cdn_domain)) {
343
+            $cdn_url = apply_filters('autoptimize_filter_base_cdnurl', get_option('autoptimize_cdn_url', ''));
344
+            if (!empty($cdn_url)) {
345
+                $cdn_domain = parse_url($cdn_url, PHP_URL_HOST);
346 346
             } else {
347 347
                 $cdn_domain = '';
348 348
             }
@@ -358,43 +358,43 @@  discard block
 block discarded – undo
358 358
          * identical string operations).
359 359
          */
360 360
         static $cache = null;
361
-        if ( null === $cache ) {
361
+        if (null === $cache) {
362 362
             $cache = array();
363 363
         }
364 364
 
365 365
         // Do the work on cache miss only.
366
-        if ( ! isset( $cache[ $in ] ) ) {
366
+        if (!isset($cache[$in])) {
367 367
             // Default to what was given to us.
368 368
             $result = $in;
369
-            if ( autoptimizeUtils::is_protocol_relative( $in ) ) {
370
-                $result = $parsed_site_url['scheme'] . ':' . $in;
371
-            } elseif ( 0 === strpos( $in, '/' ) ) {
369
+            if (autoptimizeUtils::is_protocol_relative($in)) {
370
+                $result = $parsed_site_url['scheme'].':'.$in;
371
+            } elseif (0 === strpos($in, '/')) {
372 372
                 // Root-relative...
373
-                $result = $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'];
373
+                $result = $parsed_site_url['scheme'].'://'.$parsed_site_url['host'];
374 374
                 // Add the path for subfolder installs.
375
-                if ( isset( $parsed_site_url['path'] ) ) {
375
+                if (isset($parsed_site_url['path'])) {
376 376
                     $result .= $parsed_site_url['path'];
377 377
                 }
378 378
                 $result .= $in;
379
-            } elseif ( ! empty( $cdn_domain ) && strpos( $in, $cdn_domain ) !== 0 ) {
380
-                $result = str_replace( $cdn_domain, $parsed_site_url['host'], $in );
379
+            } elseif (!empty($cdn_domain) && strpos($in, $cdn_domain) !== 0) {
380
+                $result = str_replace($cdn_domain, $parsed_site_url['host'], $in);
381 381
             }
382 382
 
383
-            $result = apply_filters( 'autoptimize_filter_extra_imgopt_normalized_url', $result );
383
+            $result = apply_filters('autoptimize_filter_extra_imgopt_normalized_url', $result);
384 384
 
385 385
             // Store in cache.
386
-            $cache[ $in ] = $result;
386
+            $cache[$in] = $result;
387 387
         }
388 388
 
389
-        return $cache[ $in ];
389
+        return $cache[$in];
390 390
     }
391 391
 
392
-    public function filter_optimize_css_images( $in )
392
+    public function filter_optimize_css_images($in)
393 393
     {
394
-        $in = $this->normalize_img_url( $in );
394
+        $in = $this->normalize_img_url($in);
395 395
 
396
-        if ( $this->can_optimize_image( $in ) ) {
397
-            return $this->build_imgopt_url( $in, '', '' );
396
+        if ($this->can_optimize_image($in)) {
397
+            return $this->build_imgopt_url($in, '', '');
398 398
         } else {
399 399
             return $in;
400 400
         }
@@ -404,50 +404,50 @@  discard block
 block discarded – undo
404 404
     {
405 405
         static $imgopt_base_url = null;
406 406
 
407
-        if ( null === $imgopt_base_url ) {
407
+        if (null === $imgopt_base_url) {
408 408
             $imgopt_host     = $this->get_imgopt_host();
409 409
             $quality         = $this->get_img_quality_string();
410
-            $ret_val         = apply_filters( 'autoptimize_filter_extra_imgopt_wait', 'ret_img' ); // values: ret_wait, ret_img, ret_json, ret_blank.
411
-            $imgopt_base_url = $imgopt_host . 'client/' . $quality . ',' . $ret_val;
412
-            $imgopt_base_url = apply_filters( 'autoptimize_filter_extra_imgopt_base_url', $imgopt_base_url );
410
+            $ret_val         = apply_filters('autoptimize_filter_extra_imgopt_wait', 'ret_img'); // values: ret_wait, ret_img, ret_json, ret_blank.
411
+            $imgopt_base_url = $imgopt_host.'client/'.$quality.','.$ret_val;
412
+            $imgopt_base_url = apply_filters('autoptimize_filter_extra_imgopt_base_url', $imgopt_base_url);
413 413
         }
414 414
 
415 415
         return $imgopt_base_url;
416 416
     }
417 417
 
418
-    private function can_optimize_image( $url )
418
+    private function can_optimize_image($url)
419 419
     {
420 420
         static $cdn_url      = null;
421 421
         static $nopti_images = null;
422 422
 
423
-        if ( null === $cdn_url ) {
423
+        if (null === $cdn_url) {
424 424
             $cdn_url = apply_filters(
425 425
                 'autoptimize_filter_base_cdnurl',
426
-                get_option( 'autoptimize_cdn_url', '' )
426
+                get_option('autoptimize_cdn_url', '')
427 427
             );
428 428
         }
429 429
 
430
-        if ( null === $nopti_images ) {
431
-            $nopti_images = apply_filters( 'autoptimize_filter_extra_imgopt_noptimize', '' );
430
+        if (null === $nopti_images) {
431
+            $nopti_images = apply_filters('autoptimize_filter_extra_imgopt_noptimize', '');
432 432
         }
433 433
 
434 434
         $site_host  = AUTOPTIMIZE_SITE_DOMAIN;
435
-        $url        = $this->normalize_img_url( $url );
436
-        $url_parsed = parse_url( $url );
435
+        $url        = $this->normalize_img_url($url);
436
+        $url_parsed = parse_url($url);
437 437
 
438
-        if ( array_key_exists( 'host', $url_parsed ) && $url_parsed['host'] !== $site_host && empty( $cdn_url ) ) {
438
+        if (array_key_exists('host', $url_parsed) && $url_parsed['host'] !== $site_host && empty($cdn_url)) {
439 439
             return false;
440
-        } elseif ( ! empty( $cdn_url ) && strpos( $url, $cdn_url ) === false && array_key_exists( 'host', $url_parsed ) && $url_parsed['host'] !== $site_host ) {
440
+        } elseif (!empty($cdn_url) && strpos($url, $cdn_url) === false && array_key_exists('host', $url_parsed) && $url_parsed['host'] !== $site_host) {
441 441
             return false;
442
-        } elseif ( strpos( $url, '.php' ) !== false ) {
442
+        } elseif (strpos($url, '.php') !== false) {
443 443
             return false;
444
-        } elseif ( str_ireplace( array( '.png', '.gif', '.jpg', '.jpeg', '.webp' ), '', $url_parsed['path'] ) === $url_parsed['path'] ) {
444
+        } elseif (str_ireplace(array('.png', '.gif', '.jpg', '.jpeg', '.webp'), '', $url_parsed['path']) === $url_parsed['path']) {
445 445
             // fixme: better check against end of string.
446 446
             return false;
447
-        } elseif ( ! empty( $nopti_images ) ) {
448
-            $nopti_images_array = array_filter( array_map( 'trim', explode( ',', $nopti_images ) ) );
449
-            foreach ( $nopti_images_array as $nopti_image ) {
450
-                if ( strpos( $url, $nopti_image ) !== false ) {
447
+        } elseif (!empty($nopti_images)) {
448
+            $nopti_images_array = array_filter(array_map('trim', explode(',', $nopti_images)));
449
+            foreach ($nopti_images_array as $nopti_image) {
450
+                if (strpos($url, $nopti_image) !== false) {
451 451
                     return false;
452 452
                 }
453 453
             }
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
         return true;
456 456
     }
457 457
 
458
-    private function build_imgopt_url( $orig_url, $width = 0, $height = 0 )
458
+    private function build_imgopt_url($orig_url, $width = 0, $height = 0)
459 459
     {
460 460
         // sanitize width and height.
461
-        if ( strpos( $width, '%' ) !== false ) {
461
+        if (strpos($width, '%') !== false) {
462 462
             $width = 0;
463 463
         }
464
-        if ( strpos( $height, '%' ) !== false ) {
464
+        if (strpos($height, '%') !== false) {
465 465
             $height = 0;
466 466
         }
467 467
         $width  = (int) $width;
@@ -475,42 +475,42 @@  discard block
 block discarded – undo
475 475
         );
476 476
 
477 477
         // If filter modified the url, return that.
478
-        if ( $filtered_url !== $orig_url ) {
478
+        if ($filtered_url !== $orig_url) {
479 479
             return $filtered_url;
480 480
         }
481 481
 
482
-        $orig_url        = $this->normalize_img_url( $orig_url );
482
+        $orig_url        = $this->normalize_img_url($orig_url);
483 483
         $imgopt_base_url = $this->get_imgopt_base_url();
484 484
         $imgopt_size     = '';
485 485
 
486
-        if ( $width && 0 !== $width ) {
487
-            $imgopt_size = ',w_' . $width;
486
+        if ($width && 0 !== $width) {
487
+            $imgopt_size = ',w_'.$width;
488 488
         }
489 489
 
490
-        if ( $height && 0 !== $height ) {
491
-            $imgopt_size .= ',h_' . $height;
490
+        if ($height && 0 !== $height) {
491
+            $imgopt_size .= ',h_'.$height;
492 492
         }
493 493
 
494
-        $url = $imgopt_base_url . $imgopt_size . '/' . $orig_url;
494
+        $url = $imgopt_base_url.$imgopt_size.'/'.$orig_url;
495 495
 
496 496
         return $url;
497 497
     }
498 498
 
499
-    public function replace_data_thumbs( $matches )
499
+    public function replace_data_thumbs($matches)
500 500
     {
501
-        $this->replace_img_callback( $matches, 150, 150 );
501
+        $this->replace_img_callback($matches, 150, 150);
502 502
     }
503 503
 
504
-    public function replace_img_callback( $matches, $width=0 , $height=0 )
504
+    public function replace_img_callback($matches, $width = 0, $height = 0)
505 505
     {
506
-        if ( $this->can_optimize_image( $matches[1] ) ) {
507
-            return str_replace( $matches[1], $this->build_imgopt_url( $matches[1], $width, $height ), $matches[0] );
506
+        if ($this->can_optimize_image($matches[1])) {
507
+            return str_replace($matches[1], $this->build_imgopt_url($matches[1], $width, $height), $matches[0]);
508 508
         } else {
509 509
             return $matches[0];
510 510
         }
511 511
     }
512 512
 
513
-    public function filter_optimize_images( $in )
513
+    public function filter_optimize_images($in)
514 514
     {
515 515
         /*
516 516
          * potential future functional improvements:
@@ -521,26 +521,26 @@  discard block
 block discarded – undo
521 521
         $to_replace = array();
522 522
 
523 523
         // extract img tags.
524
-        if ( preg_match_all( '#<img[^>]*src[^>]*>#Usmi', $in, $matches ) ) {
525
-            foreach ( $matches[0] as $tag ) {
524
+        if (preg_match_all('#<img[^>]*src[^>]*>#Usmi', $in, $matches)) {
525
+            foreach ($matches[0] as $tag) {
526 526
                 $orig_tag = $tag;
527 527
                 $imgopt_w = '';
528 528
                 $imgopt_h = '';
529 529
 
530 530
                 // first do (data-)srcsets.
531
-                if ( preg_match_all( '#srcset=("|\')(.*)("|\')#Usmi', $tag, $allsrcsets, PREG_SET_ORDER ) ) {
532
-                    foreach ( $allsrcsets as $srcset ) {
531
+                if (preg_match_all('#srcset=("|\')(.*)("|\')#Usmi', $tag, $allsrcsets, PREG_SET_ORDER)) {
532
+                    foreach ($allsrcsets as $srcset) {
533 533
                         $srcset  = $srcset[2];
534
-                        $srcsets = explode( ',', $srcset );
535
-                        foreach ( $srcsets as $indiv_srcset ) {
536
-                            $indiv_srcset_parts = explode( ' ', trim( $indiv_srcset ) );
537
-                            if ( $indiv_srcset_parts[1] && rtrim( $indiv_srcset_parts[1], 'w' ) !== $indiv_srcset_parts[1] ) {
538
-                                $imgopt_w = rtrim( $indiv_srcset_parts[1], 'w' );
534
+                        $srcsets = explode(',', $srcset);
535
+                        foreach ($srcsets as $indiv_srcset) {
536
+                            $indiv_srcset_parts = explode(' ', trim($indiv_srcset));
537
+                            if ($indiv_srcset_parts[1] && rtrim($indiv_srcset_parts[1], 'w') !== $indiv_srcset_parts[1]) {
538
+                                $imgopt_w = rtrim($indiv_srcset_parts[1], 'w');
539 539
                             }
540
-                            if ( $this->can_optimize_image( $indiv_srcset_parts[0] ) ) {
541
-                                $imgopt_url              = $this->build_imgopt_url( $indiv_srcset_parts[0], $imgopt_w, '' );
542
-                                $tag                     = str_replace( $indiv_srcset_parts[0], $imgopt_url, $tag );
543
-                                $to_replace[ $orig_tag ] = $tag;
540
+                            if ($this->can_optimize_image($indiv_srcset_parts[0])) {
541
+                                $imgopt_url              = $this->build_imgopt_url($indiv_srcset_parts[0], $imgopt_w, '');
542
+                                $tag                     = str_replace($indiv_srcset_parts[0], $imgopt_url, $tag);
543
+                                $to_replace[$orig_tag] = $tag;
544 544
                             }
545 545
                         }
546 546
                     }
@@ -550,45 +550,45 @@  discard block
 block discarded – undo
550 550
                 // first reset and then get width and height and add to $imgopt_size.
551 551
                 $imgopt_w = '';
552 552
                 $imgopt_h = '';
553
-                if ( preg_match( '#width=("|\')(.*)("|\')#Usmi', $tag, $width ) ) {
553
+                if (preg_match('#width=("|\')(.*)("|\')#Usmi', $tag, $width)) {
554 554
                     $imgopt_w = $width[2];
555 555
                 }
556
-                if ( preg_match( '#height=("|\')(.*)("|\')#Usmi', $tag, $height ) ) {
556
+                if (preg_match('#height=("|\')(.*)("|\')#Usmi', $tag, $height)) {
557 557
                     $imgopt_h = $height[2];
558 558
                 }
559 559
 
560 560
                 // then start replacing images src.
561
-                if ( preg_match_all( '#src=(?:"|\')(?!data)(.*)(?:"|\')#Usmi', $tag, $urls, PREG_SET_ORDER ) ) {
562
-                    foreach ( $urls as $url ) {
561
+                if (preg_match_all('#src=(?:"|\')(?!data)(.*)(?:"|\')#Usmi', $tag, $urls, PREG_SET_ORDER)) {
562
+                    foreach ($urls as $url) {
563 563
                         $full_src_orig = $url[0];
564 564
                         $url           = $url[1];
565
-                        if ( $this->can_optimize_image( $url ) ) {
566
-                            $imgopt_url              = $this->build_imgopt_url( $url, $imgopt_w, $imgopt_h );
567
-                            $full_imgopt_src         = str_replace( $url, $imgopt_url, $full_src_orig );
568
-                            $tag                     = str_replace( $full_src_orig, $full_imgopt_src, $tag );
569
-                            $to_replace[ $orig_tag ] = $tag;
565
+                        if ($this->can_optimize_image($url)) {
566
+                            $imgopt_url              = $this->build_imgopt_url($url, $imgopt_w, $imgopt_h);
567
+                            $full_imgopt_src         = str_replace($url, $imgopt_url, $full_src_orig);
568
+                            $tag                     = str_replace($full_src_orig, $full_imgopt_src, $tag);
569
+                            $to_replace[$orig_tag] = $tag;
570 570
                         }
571 571
                     }
572 572
                 }
573 573
             }
574 574
         }
575 575
 
576
-        $out = str_replace( array_keys( $to_replace ), array_values( $to_replace ), $in );
576
+        $out = str_replace(array_keys($to_replace), array_values($to_replace), $in);
577 577
 
578 578
         // img thumbnails in e.g. woocommerce.
579
-        if ( strpos( $out, 'data-thumb' ) !== false && apply_filters( 'autoptimize_filter_extra_imgopt_datathumbs', true ) ) {
579
+        if (strpos($out, 'data-thumb') !== false && apply_filters('autoptimize_filter_extra_imgopt_datathumbs', true)) {
580 580
             $out = preg_replace_callback(
581 581
                 '/\<div(?:[^>]?)\sdata-thumb\=(?:\"|\')(.+?)(?:\"|\')(?:[^>]*)?\>/s',
582
-                array( $this, 'replace_data_thumbs' ),
582
+                array($this, 'replace_data_thumbs'),
583 583
                 $out
584 584
             );
585 585
         }
586 586
 
587 587
         // background-image in inline style
588
-        if ( strpos( $out, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_extra_imgopt_backgroundimages', true ) ) {
588
+        if (strpos($out, 'background-image:') !== false && apply_filters('autoptimize_filter_extra_imgopt_backgroundimages', true)) {
589 589
             $out = preg_replace_callback(
590 590
                 '/style=(?:"|\').*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)/s',
591
-                array( $this, 'replace_img_callback' ),
591
+                array($this, 'replace_img_callback'),
592 592
                 $out
593 593
             );
594 594
         }
Please login to merge, or discard this patch.
classes/autoptimizeConfig.php 1 patch
Spacing   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if (!defined('ABSPATH')) exit; // Exit if accessed directly.
3 3
 
4 4
 class autoptimizeConfig
5 5
 {
@@ -13,28 +13,28 @@  discard block
 block discarded – undo
13 13
      */
14 14
     private function __construct()
15 15
     {
16
-        if ( is_admin() ) {
16
+        if (is_admin()) {
17 17
             // Add the admin page and settings.
18
-            add_action( 'admin_menu', array( $this, 'addmenu' ) );
19
-            add_action( 'admin_init', array( $this, 'registersettings' ) );
18
+            add_action('admin_menu', array($this, 'addmenu'));
19
+            add_action('admin_init', array($this, 'registersettings'));
20 20
 
21 21
             // Set meta info.
22
-            if ( function_exists( 'plugin_row_meta' ) ) {
22
+            if (function_exists('plugin_row_meta')) {
23 23
                 // 2.8 and higher.
24
-                add_filter( 'plugin_row_meta', array( $this, 'setmeta' ), 10, 2 );
25
-            } elseif ( function_exists( 'post_class' ) ) {
24
+                add_filter('plugin_row_meta', array($this, 'setmeta'), 10, 2);
25
+            } elseif (function_exists('post_class')) {
26 26
                 // 2.7 and lower.
27
-                $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' );
28
-                add_filter( 'plugin_action_links_' . $plugin, array( $this, 'setmeta' ) );
27
+                $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php');
28
+                add_filter('plugin_action_links_'.$plugin, array($this, 'setmeta'));
29 29
             }
30 30
 
31 31
             // Clean cache?
32
-            if ( get_option( 'autoptimize_cache_clean' ) ) {
32
+            if (get_option('autoptimize_cache_clean')) {
33 33
                 autoptimizeCache::clearall();
34
-                update_option( 'autoptimize_cache_clean', 0 );
34
+                update_option('autoptimize_cache_clean', 0);
35 35
             }
36 36
 
37
-            $this->settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http );
37
+            $this->settings_screen_do_remote_http = apply_filters('autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http);
38 38
         }
39 39
 
40 40
         // Adds the Autoptimize Toolbar to the Admin bar.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     static public function instance()
49 49
     {
50 50
         // Only one instance.
51
-        if ( null === self::$instance ) {
51
+        if (null === self::$instance) {
52 52
             self::$instance = new autoptimizeConfig();
53 53
         }
54 54
 
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
 
175 175
 <div class="wrap">
176 176
 
177
-<?php if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { ?>
178
-<div class="notice-error notice"><?php echo '<p>' . sprintf( __( '<strong>You are using a very old version of PHP</strong> (5.2.x or older) which has <a href=%s>serious security and performance issues</a>. Support for PHP 5.5 and below will be removed in one of the next AO released, please ask your hoster to provide you with an upgrade path to 7.x.', 'autoptimize' ), '"http://blog.futtta.be/2016/03/15/why-would-you-still-be-on-php-5-2/" target="_blank"' ) . '</p>'; ?></div>
177
+<?php if (version_compare(PHP_VERSION, '5.3.0') < 0) { ?>
178
+<div class="notice-error notice"><?php echo '<p>'.sprintf(__('<strong>You are using a very old version of PHP</strong> (5.2.x or older) which has <a href=%s>serious security and performance issues</a>. Support for PHP 5.5 and below will be removed in one of the next AO released, please ask your hoster to provide you with an upgrade path to 7.x.', 'autoptimize'), '"http://blog.futtta.be/2016/03/15/why-would-you-still-be-on-php-5-2/" target="_blank"').'</p>'; ?></div>
179 179
 <?php } ?>
180 180
 
181
-<?php if ( defined( 'AUTOPTIMIZE_LEGACY_MINIFIERS' ) ) { ?>
181
+<?php if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { ?>
182 182
     <div class="notice-error notice"><p>
183
-        <?php _e( "You are using the (no longer supported) AUTOPTIMIZE_LEGACY_MINIFIERS constant. Ensure your site is working properly and remove the constant, it doesn't do anything any more.", 'autoptimize' ); ?>
183
+        <?php _e("You are using the (no longer supported) AUTOPTIMIZE_LEGACY_MINIFIERS constant. Ensure your site is working properly and remove the constant, it doesn't do anything any more.", 'autoptimize'); ?>
184 184
     </p></div>
185 185
 <?php } ?>
186 186
 
187 187
 <!-- AO beta only. -->
188 188
 <div class="notice-info notice"><p>
189
-    <?php printf( __( 'Thanks for testing Autoptimize Beta! Please report any issues you might encounter in the %s.', 'autoptimize' ), '<a href="https://github.com/futtta/autoptimize/issues" target="_blank">GitHub Issues</a>' ); ?>
189
+    <?php printf(__('Thanks for testing Autoptimize Beta! Please report any issues you might encounter in the %s.', 'autoptimize'), '<a href="https://github.com/futtta/autoptimize/issues" target="_blank">GitHub Issues</a>'); ?>
190 190
 </p></div>
191 191
 
192 192
 <div id="autoptimize_main">
193 193
     <div id="ao_title_and_button">
194
-        <h1 id="ao_title"><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?>
194
+        <h1 id="ao_title"><?php _e('Autoptimize Settings', 'autoptimize'); ?>
195 195
         <span id="ao_adv_button">
196
-        <?php if ( get_option( 'autoptimize_show_adv', '0' ) == '1' ) { ?>
197
-            <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
198
-            <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
196
+        <?php if (get_option('autoptimize_show_adv', '0') == '1') { ?>
197
+            <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings", "autoptimize") ?></span></a>
198
+            <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings", "autoptimize") ?></span></a>
199 199
             <style>tr.ao_adv{display:table-row;} li.ao_adv{display:list-item;}</style>
200 200
             <?php $hiddenClass = ''; ?>
201 201
         <?php } else { ?>
202
-            <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
203
-            <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
202
+            <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings", "autoptimize") ?></span></a>
203
+            <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings", "autoptimize") ?></span></a>
204 204
             <?php $hiddenClass = 'hidden '; ?>
205 205
         <?php } ?>
206 206
         </span>
@@ -210,185 +210,185 @@  discard block
 block discarded – undo
210 210
     <?php echo $this->ao_admin_tabs(); ?>
211 211
 
212 212
 <form method="post" action="options.php">
213
-<?php settings_fields( 'autoptimize' ); ?>
213
+<?php settings_fields('autoptimize'); ?>
214 214
 
215 215
 <ul>
216 216
 
217 217
 <li class="itemDetail">
218
-<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2>
218
+<h2 class="itemTitle"><?php _e('HTML Options', 'autoptimize'); ?></h2>
219 219
 <table class="form-table">
220 220
 <tr valign="top">
221
-<th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th>
222
-<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
221
+<th scope="row"><?php _e('Optimize HTML Code?', 'autoptimize'); ?></th>
222
+<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html') ? 'checked="checked" ' : ''; ?>/></td>
223 223
 </tr>
224
-<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top">
225
-<th scope="row"><?php _e('Keep HTML comments?','autoptimize'); ?></th>
226
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
227
-<?php _e('Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td>
224
+<tr class="<?php echo $hiddenClass; ?>html_sub ao_adv" valign="top">
225
+<th scope="row"><?php _e('Keep HTML comments?', 'autoptimize'); ?></th>
226
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments') ? 'checked="checked" ' : ''; ?>/>
227
+<?php _e('Enable this if you want HTML comments to remain in the page.', 'autoptimize'); ?></label></td>
228 228
 </tr>
229 229
 </table>
230 230
 </li>
231 231
 
232 232
 <li class="itemDetail">
233
-<h2 class="itemTitle"><?php _e('JavaScript Options','autoptimize'); ?></h2>
233
+<h2 class="itemTitle"><?php _e('JavaScript Options', 'autoptimize'); ?></h2>
234 234
 <table class="form-table">
235 235
 <tr valign="top">
236
-<th scope="row"><?php _e('Optimize JavaScript Code?','autoptimize'); ?></th>
237
-<td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
236
+<th scope="row"><?php _e('Optimize JavaScript Code?', 'autoptimize'); ?></th>
237
+<td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js') ? 'checked="checked" ' : ''; ?>/></td>
238 238
 </tr>
239
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
240
-<th scope="row"><?php _e( 'Aggregate JS-files?', 'autoptimize' ); ?></th>
241
-<td><label class="cb_label"><input type="checkbox" id="autoptimize_js_aggregate" name="autoptimize_js_aggregate" <?php echo $conf->get( 'autoptimize_js_aggregate' ) ? 'checked="checked" ':''; ?>/>
242
-<?php _e( 'Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'autoptimize' ); ?></label></td>
239
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv">
240
+<th scope="row"><?php _e('Aggregate JS-files?', 'autoptimize'); ?></th>
241
+<td><label class="cb_label"><input type="checkbox" id="autoptimize_js_aggregate" name="autoptimize_js_aggregate" <?php echo $conf->get('autoptimize_js_aggregate') ? 'checked="checked" ' : ''; ?>/>
242
+<?php _e('Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'autoptimize'); ?></label></td>
243 243
 </tr>
244
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
245
-<th scope="row"><?php _e('Also aggregate inline JS?','autoptimize'); ?></th>
246
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline')?'checked="checked" ':''; ?>/>
247
-<?php _e('Let Autoptimize also extract JS from the HTML. <strong>Warning</strong>: this can make Autoptimize\'s cache size grow quickly, so only enable this if you know what you\'re doing.','autoptimize'); ?></label></td>
244
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate">
245
+<th scope="row"><?php _e('Also aggregate inline JS?', 'autoptimize'); ?></th>
246
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline') ? 'checked="checked" ' : ''; ?>/>
247
+<?php _e('Let Autoptimize also extract JS from the HTML. <strong>Warning</strong>: this can make Autoptimize\'s cache size grow quickly, so only enable this if you know what you\'re doing.', 'autoptimize'); ?></label></td>
248 248
 </tr>
249
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
250
-<th scope="row"><?php _e('Force JavaScript in &lt;head&gt;?','autoptimize'); ?></th>
251
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/>
252
-<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.','autoptimize'); ?></label></td>
249
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate">
250
+<th scope="row"><?php _e('Force JavaScript in &lt;head&gt;?', 'autoptimize'); ?></th>
251
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead') ? 'checked="checked" ' : ''; ?>/>
252
+<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.', 'autoptimize'); ?></label></td>
253 253
 </tr>
254 254
 <?php if (get_option('autoptimize_js_justhead')) { ?>
255
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
256
-<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
257
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
258
-<?php _e('Mostly useful in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.','autoptimize'); ?></label></td>
255
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate">
256
+<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?', 'autoptimize'); echo ' <i>'.__('(deprecated)', 'autoptimize').'</i>'; ?></th>
257
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead') ? 'checked="checked" ' : ''; ?>/>
258
+<?php _e('Mostly useful in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.', 'autoptimize'); ?></label></td>
259 259
 </tr>
260 260
 <?php } ?>
261
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
262
-<th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th>
263
-<td><label><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"seal.js, js/jquery/jquery.js"); ?>"/><br />
264
-<?php _e('A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated by Autoptimize.','autoptimize'); ?></label></td>
261
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate">
262
+<th scope="row"><?php _e('Exclude scripts from Autoptimize:', 'autoptimize'); ?></th>
263
+<td><label><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude', "seal.js, js/jquery/jquery.js"); ?>"/><br />
264
+<?php _e('A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated by Autoptimize.', 'autoptimize'); ?></label></td>
265 265
 </tr>
266
-<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
267
-<th scope="row"><?php _e('Add try-catch wrapping?','autoptimize'); ?></th>
268
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/>
269
-<?php _e('If your scripts break because of a JS-error, you might want to try this.','autoptimize'); ?></label></td>
266
+<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate">
267
+<th scope="row"><?php _e('Add try-catch wrapping?', 'autoptimize'); ?></th>
268
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch') ? 'checked="checked" ' : ''; ?>/>
269
+<?php _e('If your scripts break because of a JS-error, you might want to try this.', 'autoptimize'); ?></label></td>
270 270
 </tr>
271 271
 </table>
272 272
 </li>
273 273
 
274 274
 <li class="itemDetail">
275
-<h2 class="itemTitle"><?php _e('CSS Options','autoptimize'); ?></h2>
275
+<h2 class="itemTitle"><?php _e('CSS Options', 'autoptimize'); ?></h2>
276 276
 <table class="form-table">
277 277
 <tr valign="top">
278
-<th scope="row"><?php _e('Optimize CSS Code?','autoptimize'); ?></th>
279
-<td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
278
+<th scope="row"><?php _e('Optimize CSS Code?', 'autoptimize'); ?></th>
279
+<td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css') ? 'checked="checked" ' : ''; ?>/></td>
280 280
 </tr>
281
-<tr class="<?php echo $hiddenClass;?>css_sub ao_adv" valign="top">
282
-<th scope="row"><?php _e( 'Aggregate CSS-files?', 'autoptimize' ); ?></th>
283
-<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_aggregate" name="autoptimize_css_aggregate" <?php echo $conf->get( 'autoptimize_css_aggregate' ) ? 'checked="checked" ' : ''; ?>/>
284
-<?php _e('Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'autoptimize' ); ?></label></td>
281
+<tr class="<?php echo $hiddenClass; ?>css_sub ao_adv" valign="top">
282
+<th scope="row"><?php _e('Aggregate CSS-files?', 'autoptimize'); ?></th>
283
+<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_aggregate" name="autoptimize_css_aggregate" <?php echo $conf->get('autoptimize_css_aggregate') ? 'checked="checked" ' : ''; ?>/>
284
+<?php _e('Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'autoptimize'); ?></label></td>
285 285
 </tr>
286
-<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate">
287
-<th scope="row"><?php _e('Also aggregate inline CSS?','autoptimize'); ?></th>
288
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline','1')?'checked="checked" ':''; ?>/>
289
-<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.','autoptimize'); ?></label></td>
286
+<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate">
287
+<th scope="row"><?php _e('Also aggregate inline CSS?', 'autoptimize'); ?></th>
288
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline', '1') ? 'checked="checked" ' : ''; ?>/>
289
+<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.', 'autoptimize'); ?></label></td>
290 290
 </tr>
291
-<tr class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate" valign="top">
292
-<th scope="row"><?php _e('Generate data: URIs for images?','autoptimize'); ?></th>
293
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/>
294
-<?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.','autoptimize'); ?></label></td>
291
+<tr class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate" valign="top">
292
+<th scope="row"><?php _e('Generate data: URIs for images?', 'autoptimize'); ?></th>
293
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris') ? 'checked="checked" ' : ''; ?>/>
294
+<?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.', 'autoptimize'); ?></label></td>
295 295
 </tr>
296 296
 <?php if (get_option('autoptimize_css_justhead')) { ?>
297
-<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate">
298
-<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
299
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
300
-<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
297
+<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate">
298
+<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?', 'autoptimize'); echo ' <i>'.__('(deprecated)', 'autoptimize').'</i>'; ?></th>
299
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead') ? 'checked="checked" ' : ''; ?>/>
300
+<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.', 'autoptimize'); ?></label></td>
301 301
 </tr>
302 302
 <?php } ?>
303
-<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
304
-<th scope="row"><?php _e('Inline and Defer CSS?','autoptimize'); ?></th>
305
-<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_defer" id="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer')?'checked="checked" ':''; ?>/>
303
+<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv">
304
+<th scope="row"><?php _e('Inline and Defer CSS?', 'autoptimize'); ?></th>
305
+<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_defer" id="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer') ? 'checked="checked" ' : ''; ?>/>
306 306
 <?php
307
-_e( 'Inline "above the fold CSS" while loading the main autoptimized CSS only after page load. <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">Check the FAQ</a> for more info.', 'autoptimize' );
308
-if ( function_exists( 'is_plugin_active' ) && ! is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) {
307
+_e('Inline "above the fold CSS" while loading the main autoptimized CSS only after page load. <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">Check the FAQ</a> for more info.', 'autoptimize');
308
+if (function_exists('is_plugin_active') && !is_plugin_active('autoptimize-criticalcss/ao_criticss_aas.php')) {
309 309
     echo ' ';
310
-    $critcss_install_url = network_admin_url() . 'plugin-install.php?s=autoptimize+criticalcss&tab=search&type=term';
311
-    echo sprintf( __( 'This can be fully automated for different types of pages with the %s.', 'autoptimize' ), '<a href="'.$critcss_install_url.'">Autoptimize CriticalCSS Power-Up</a>' );
310
+    $critcss_install_url = network_admin_url().'plugin-install.php?s=autoptimize+criticalcss&tab=search&type=term';
311
+    echo sprintf(__('This can be fully automated for different types of pages with the %s.', 'autoptimize'), '<a href="'.$critcss_install_url.'">Autoptimize CriticalCSS Power-Up</a>');
312 312
 }
313 313
 ?>
314 314
 </label></td>
315 315
 </tr>
316
-<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv" id="autoptimize_css_defer_inline">
316
+<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv" id="autoptimize_css_defer_inline">
317 317
 <th scope="row"></th>
318
-<td><label><textarea rows="10" cols="10" style="width:100%;" placeholder="<?php _e('Paste the above the fold CSS here.','autoptimize'); ?>" name="autoptimize_css_defer_inline"><?php echo get_option('autoptimize_css_defer_inline'); ?></textarea></label></td>
318
+<td><label><textarea rows="10" cols="10" style="width:100%;" placeholder="<?php _e('Paste the above the fold CSS here.', 'autoptimize'); ?>" name="autoptimize_css_defer_inline"><?php echo get_option('autoptimize_css_defer_inline'); ?></textarea></label></td>
319 319
 </tr>
320
-<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub css_aggregate">
321
-<th scope="row"><?php _e('Inline all CSS?','autoptimize'); ?></th>
322
-<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_inline" name="autoptimize_css_inline" <?php echo get_option('autoptimize_css_inline')?'checked="checked" ':''; ?>/>
323
-<?php _e('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.','autoptimize'); ?></label></td>
320
+<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv css_sub css_aggregate">
321
+<th scope="row"><?php _e('Inline all CSS?', 'autoptimize'); ?></th>
322
+<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_inline" name="autoptimize_css_inline" <?php echo get_option('autoptimize_css_inline') ? 'checked="checked" ' : ''; ?>/>
323
+<?php _e('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.', 'autoptimize'); ?></label></td>
324 324
 </tr>
325
-<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub css_aggregate">
326
-<th scope="row"><?php _e('Exclude CSS from Autoptimize:','autoptimize'); ?></th>
327
-<td><label><input type="text" style="width:100%;" name="autoptimize_css_exclude" value="<?php echo get_option('autoptimize_css_exclude','wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'); ?>"/><br />
328
-<?php _e('A comma-separated list of CSS you want to exclude from being optimized.','autoptimize'); ?></label></td>
325
+<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv css_sub css_aggregate">
326
+<th scope="row"><?php _e('Exclude CSS from Autoptimize:', 'autoptimize'); ?></th>
327
+<td><label><input type="text" style="width:100%;" name="autoptimize_css_exclude" value="<?php echo get_option('autoptimize_css_exclude', 'wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'); ?>"/><br />
328
+<?php _e('A comma-separated list of CSS you want to exclude from being optimized.', 'autoptimize'); ?></label></td>
329 329
 </tr>
330 330
 </table>
331 331
 </li>
332 332
 
333 333
 <li class="itemDetail">
334
-<h2 class="itemTitle"><?php _e('CDN Options','autoptimize'); ?></h2>
334
+<h2 class="itemTitle"><?php _e('CDN Options', 'autoptimize'); ?></h2>
335 335
 <table class="form-table">
336 336
 <tr valign="top">
337
-<th scope="row"><?php _e('CDN Base URL','autoptimize'); ?></th>
338
-<td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" value="<?php echo esc_url(get_option('autoptimize_cdn_url',''),array("http","https")); ?>" /><br />
339
-<?php _e('Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative (e.g. <code>//cdn.example.com/</code>). This is not needed for Cloudflare.','autoptimize'); ?></label></td>
337
+<th scope="row"><?php _e('CDN Base URL', 'autoptimize'); ?></th>
338
+<td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" value="<?php echo esc_url(get_option('autoptimize_cdn_url', ''), array("http", "https")); ?>" /><br />
339
+<?php _e('Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative (e.g. <code>//cdn.example.com/</code>). This is not needed for Cloudflare.', 'autoptimize'); ?></label></td>
340 340
 </tr>
341 341
 </table>
342 342
 </li>
343 343
 
344
-<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
345
-<h2 class="itemTitle"><?php _e('Cache Info','autoptimize'); ?></h2>
344
+<li class="<?php echo $hiddenClass; ?>itemDetail ao_adv">
345
+<h2 class="itemTitle"><?php _e('Cache Info', 'autoptimize'); ?></h2>
346 346
 <table class="form-table" >
347
-<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
348
-<th scope="row"><?php _e('Cache folder','autoptimize'); ?></th>
347
+<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
348
+<th scope="row"><?php _e('Cache folder', 'autoptimize'); ?></th>
349 349
 <td><?php echo htmlentities(AUTOPTIMIZE_CACHE_DIR); ?></td>
350 350
 </tr>
351
-<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
352
-<th scope="row"><?php _e('Can we write?','autoptimize'); ?></th>
353
-<td><?php echo (autoptimizeCache::cacheavail() ? __('Yes','autoptimize') : __('No','autoptimize')); ?></td>
351
+<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
352
+<th scope="row"><?php _e('Can we write?', 'autoptimize'); ?></th>
353
+<td><?php echo (autoptimizeCache::cacheavail() ? __('Yes', 'autoptimize') : __('No', 'autoptimize')); ?></td>
354 354
 </tr>
355
-<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
356
-<th scope="row"><?php _e('Cached styles and scripts','autoptimize'); ?></th>
355
+<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
356
+<th scope="row"><?php _e('Cached styles and scripts', 'autoptimize'); ?></th>
357 357
 <td><?php
358 358
     $AOstatArr = autoptimizeCache::stats();
359
-    if ( ! empty( $AOstatArr ) && is_array( $AOstatArr ) ) {
360
-        $AOcacheSize = size_format( $AOstatArr[1], 2 );
359
+    if (!empty($AOstatArr) && is_array($AOstatArr)) {
360
+        $AOcacheSize = size_format($AOstatArr[1], 2);
361 361
         $details = '';
362
-        if ( $AOcacheSize > 0 ) {
363
-            $details = ', ~' . $AOcacheSize . ' total';
362
+        if ($AOcacheSize > 0) {
363
+            $details = ', ~'.$AOcacheSize.' total';
364 364
         }
365
-        printf( __( '%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize' ), $AOstatArr[0], $AOcacheSize, date( 'H:i e', $AOstatArr[2] ) );
365
+        printf(__('%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize'), $AOstatArr[0], $AOcacheSize, date('H:i e', $AOstatArr[2]));
366 366
     }
367 367
 ?></td>
368 368
 </tr>
369 369
 </table>
370 370
 </li>
371 371
 
372
-<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
373
-<h2 class="itemTitle"><?php _e('Misc Options','autoptimize'); ?></h2>
372
+<li class="<?php echo $hiddenClass; ?>itemDetail ao_adv">
373
+<h2 class="itemTitle"><?php _e('Misc Options', 'autoptimize'); ?></h2>
374 374
 <table class="form-table">
375
-    <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
376
-    <th scope="row"><?php _e('Save aggregated script/css as static files?','autoptimize'); ?></th>
377
-    <td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip','1')?'checked="checked" ':''; ?>/>
378
-    <?php _e('By default files saved are static css/js, uncheck this option if your webserver doesn\'t properly handle the compression and expiry.','autoptimize'); ?></label></td>
375
+    <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
376
+    <th scope="row"><?php _e('Save aggregated script/css as static files?', 'autoptimize'); ?></th>
377
+    <td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip', '1') ? 'checked="checked" ' : ''; ?>/>
378
+    <?php _e('By default files saved are static css/js, uncheck this option if your webserver doesn\'t properly handle the compression and expiry.', 'autoptimize'); ?></label></td>
379 379
     </tr>
380
-    <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
381
-    <th scope="row"><?php _e('Also optimize for logged in users?','autoptimize'); ?></th>
382
-    <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged','1')?'checked="checked" ':''; ?>/>
383
-    <?php _e('By default Autoptimize is also active for logged on users, uncheck not to optimize when logged in e.g. to use a pagebuilder.','autoptimize'); ?></label></td>
380
+    <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
381
+    <th scope="row"><?php _e('Also optimize for logged in users?', 'autoptimize'); ?></th>
382
+    <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged', '1') ? 'checked="checked" ' : ''; ?>/>
383
+    <?php _e('By default Autoptimize is also active for logged on users, uncheck not to optimize when logged in e.g. to use a pagebuilder.', 'autoptimize'); ?></label></td>
384 384
     </tr>
385 385
     <?php
386
-    if ( function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout") ) {
386
+    if (function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout")) {
387 387
     ?>
388
-    <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
389
-        <th scope="row"><?php _e('Also optimize shop cart/ checkout?','autoptimize'); ?></th>
390
-        <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout','1')?'checked="checked" ':''; ?>/>
391
-            <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.','autoptimize'); ?></label>
388
+    <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv">
389
+        <th scope="row"><?php _e('Also optimize shop cart/ checkout?', 'autoptimize'); ?></th>
390
+        <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout', '1') ? 'checked="checked" ' : ''; ?>/>
391
+            <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.', 'autoptimize'); ?></label>
392 392
         </td>
393 393
     </tr>
394 394
     <?php } ?>
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 
398 398
 </ul>
399 399
 
400
-<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','0'); ?>">
400
+<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv', '0'); ?>">
401 401
 
402 402
 <p class="submit">
403
-<input type="submit" class="button-secondary" value="<?php _e('Save Changes','autoptimize') ?>" />
404
-<input type="submit" class="button-primary" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache','autoptimize') ?>" />
403
+<input type="submit" class="button-secondary" value="<?php _e('Save Changes', 'autoptimize') ?>" />
404
+<input type="submit" class="button-primary" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache', 'autoptimize') ?>" />
405 405
 </p>
406 406
 
407 407
 </form>
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
     <div class="autoptimize_banner hidden">
411 411
       <ul>
412 412
     <?php
413
-    if ( $this->settings_screen_do_remote_http ) {
414
-        $AO_banner = get_transient( 'autoptimize_banner' );
415
-        if ( empty( $AO_banner ) ) {
416
-            $banner_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION );
417
-            if ( ! is_wp_error( $banner_resp ) ) {
418
-                if ( '200' == wp_remote_retrieve_response_code( $banner_resp ) ) {
419
-                    $AO_banner = wp_kses_post( wp_remote_retrieve_body( $banner_resp ) );
413
+    if ($this->settings_screen_do_remote_http) {
414
+        $AO_banner = get_transient('autoptimize_banner');
415
+        if (empty($AO_banner)) {
416
+            $banner_resp = wp_remote_get('https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION);
417
+            if (!is_wp_error($banner_resp)) {
418
+                if ('200' == wp_remote_retrieve_response_code($banner_resp)) {
419
+                    $AO_banner = wp_kses_post(wp_remote_retrieve_body($banner_resp));
420 420
                     set_transient('autoptimize_banner', $AO_banner, DAY_IN_SECONDS);
421 421
                 }
422 422
             }
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
         echo $AO_banner;
425 425
     }
426 426
     ?>
427
-        <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.","autoptimize"); ?></li>
428
-        <li><?php _e("Happy with Autoptimize?","autoptimize"); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e("Try my other plugins!","autoptimize"); ?></a></li>
427
+        <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.", "autoptimize"); ?></li>
428
+        <li><?php _e("Happy with Autoptimize?", "autoptimize"); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e("Try my other plugins!", "autoptimize"); ?></a></li>
429 429
     </ul>
430 430
     </div>
431 431
     <div style="margin-left:10px;margin-top:-5px;">
432 432
         <h2>
433
-            <?php _e("futtta about","autoptimize") ?>
433
+            <?php _e("futtta about", "autoptimize") ?>
434 434
             <select id="feed_dropdown" >
435
-                <option value="1"><?php _e("Autoptimize","autoptimize") ?></option>
436
-                <option value="2"><?php _e("WordPress","autoptimize") ?></option>
437
-                <option value="3"><?php _e("Web Technology","autoptimize") ?></option>
435
+                <option value="1"><?php _e("Autoptimize", "autoptimize") ?></option>
436
+                <option value="2"><?php _e("WordPress", "autoptimize") ?></option>
437
+                <option value="3"><?php _e("Web Technology", "autoptimize") ?></option>
438 438
             </select>
439 439
         </h2>
440 440
         <div id="futtta_feed">
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             </div>
450 450
         </div>
451 451
     </div>
452
-    <div style="float:right;margin:50px 15px;"><a href="http://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url().'/'.plugin_basename(dirname(__FILE__)).'/external/do_not_donate_smallest.png'; ?>" title="<?php _e("Do not donate for this plugin!","autoptimize"); ?>"></a></div>
452
+    <div style="float:right;margin:50px 15px;"><a href="http://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url().'/'.plugin_basename(dirname(__FILE__)).'/external/do_not_donate_smallest.png'; ?>" title="<?php _e("Do not donate for this plugin!", "autoptimize"); ?>"></a></div>
453 453
 </div>
454 454
 
455 455
 <script type="text/javascript">
@@ -612,48 +612,48 @@  discard block
 block discarded – undo
612 612
 
613 613
     public function addmenu()
614 614
     {
615
-        $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show' ) );
616
-        add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
617
-        add_action( 'admin_print_styles-' . $hook, array( $this, 'autoptimize_admin_styles' ) );
615
+        $hook = add_options_page(__('Autoptimize Options', 'autoptimize'), 'Autoptimize', 'manage_options', 'autoptimize', array($this, 'show'));
616
+        add_action('admin_print_scripts-'.$hook, array($this, 'autoptimize_admin_scripts'));
617
+        add_action('admin_print_styles-'.$hook, array($this, 'autoptimize_admin_styles'));
618 618
     }
619 619
 
620 620
     public function autoptimize_admin_scripts()
621 621
     {
622
-        wp_enqueue_script( 'jqcookie', plugins_url( '/external/js/jquery.cookie.min.js', __FILE__ ), array( 'jquery' ), null, true );
623
-        wp_enqueue_script( 'unslider', plugins_url( '/external/js/unslider-min.js', __FILE__ ), array( 'jquery' ), null, true );
622
+        wp_enqueue_script('jqcookie', plugins_url('/external/js/jquery.cookie.min.js', __FILE__), array('jquery'), null, true);
623
+        wp_enqueue_script('unslider', plugins_url('/external/js/unslider-min.js', __FILE__), array('jquery'), null, true);
624 624
     }
625 625
 
626 626
     public function autoptimize_admin_styles()
627 627
     {
628
-        wp_enqueue_style( 'unslider', plugins_url( '/external/js/unslider.css', __FILE__ ) );
629
-        wp_enqueue_style( 'unslider-dots', plugins_url( '/external/js/unslider-dots.css', __FILE__ ) );
628
+        wp_enqueue_style('unslider', plugins_url('/external/js/unslider.css', __FILE__));
629
+        wp_enqueue_style('unslider-dots', plugins_url('/external/js/unslider-dots.css', __FILE__));
630 630
     }
631 631
 
632 632
     public function registersettings() {
633
-        register_setting( 'autoptimize', 'autoptimize_html' );
634
-        register_setting( 'autoptimize', 'autoptimize_html_keepcomments' );
635
-        register_setting( 'autoptimize', 'autoptimize_js' );
636
-        register_setting( 'autoptimize', 'autoptimize_js_aggregate' );
637
-        register_setting( 'autoptimize', 'autoptimize_js_exclude' );
638
-        register_setting( 'autoptimize', 'autoptimize_js_trycatch' );
639
-        register_setting( 'autoptimize', 'autoptimize_js_justhead' );
640
-        register_setting( 'autoptimize', 'autoptimize_js_forcehead' );
641
-        register_setting( 'autoptimize', 'autoptimize_js_include_inline' );
642
-        register_setting( 'autoptimize', 'autoptimize_css' );
643
-        register_setting( 'autoptimize', 'autoptimize_css_aggregate' );
644
-        register_setting( 'autoptimize', 'autoptimize_css_exclude' );
645
-        register_setting( 'autoptimize', 'autoptimize_css_justhead' );
646
-        register_setting( 'autoptimize', 'autoptimize_css_datauris' );
647
-        register_setting( 'autoptimize', 'autoptimize_css_defer' );
648
-        register_setting( 'autoptimize', 'autoptimize_css_defer_inline' );
649
-        register_setting( 'autoptimize', 'autoptimize_css_inline' );
650
-        register_setting( 'autoptimize', 'autoptimize_css_include_inline' );
651
-        register_setting( 'autoptimize', 'autoptimize_cdn_url' );
652
-        register_setting( 'autoptimize', 'autoptimize_cache_clean' );
653
-        register_setting( 'autoptimize', 'autoptimize_cache_nogzip' );
654
-        register_setting( 'autoptimize', 'autoptimize_show_adv' );
655
-        register_setting( 'autoptimize', 'autoptimize_optimize_logged' );
656
-        register_setting( 'autoptimize', 'autoptimize_optimize_checkout' );
633
+        register_setting('autoptimize', 'autoptimize_html');
634
+        register_setting('autoptimize', 'autoptimize_html_keepcomments');
635
+        register_setting('autoptimize', 'autoptimize_js');
636
+        register_setting('autoptimize', 'autoptimize_js_aggregate');
637
+        register_setting('autoptimize', 'autoptimize_js_exclude');
638
+        register_setting('autoptimize', 'autoptimize_js_trycatch');
639
+        register_setting('autoptimize', 'autoptimize_js_justhead');
640
+        register_setting('autoptimize', 'autoptimize_js_forcehead');
641
+        register_setting('autoptimize', 'autoptimize_js_include_inline');
642
+        register_setting('autoptimize', 'autoptimize_css');
643
+        register_setting('autoptimize', 'autoptimize_css_aggregate');
644
+        register_setting('autoptimize', 'autoptimize_css_exclude');
645
+        register_setting('autoptimize', 'autoptimize_css_justhead');
646
+        register_setting('autoptimize', 'autoptimize_css_datauris');
647
+        register_setting('autoptimize', 'autoptimize_css_defer');
648
+        register_setting('autoptimize', 'autoptimize_css_defer_inline');
649
+        register_setting('autoptimize', 'autoptimize_css_inline');
650
+        register_setting('autoptimize', 'autoptimize_css_include_inline');
651
+        register_setting('autoptimize', 'autoptimize_cdn_url');
652
+        register_setting('autoptimize', 'autoptimize_cache_clean');
653
+        register_setting('autoptimize', 'autoptimize_cache_nogzip');
654
+        register_setting('autoptimize', 'autoptimize_show_adv');
655
+        register_setting('autoptimize', 'autoptimize_optimize_logged');
656
+        register_setting('autoptimize', 'autoptimize_optimize_checkout');
657 657
     }
658 658
 
659 659
     public function setmeta($links, $file = null)
@@ -661,20 +661,20 @@  discard block
 block discarded – undo
661 661
         // Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/.
662 662
         // Do it only once - saves time.
663 663
         static $plugin;
664
-        if ( empty( $plugin ) ) {
665
-            $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' );
664
+        if (empty($plugin)) {
665
+            $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php');
666 666
         }
667 667
 
668
-        if ( null === $file ) {
668
+        if (null === $file) {
669 669
             // 2.7 and lower.
670
-            $settings_link = sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) );
671
-            array_unshift( $links, $settings_link );
670
+            $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
671
+            array_unshift($links, $settings_link);
672 672
         } else {
673 673
             // 2.8 and higher.
674 674
             // If it's us, add the link.
675
-            if ( $file === $plugin ) {
676
-                $newlink = array( sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) ) );
677
-                $links = array_merge( $links, $newlink );
675
+            if ($file === $plugin) {
676
+                $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings')));
677
+                $links = array_merge($links, $newlink);
678 678
             }
679 679
         }
680 680
 
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
      */
743 743
     public static function get_ao_css_preload_polyfill()
744 744
     {
745
-        $preload_poly = apply_filters('autoptimize_css_preload_polyfill','<script data-cfasync=\'false\'>!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={};if(e.support=function(){var e;try{e=t.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),e.bindMediaToggle=function(t){function e(){t.media=a}var a=t.media||"all";t.addEventListener?t.addEventListener("load",e):t.attachEvent&&t.attachEvent("onload",e),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(e,3e3)},e.poly=function(){if(!e.support())for(var a=t.document.getElementsByTagName("link"),n=0;n<a.length;n++){var o=a[n];"preload"!==o.rel||"style"!==o.getAttribute("as")||o.getAttribute("data-loadcss")||(o.setAttribute("data-loadcss",!0),e.bindMediaToggle(o))}},!e.support()){e.poly();var a=t.setInterval(e.poly,500);t.addEventListener?t.addEventListener("load",function(){e.poly(),t.clearInterval(a)}):t.attachEvent&&t.attachEvent("onload",function(){e.poly(),t.clearInterval(a)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:t.loadCSS=loadCSS}("undefined"!=typeof global?global:this);</script>');
745
+        $preload_poly = apply_filters('autoptimize_css_preload_polyfill', '<script data-cfasync=\'false\'>!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={};if(e.support=function(){var e;try{e=t.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),e.bindMediaToggle=function(t){function e(){t.media=a}var a=t.media||"all";t.addEventListener?t.addEventListener("load",e):t.attachEvent&&t.attachEvent("onload",e),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(e,3e3)},e.poly=function(){if(!e.support())for(var a=t.document.getElementsByTagName("link"),n=0;n<a.length;n++){var o=a[n];"preload"!==o.rel||"style"!==o.getAttribute("as")||o.getAttribute("data-loadcss")||(o.setAttribute("data-loadcss",!0),e.bindMediaToggle(o))}},!e.support()){e.poly();var a=t.setInterval(e.poly,500);t.addEventListener?t.addEventListener("load",function(){e.poly(),t.clearInterval(a)}):t.attachEvent&&t.attachEvent("onload",function(){e.poly(),t.clearInterval(a)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:t.loadCSS=loadCSS}("undefined"!=typeof global?global:this);</script>');
746 746
         return $preload_poly;
747 747
     }
748 748
 
@@ -753,55 +753,55 @@  discard block
 block discarded – undo
753 753
      */
754 754
     public static function get_ao_css_preload_onload()
755 755
     {
756
-        $preload_onload = apply_filters('autoptimize_filter_css_preload_onload',"this.onload=null;this.rel='stylesheet'");
756
+        $preload_onload = apply_filters('autoptimize_filter_css_preload_onload', "this.onload=null;this.rel='stylesheet'");
757 757
         return $preload_onload;
758 758
     }
759 759
 
760 760
     public function get($key)
761 761
     {
762
-        if ( ! is_array( $this->config ) ) {
762
+        if (!is_array($this->config)) {
763 763
             // Default config.
764 764
             $config = self::get_defaults();
765 765
 
766 766
             // Override with user settings.
767
-            foreach ( array_keys( $config ) as $name ) {
768
-                $conf = get_option( $name );
769
-                if ( false !== $conf ) {
767
+            foreach (array_keys($config) as $name) {
768
+                $conf = get_option($name);
769
+                if (false !== $conf) {
770 770
                     // It was set before!
771
-                    $config[ $name ] = $conf;
771
+                    $config[$name] = $conf;
772 772
                 }
773 773
             }
774 774
 
775 775
             // Save for next call.
776
-            $this->config = apply_filters( 'autoptimize_filter_get_config', $config );
776
+            $this->config = apply_filters('autoptimize_filter_get_config', $config);
777 777
         }
778 778
 
779
-        if ( isset( $this->config[ $key ] ) ) {
780
-            return $this->config[ $key ];
779
+        if (isset($this->config[$key])) {
780
+            return $this->config[$key];
781 781
         }
782 782
 
783 783
         return false;
784 784
     }
785 785
 
786 786
     private function getFutttaFeeds($url) {
787
-        if ( $this->settings_screen_do_remote_http ) {
788
-            $rss = fetch_feed( $url );
787
+        if ($this->settings_screen_do_remote_http) {
788
+            $rss = fetch_feed($url);
789 789
             $maxitems = 0;
790 790
 
791
-            if ( ! is_wp_error( $rss ) ) {
792
-                $maxitems = $rss->get_item_quantity( 7 );
793
-                $rss_items = $rss->get_items( 0, $maxitems );
791
+            if (!is_wp_error($rss)) {
792
+                $maxitems = $rss->get_item_quantity(7);
793
+                $rss_items = $rss->get_items(0, $maxitems);
794 794
             }
795 795
             ?>
796 796
             <ul>
797
-                <?php if ( $maxitems == 0 ) : ?>
798
-                    <li><?php _e( 'No items', 'autoptimize' ); ?></li>
797
+                <?php if ($maxitems == 0) : ?>
798
+                    <li><?php _e('No items', 'autoptimize'); ?></li>
799 799
                 <?php else : ?>
800
-                    <?php foreach ( $rss_items as $item ) : ?>
800
+                    <?php foreach ($rss_items as $item) : ?>
801 801
                         <li>
802
-                            <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
803
-                                title="<?php printf( __( 'Posted %s', 'autoptimize' ), $item->get_date('j F Y | g:i a') ); ?>">
804
-                                <?php echo esc_html( $item->get_title() ); ?>
802
+                            <a href="<?php echo esc_url($item->get_permalink()); ?>"
803
+                                title="<?php printf(__('Posted %s', 'autoptimize'), $item->get_date('j F Y | g:i a')); ?>">
804
+                                <?php echo esc_html($item->get_title()); ?>
805 805
                             </a>
806 806
                         </li>
807 807
                     <?php endforeach; ?>
@@ -814,23 +814,23 @@  discard block
 block discarded – undo
814 814
     // based on http://wordpress.stackexchange.com/a/58826
815 815
     static function ao_admin_tabs()
816 816
     {
817
-        $tabs = apply_filters( 'autoptimize_filter_settingsscreen_tabs' ,array( 'autoptimize' => __( 'Main', 'autoptimize' ) ) );
817
+        $tabs = apply_filters('autoptimize_filter_settingsscreen_tabs', array('autoptimize' => __('Main', 'autoptimize')));
818 818
         $tabContent = '';
819 819
         $tabs_count = count($tabs);
820
-        if ( $tabs_count > 1 ) {
821
-            if ( isset( $_GET['page'] ) ) {
820
+        if ($tabs_count > 1) {
821
+            if (isset($_GET['page'])) {
822 822
                 $currentId = $_GET['page'];
823 823
             } else {
824 824
                 $currentId = "autoptimize";
825 825
             }
826 826
             $tabContent .= '<h2 class="nav-tab-wrapper">';
827 827
             foreach ($tabs as $tabId => $tabName) {
828
-                if ( $currentId == $tabId ) {
828
+                if ($currentId == $tabId) {
829 829
                     $class = ' nav-tab-active';
830
-                } else{
830
+                } else {
831 831
                     $class = '';
832 832
                 }
833
-                $tabContent .= '<a class="nav-tab' . $class . '" href="?page=' . $tabId . '">' . $tabName . '</a>';
833
+                $tabContent .= '<a class="nav-tab'.$class.'" href="?page='.$tabId.'">'.$tabName.'</a>';
834 834
             }
835 835
             $tabContent .= '</h2>';
836 836
         } else {
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
      */
848 848
     public static function is_admin_and_not_ajax()
849 849
     {
850
-        return ( is_admin() && ! self::doing_ajax() );
850
+        return (is_admin() && !self::doing_ajax());
851 851
     }
852 852
 
853 853
     /**
@@ -857,10 +857,10 @@  discard block
 block discarded – undo
857 857
      */
858 858
     protected static function doing_ajax()
859 859
     {
860
-        if ( function_exists( 'wp_doing_ajax' ) ) {
860
+        if (function_exists('wp_doing_ajax')) {
861 861
             return wp_doing_ajax();
862 862
         } else {
863
-            return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
863
+            return (defined('DOING_AJAX') && DOING_AJAX);
864 864
         }
865 865
     }
866 866
 }
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/plugin-update-checker.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
  * Released under the MIT license. See license.txt for details.
8 8
  */
9 9
 
10
-require dirname(__FILE__) . '/Puc/v4p4/Factory.php';
11
-require dirname(__FILE__) . '/Puc/v4/Factory.php';
12
-require dirname(__FILE__) . '/Puc/v4p4/Autoloader.php';
10
+require dirname(__FILE__).'/Puc/v4p4/Factory.php';
11
+require dirname(__FILE__).'/Puc/v4/Factory.php';
12
+require dirname(__FILE__).'/Puc/v4p4/Autoloader.php';
13 13
 new Puc_v4p4_Autoloader();
14 14
 
15 15
 //Register classes defined in this file with the factory.
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/ParsedownLegacy.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
                 foreach ($parts as $part)
149 149
                 {
150
-                    $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
150
+                    $shortage = 4 - mb_strlen($line, 'utf-8')%4;
151 151
 
152 152
                     $line .= str_repeat(' ', $shortage);
153 153
                     $line .= $part;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
             while (isset($line[$indent]) and $line[$indent] === ' ')
160 160
             {
161
-                $indent ++;
161
+                $indent++;
162 162
             }
163 163
 
164 164
             $text = $indent > 0 ? substr($line, $indent) : $line;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             {
203 203
                 foreach ($this->BlockTypes[$marker] as $blockType)
204 204
                 {
205
-                    $blockTypes []= $blockType;
205
+                    $blockTypes [] = $blockType;
206 206
                 }
207 207
             }
208 208
 
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
                 {
218 218
                     $Block['type'] = $blockType;
219 219
 
220
-                    if ( ! isset($Block['identified']))
220
+                    if (!isset($Block['identified']))
221 221
                     {
222
-                        $Blocks []= $CurrentBlock;
222
+                        $Blocks [] = $CurrentBlock;
223 223
 
224 224
                         $Block['identified'] = true;
225 225
                     }
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 
238 238
             # ~
239 239
 
240
-            if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
240
+            if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted']))
241 241
             {
242 242
                 $CurrentBlock['element']['text'] .= "\n".$text;
243 243
             }
244 244
             else
245 245
             {
246
-                $Blocks []= $CurrentBlock;
246
+                $Blocks [] = $CurrentBlock;
247 247
 
248 248
                 $CurrentBlock = $this->paragraph($Line);
249 249
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
         # ~
262 262
 
263
-        $Blocks []= $CurrentBlock;
263
+        $Blocks [] = $CurrentBlock;
264 264
 
265 265
         unset($Blocks[0]);
266 266
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
     protected function blockCode($Line, $Block = null)
293 293
     {
294
-        if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
294
+        if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted']))
295 295
         {
296 296
             return;
297 297
         }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
             return;
380 380
         }
381 381
 
382
-        $Block['markup'] .= "\n" . $Line['body'];
382
+        $Block['markup'] .= "\n".$Line['body'];
383 383
 
384 384
         if (preg_match('/-->$/', $Line['text']))
385 385
         {
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
             return $Block;
447 447
         }
448 448
 
449
-        $Block['element']['text']['text'] .= "\n".$Line['body'];;
449
+        $Block['element']['text']['text'] .= "\n".$Line['body']; ;
450 450
 
451 451
         return $Block;
452 452
     }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
             while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
475 475
             {
476
-                $level ++;
476
+                $level++;
477 477
             }
478 478
 
479 479
             if ($level > 6)
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
             $Block = array(
487 487
                 'element' => array(
488
-                    'name' => 'h' . min(6, $level),
488
+                    'name' => 'h'.min(6, $level),
489 489
                     'text' => $text,
490 490
                     'handler' => 'line',
491 491
                 ),
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
                 ),
522 522
             );
523 523
 
524
-            $Block['element']['text'] []= & $Block['li'];
524
+            $Block['element']['text'] [] = & $Block['li'];
525 525
 
526 526
             return $Block;
527 527
         }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         {
534 534
             if (isset($Block['interrupted']))
535 535
             {
536
-                $Block['li']['text'] []= '';
536
+                $Block['li']['text'] [] = '';
537 537
 
538 538
                 unset($Block['interrupted']);
539 539
             }
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                 ),
551 551
             );
552 552
 
553
-            $Block['element']['text'] []= & $Block['li'];
553
+            $Block['element']['text'] [] = & $Block['li'];
554 554
 
555 555
             return $Block;
556 556
         }
@@ -560,22 +560,22 @@  discard block
 block discarded – undo
560 560
             return $Block;
561 561
         }
562 562
 
563
-        if ( ! isset($Block['interrupted']))
563
+        if (!isset($Block['interrupted']))
564 564
         {
565 565
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
566 566
 
567
-            $Block['li']['text'] []= $text;
567
+            $Block['li']['text'] [] = $text;
568 568
 
569 569
             return $Block;
570 570
         }
571 571
 
572 572
         if ($Line['indent'] > 0)
573 573
         {
574
-            $Block['li']['text'] []= '';
574
+            $Block['li']['text'] [] = '';
575 575
 
576 576
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
577 577
 
578
-            $Block['li']['text'] []= $text;
578
+            $Block['li']['text'] [] = $text;
579 579
 
580 580
             unset($Block['interrupted']);
581 581
 
@@ -608,19 +608,19 @@  discard block
 block discarded – undo
608 608
         {
609 609
             if (isset($Block['interrupted']))
610 610
             {
611
-                $Block['element']['text'] []= '';
611
+                $Block['element']['text'] [] = '';
612 612
 
613 613
                 unset($Block['interrupted']);
614 614
             }
615 615
 
616
-            $Block['element']['text'] []= $matches[1];
616
+            $Block['element']['text'] [] = $matches[1];
617 617
 
618 618
             return $Block;
619 619
         }
620 620
 
621
-        if ( ! isset($Block['interrupted']))
621
+        if (!isset($Block['interrupted']))
622 622
         {
623
-            $Block['element']['text'] []= $Line['text'];
623
+            $Block['element']['text'] [] = $Line['text'];
624 624
 
625 625
             return $Block;
626 626
         }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 
649 649
     protected function blockSetextHeader($Line, array $Block = null)
650 650
     {
651
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
651
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
652 652
         {
653 653
             return;
654 654
         }
@@ -723,14 +723,14 @@  discard block
 block discarded – undo
723 723
 
724 724
         if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
725 725
         {
726
-            $Block['depth'] ++;
726
+            $Block['depth']++;
727 727
         }
728 728
 
729 729
         if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
730 730
         {
731 731
             if ($Block['depth'] > 0)
732 732
             {
733
-                $Block['depth'] --;
733
+                $Block['depth']--;
734 734
             }
735 735
             else
736 736
             {
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
     protected function blockTable($Line, array $Block = null)
788 788
     {
789
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
789
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
790 790
         {
791 791
             return;
792 792
         }
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
                     $alignment = $alignment === 'left' ? 'center' : 'right';
824 824
                 }
825 825
 
826
-                $alignments []= $alignment;
826
+                $alignments [] = $alignment;
827 827
             }
828 828
 
829 829
             # ~
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
                     );
857 857
                 }
858 858
 
859
-                $HeaderElements []= $HeaderElement;
859
+                $HeaderElements [] = $HeaderElement;
860 860
             }
861 861
 
862 862
             # ~
@@ -870,18 +870,18 @@  discard block
 block discarded – undo
870 870
                 ),
871 871
             );
872 872
 
873
-            $Block['element']['text'] []= array(
873
+            $Block['element']['text'] [] = array(
874 874
                 'name' => 'thead',
875 875
                 'handler' => 'elements',
876 876
             );
877 877
 
878
-            $Block['element']['text'] []= array(
878
+            $Block['element']['text'] [] = array(
879 879
                 'name' => 'tbody',
880 880
                 'handler' => 'elements',
881 881
                 'text' => array(),
882 882
             );
883 883
 
884
-            $Block['element']['text'][0]['text'] []= array(
884
+            $Block['element']['text'][0]['text'] [] = array(
885 885
                 'name' => 'tr',
886 886
                 'handler' => 'elements',
887 887
                 'text' => $HeaderElements,
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
                     );
927 927
                 }
928 928
 
929
-                $Elements []= $Element;
929
+                $Elements [] = $Element;
930 930
             }
931 931
 
932 932
             $Element = array(
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
                 'text' => $Elements,
936 936
             );
937 937
 
938
-            $Block['element']['text'][1]['text'] []= $Element;
938
+            $Block['element']['text'][1]['text'] [] = $Element;
939 939
 
940 940
             return $Block;
941 941
         }
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
             {
1006 1006
                 $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007 1007
 
1008
-                if ( ! isset($Inline))
1008
+                if (!isset($Inline))
1009 1009
                 {
1010 1010
                     continue;
1011 1011
                 }
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                     continue;
1016 1016
                 }
1017 1017
 
1018
-                if ( ! isset($Inline['position']))
1018
+                if (!isset($Inline['position']))
1019 1019
                 {
1020 1020
                     $Inline['position'] = $markerPosition;
1021 1021
                 }
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
             $unexaminedText = substr($excerpt, 1);
1039 1039
 
1040
-            $markerPosition ++;
1040
+            $markerPosition++;
1041 1041
         }
1042 1042
 
1043 1043
         $markup .= $this->unmarkedText($text);
@@ -1075,9 +1075,9 @@  discard block
 block discarded – undo
1075 1075
         {
1076 1076
             $url = $matches[1];
1077 1077
 
1078
-            if ( ! isset($matches[2]))
1078
+            if (!isset($matches[2]))
1079 1079
             {
1080
-                $url = 'mailto:' . $url;
1080
+                $url = 'mailto:'.$url;
1081 1081
             }
1082 1082
 
1083 1083
             return array(
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
     protected function inlineEmphasis($Excerpt)
1097 1097
     {
1098
-        if ( ! isset($Excerpt['text'][1]))
1098
+        if (!isset($Excerpt['text'][1]))
1099 1099
         {
1100 1100
             return;
1101 1101
         }
@@ -1138,12 +1138,12 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
     protected function inlineImage($Excerpt)
1140 1140
     {
1141
-        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1141
+        if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1142 1142
         {
1143 1143
             return;
1144 1144
         }
1145 1145
 
1146
-        $Excerpt['text']= substr($Excerpt['text'], 1);
1146
+        $Excerpt['text'] = substr($Excerpt['text'], 1);
1147 1147
 
1148 1148
         $Link = $this->inlineLink($Excerpt);
1149 1149
 
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
                 $definition = strtolower($Element['text']);
1225 1225
             }
1226 1226
 
1227
-            if ( ! isset($this->DefinitionData['Reference'][$definition]))
1227
+            if (!isset($this->DefinitionData['Reference'][$definition]))
1228 1228
             {
1229 1229
                 return;
1230 1230
             }
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 
1278 1278
     protected function inlineSpecialCharacter($Excerpt)
1279 1279
     {
1280
-        if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1280
+        if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text']))
1281 1281
         {
1282 1282
             return array(
1283 1283
                 'markup' => '&amp;',
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 
1299 1299
     protected function inlineStrikethrough($Excerpt)
1300 1300
     {
1301
-        if ( ! isset($Excerpt['text'][1]))
1301
+        if (!isset($Excerpt['text'][1]))
1302 1302
         {
1303 1303
             return;
1304 1304
         }
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
 
1319 1319
     protected function inlineUrl($Excerpt)
1320 1320
     {
1321
-        if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1321
+        if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1322 1322
         {
1323 1323
             return;
1324 1324
         }
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
         foreach ($Elements as $Element)
1434 1434
         {
1435
-            $markup .= "\n" . $this->element($Element);
1435
+            $markup .= "\n".$this->element($Element);
1436 1436
         }
1437 1437
 
1438 1438
         $markup .= "\n";
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
         $trimmedMarkup = trim($markup);
1450 1450
 
1451
-        if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1451
+        if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1452 1452
         {
1453 1453
             $markup = $trimmedMarkup;
1454 1454
             $markup = substr($markup, 3);
@@ -1524,8 +1524,8 @@  discard block
 block discarded – undo
1524 1524
     protected $textLevelElements = array(
1525 1525
         'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1526 1526
         'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1527
-        'i', 'rp', 'del', 'code',          'strike', 'marquee',
1528
-        'q', 'rt', 'ins', 'font',          'strong',
1527
+        'i', 'rp', 'del', 'code', 'strike', 'marquee',
1528
+        'q', 'rt', 'ins', 'font', 'strong',
1529 1529
         's', 'tt', 'sub', 'mark',
1530 1530
         'u', 'xm', 'sup', 'nobr',
1531 1531
                    'var', 'ruby',
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/Parsedown.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
                 foreach ($parts as $part)
143 143
                 {
144
-                    $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
144
+                    $shortage = 4 - mb_strlen($line, 'utf-8')%4;
145 145
 
146 146
                     $line .= str_repeat(' ', $shortage);
147 147
                     $line .= $part;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
             while (isset($line[$indent]) and $line[$indent] === ' ')
154 154
             {
155
-                $indent ++;
155
+                $indent++;
156 156
             }
157 157
 
158 158
             $text = $indent > 0 ? substr($line, $indent) : $line;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             {
195 195
                 foreach ($this->BlockTypes[$marker] as $blockType)
196 196
                 {
197
-                    $blockTypes []= $blockType;
197
+                    $blockTypes [] = $blockType;
198 198
                 }
199 199
             }
200 200
 
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                 {
210 210
                     $Block['type'] = $blockType;
211 211
 
212
-                    if ( ! isset($Block['identified']))
212
+                    if (!isset($Block['identified']))
213 213
                     {
214
-                        $Blocks []= $CurrentBlock;
214
+                        $Blocks [] = $CurrentBlock;
215 215
 
216 216
                         $Block['identified'] = true;
217 217
                     }
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 
230 230
             # ~
231 231
 
232
-            if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
232
+            if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted']))
233 233
             {
234 234
                 $CurrentBlock['element']['text'] .= "\n".$text;
235 235
             }
236 236
             else
237 237
             {
238
-                $Blocks []= $CurrentBlock;
238
+                $Blocks [] = $CurrentBlock;
239 239
 
240 240
                 $CurrentBlock = $this->paragraph($Line);
241 241
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
         # ~
254 254
 
255
-        $Blocks []= $CurrentBlock;
255
+        $Blocks [] = $CurrentBlock;
256 256
 
257 257
         unset($Blocks[0]);
258 258
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
     protected function blockCode($Line, $Block = null)
295 295
     {
296
-        if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
296
+        if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted']))
297 297
         {
298 298
             return;
299 299
         }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return;
382 382
         }
383 383
 
384
-        $Block['markup'] .= "\n" . $Line['body'];
384
+        $Block['markup'] .= "\n".$Line['body'];
385 385
 
386 386
         if (preg_match('/-->$/', $Line['text']))
387 387
         {
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             return $Block;
449 449
         }
450 450
 
451
-        $Block['element']['text']['text'] .= "\n".$Line['body'];;
451
+        $Block['element']['text']['text'] .= "\n".$Line['body']; ;
452 452
 
453 453
         return $Block;
454 454
     }
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
             while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
477 477
             {
478
-                $level ++;
478
+                $level++;
479 479
             }
480 480
 
481 481
             if ($level > 6)
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
             $Block = array(
489 489
                 'element' => array(
490
-                    'name' => 'h' . min(6, $level),
490
+                    'name' => 'h'.min(6, $level),
491 491
                     'text' => $text,
492 492
                     'handler' => 'line',
493 493
                 ),
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 ),
524 524
             );
525 525
 
526
-            $Block['element']['text'] []= & $Block['li'];
526
+            $Block['element']['text'] [] = & $Block['li'];
527 527
 
528 528
             return $Block;
529 529
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         {
536 536
             if (isset($Block['interrupted']))
537 537
             {
538
-                $Block['li']['text'] []= '';
538
+                $Block['li']['text'] [] = '';
539 539
 
540 540
                 unset($Block['interrupted']);
541 541
             }
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
                 ),
553 553
             );
554 554
 
555
-            $Block['element']['text'] []= & $Block['li'];
555
+            $Block['element']['text'] [] = & $Block['li'];
556 556
 
557 557
             return $Block;
558 558
         }
@@ -562,22 +562,22 @@  discard block
 block discarded – undo
562 562
             return $Block;
563 563
         }
564 564
 
565
-        if ( ! isset($Block['interrupted']))
565
+        if (!isset($Block['interrupted']))
566 566
         {
567 567
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
568 568
 
569
-            $Block['li']['text'] []= $text;
569
+            $Block['li']['text'] [] = $text;
570 570
 
571 571
             return $Block;
572 572
         }
573 573
 
574 574
         if ($Line['indent'] > 0)
575 575
         {
576
-            $Block['li']['text'] []= '';
576
+            $Block['li']['text'] [] = '';
577 577
 
578 578
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
579 579
 
580
-            $Block['li']['text'] []= $text;
580
+            $Block['li']['text'] [] = $text;
581 581
 
582 582
             unset($Block['interrupted']);
583 583
 
@@ -610,19 +610,19 @@  discard block
 block discarded – undo
610 610
         {
611 611
             if (isset($Block['interrupted']))
612 612
             {
613
-                $Block['element']['text'] []= '';
613
+                $Block['element']['text'] [] = '';
614 614
 
615 615
                 unset($Block['interrupted']);
616 616
             }
617 617
 
618
-            $Block['element']['text'] []= $matches[1];
618
+            $Block['element']['text'] [] = $matches[1];
619 619
 
620 620
             return $Block;
621 621
         }
622 622
 
623
-        if ( ! isset($Block['interrupted']))
623
+        if (!isset($Block['interrupted']))
624 624
         {
625
-            $Block['element']['text'] []= $Line['text'];
625
+            $Block['element']['text'] [] = $Line['text'];
626 626
 
627 627
             return $Block;
628 628
         }
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 
651 651
     protected function blockSetextHeader($Line, array $Block = null)
652 652
     {
653
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
653
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
654 654
         {
655 655
             return;
656 656
         }
@@ -727,14 +727,14 @@  discard block
 block discarded – undo
727 727
 
728 728
         if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
729 729
         {
730
-            $Block['depth'] ++;
730
+            $Block['depth']++;
731 731
         }
732 732
 
733 733
         if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
734 734
         {
735 735
             if ($Block['depth'] > 0)
736 736
             {
737
-                $Block['depth'] --;
737
+                $Block['depth']--;
738 738
             }
739 739
             else
740 740
             {
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 
789 789
     protected function blockTable($Line, array $Block = null)
790 790
     {
791
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
791
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
792 792
         {
793 793
             return;
794 794
         }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                     $alignment = $alignment === 'left' ? 'center' : 'right';
826 826
                 }
827 827
 
828
-                $alignments []= $alignment;
828
+                $alignments [] = $alignment;
829 829
             }
830 830
 
831 831
             # ~
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
                     );
859 859
                 }
860 860
 
861
-                $HeaderElements []= $HeaderElement;
861
+                $HeaderElements [] = $HeaderElement;
862 862
             }
863 863
 
864 864
             # ~
@@ -872,18 +872,18 @@  discard block
 block discarded – undo
872 872
                 ),
873 873
             );
874 874
 
875
-            $Block['element']['text'] []= array(
875
+            $Block['element']['text'] [] = array(
876 876
                 'name' => 'thead',
877 877
                 'handler' => 'elements',
878 878
             );
879 879
 
880
-            $Block['element']['text'] []= array(
880
+            $Block['element']['text'] [] = array(
881 881
                 'name' => 'tbody',
882 882
                 'handler' => 'elements',
883 883
                 'text' => array(),
884 884
             );
885 885
 
886
-            $Block['element']['text'][0]['text'] []= array(
886
+            $Block['element']['text'][0]['text'] [] = array(
887 887
                 'name' => 'tr',
888 888
                 'handler' => 'elements',
889 889
                 'text' => $HeaderElements,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
                     );
929 929
                 }
930 930
 
931
-                $Elements []= $Element;
931
+                $Elements [] = $Element;
932 932
             }
933 933
 
934 934
             $Element = array(
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
                 'text' => $Elements,
938 938
             );
939 939
 
940
-            $Block['element']['text'][1]['text'] []= $Element;
940
+            $Block['element']['text'][1]['text'] [] = $Element;
941 941
 
942 942
             return $Block;
943 943
         }
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
             {
1006 1006
                 $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007 1007
 
1008
-                if ( ! isset($Inline))
1008
+                if (!isset($Inline))
1009 1009
                 {
1010 1010
                     continue;
1011 1011
                 }
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 
1020 1020
                 # sets a default inline position
1021 1021
 
1022
-                if ( ! isset($Inline['position']))
1022
+                if (!isset($Inline['position']))
1023 1023
                 {
1024 1024
                     $Inline['position'] = $markerPosition;
1025 1025
                 }
@@ -1083,9 +1083,9 @@  discard block
 block discarded – undo
1083 1083
         {
1084 1084
             $url = $matches[1];
1085 1085
 
1086
-            if ( ! isset($matches[2]))
1086
+            if (!isset($matches[2]))
1087 1087
             {
1088
-                $url = 'mailto:' . $url;
1088
+                $url = 'mailto:'.$url;
1089 1089
             }
1090 1090
 
1091 1091
             return array(
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
     protected function inlineEmphasis($Excerpt)
1105 1105
     {
1106
-        if ( ! isset($Excerpt['text'][1]))
1106
+        if (!isset($Excerpt['text'][1]))
1107 1107
         {
1108 1108
             return;
1109 1109
         }
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 
1147 1147
     protected function inlineImage($Excerpt)
1148 1148
     {
1149
-        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1149
+        if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1150 1150
         {
1151 1151
             return;
1152 1152
         }
1153 1153
 
1154
-        $Excerpt['text']= substr($Excerpt['text'], 1);
1154
+        $Excerpt['text'] = substr($Excerpt['text'], 1);
1155 1155
 
1156 1156
         $Link = $this->inlineLink($Excerpt);
1157 1157
 
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
                 $definition = strtolower($Element['text']);
1233 1233
             }
1234 1234
 
1235
-            if ( ! isset($this->DefinitionData['Reference'][$definition]))
1235
+            if (!isset($this->DefinitionData['Reference'][$definition]))
1236 1236
             {
1237 1237
                 return;
1238 1238
             }
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
     protected function inlineSpecialCharacter($Excerpt)
1287 1287
     {
1288
-        if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1288
+        if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text']))
1289 1289
         {
1290 1290
             return array(
1291 1291
                 'markup' => '&amp;',
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 
1307 1307
     protected function inlineStrikethrough($Excerpt)
1308 1308
     {
1309
-        if ( ! isset($Excerpt['text'][1]))
1309
+        if (!isset($Excerpt['text'][1]))
1310 1310
         {
1311 1311
             return;
1312 1312
         }
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
     protected function inlineUrl($Excerpt)
1328 1328
     {
1329
-        if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1329
+        if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1330 1330
         {
1331 1331
             return;
1332 1332
         }
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 
1436 1436
         foreach ($Elements as $Element)
1437 1437
         {
1438
-            $markup .= "\n" . $this->element($Element);
1438
+            $markup .= "\n".$this->element($Element);
1439 1439
         }
1440 1440
 
1441 1441
         $markup .= "\n";
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 
1452 1452
         $trimmedMarkup = trim($markup);
1453 1453
 
1454
-        if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1454
+        if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1455 1455
         {
1456 1456
             $markup = $trimmedMarkup;
1457 1457
             $markup = substr($markup, 3);
@@ -1527,8 +1527,8 @@  discard block
 block discarded – undo
1527 1527
     protected $textLevelElements = array(
1528 1528
         'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1529 1529
         'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1530
-        'i', 'rp', 'del', 'code',          'strike', 'marquee',
1531
-        'q', 'rt', 'ins', 'font',          'strong',
1530
+        'i', 'rp', 'del', 'code', 'strike', 'marquee',
1531
+        'q', 'rt', 'ins', 'font', 'strong',
1532 1532
         's', 'tt', 'sub', 'mark',
1533 1533
         'u', 'xm', 'sup', 'nobr',
1534 1534
                    'var', 'ruby',
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/readme-parser.php 1 patch
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( !class_exists('PucReadmeParser', false) ):
3
+if (!class_exists('PucReadmeParser', false)):
4 4
 
5 5
 /**
6 6
  * This is a slightly modified version of github.com/markjaquith/WordPress-Plugin-Readme-Parser
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 		// This space intentionally blank
14 14
 	}
15 15
 
16
-	function parse_readme( $file ) {
16
+	function parse_readme($file) {
17 17
 		$file_contents = @implode('', @file($file));
18
-		return $this->parse_readme_contents( $file_contents );
18
+		return $this->parse_readme_contents($file_contents);
19 19
 	}
20 20
 
21
-	function parse_readme_contents( $file_contents ) {
21
+	function parse_readme_contents($file_contents) {
22 22
 		$file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents);
23 23
 		$file_contents = trim($file_contents);
24
-		if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) )
25
-			$file_contents = substr( $file_contents, 3 );
24
+		if (0 === strpos($file_contents, "\xEF\xBB\xBF"))
25
+			$file_contents = substr($file_contents, 3);
26 26
 
27 27
 		// Markdown transformations
28
-		$file_contents = preg_replace( "|^###([^#]+)#*?\s*?\n|im", '=$1='."\n",     $file_contents );
29
-		$file_contents = preg_replace( "|^##([^#]+)#*?\s*?\n|im",  '==$1=='."\n",   $file_contents );
30
-		$file_contents = preg_replace( "|^#([^#]+)#*?\s*?\n|im",   '===$1==='."\n", $file_contents );
28
+		$file_contents = preg_replace("|^###([^#]+)#*?\s*?\n|im", '=$1='."\n", $file_contents);
29
+		$file_contents = preg_replace("|^##([^#]+)#*?\s*?\n|im", '==$1=='."\n", $file_contents);
30
+		$file_contents = preg_replace("|^#([^#]+)#*?\s*?\n|im", '===$1==='."\n", $file_contents);
31 31
 
32 32
 		// === Plugin Name ===
33 33
 		// Must be the very first thing.
34
-		if ( !preg_match('|^===(.*)===|', $file_contents, $_name) )
34
+		if (!preg_match('|^===(.*)===|', $file_contents, $_name))
35 35
 			return array(); // require a name
36 36
 		$name = trim($_name[1], '=');
37
-		$name = $this->sanitize_text( $name );
37
+		$name = $this->sanitize_text($name);
38 38
 
39
-		$file_contents = $this->chop_string( $file_contents, $_name[0] );
39
+		$file_contents = $this->chop_string($file_contents, $_name[0]);
40 40
 
41 41
 
42 42
 		// Requires at least: 1.5
43
-		if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) )
43
+		if (preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least))
44 44
 			$requires_at_least = $this->sanitize_text($_requires_at_least[1]);
45 45
 		else
46 46
 			$requires_at_least = NULL;
47 47
 
48 48
 
49 49
 		// Tested up to: 2.1
50
-		if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) )
51
-			$tested_up_to = $this->sanitize_text( $_tested_up_to[1] );
50
+		if (preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to))
51
+			$tested_up_to = $this->sanitize_text($_tested_up_to[1]);
52 52
 		else
53 53
 			$tested_up_to = NULL;
54 54
 
55 55
 
56 56
 		// Stable tag: 10.4-ride-the-fire-eagle-danger-day
57
-		if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) )
58
-			$stable_tag = $this->sanitize_text( $_stable_tag[1] );
57
+		if (preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag))
58
+			$stable_tag = $this->sanitize_text($_stable_tag[1]);
59 59
 		else
60 60
 			$stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk
61 61
 
62 62
 
63 63
 		// Tags: some tag, another tag, we like tags
64
-		if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) {
64
+		if (preg_match('|Tags:(.*)|i', $file_contents, $_tags)) {
65 65
 			$tags = preg_split('|,[\s]*?|', trim($_tags[1]));
66
-			foreach ( array_keys($tags) as $t )
67
-				$tags[$t] = $this->sanitize_text( $tags[$t] );
66
+			foreach (array_keys($tags) as $t)
67
+				$tags[$t] = $this->sanitize_text($tags[$t]);
68 68
 		} else {
69 69
 			$tags = array();
70 70
 		}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 		// Contributors: markjaquith, mdawaffe, zefrank
74 74
 		$contributors = array();
75
-		if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) {
75
+		if (preg_match('|Contributors:(.*)|i', $file_contents, $_contributors)) {
76 76
 			$temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1]));
77
-			foreach ( array_keys($temp_contributors) as $c ) {
78
-				$tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] );
79
-				if ( strlen(trim($tmp_sanitized)) > 0 )
77
+			foreach (array_keys($temp_contributors) as $c) {
78
+				$tmp_sanitized = $this->user_sanitize($temp_contributors[$c]);
79
+				if (strlen(trim($tmp_sanitized)) > 0)
80 80
 					$contributors[$c] = $tmp_sanitized;
81 81
 				unset($tmp_sanitized);
82 82
 			}
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 
85 85
 
86 86
 		// Donate Link: URL
87
-		if ( preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link) )
88
-			$donate_link = esc_url( $_donate_link[1] );
87
+		if (preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link))
88
+			$donate_link = esc_url($_donate_link[1]);
89 89
 		else
90 90
 			$donate_link = NULL;
91 91
 
92 92
 
93 93
 		// togs, conts, etc are optional and order shouldn't matter.  So we chop them only after we've grabbed their values.
94
-		foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop ) {
95
-			if ( $$chop ) {
96
-				$_chop = '_' . $chop;
97
-				$file_contents = $this->chop_string( $file_contents, ${$_chop}[0] );
94
+		foreach (array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop) {
95
+			if ($$chop) {
96
+				$_chop = '_'.$chop;
97
+				$file_contents = $this->chop_string($file_contents, ${$_chop}[0]);
98 98
 			}
99 99
 		}
100 100
 
@@ -102,29 +102,29 @@  discard block
 block discarded – undo
102 102
 
103 103
 
104 104
 		// short-description fu
105
-		if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) )
106
-			$_short_description = array( 1 => &$file_contents, 2 => &$file_contents );
107
-		$short_desc_filtered = $this->sanitize_text( $_short_description[2] );
105
+		if (!preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description))
106
+			$_short_description = array(1 => &$file_contents, 2 => &$file_contents);
107
+		$short_desc_filtered = $this->sanitize_text($_short_description[2]);
108 108
 		$short_desc_length = strlen($short_desc_filtered);
109 109
 		$short_description = substr($short_desc_filtered, 0, 150);
110
-		if ( $short_desc_length > strlen($short_description) )
110
+		if ($short_desc_length > strlen($short_description))
111 111
 			$truncated = true;
112 112
 		else
113 113
 			$truncated = false;
114
-		if ( $_short_description[1] )
115
-			$file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional
114
+		if ($_short_description[1])
115
+			$file_contents = $this->chop_string($file_contents, $_short_description[1]); // yes, the [1] is intentional
116 116
 
117 117
 		// == Section ==
118 118
 		// Break into sections
119 119
 		// $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section
120 120
 		// the array alternates from there:  title2, content2, title3, content3... and so forth
121
-		$_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
121
+		$_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
122 122
 
123 123
 		$sections = array();
124
-		for ( $i=1; $i <= count($_sections); $i +=2 ) {
124
+		for ($i = 1; $i <= count($_sections); $i += 2) {
125 125
 			$_sections[$i] = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i]);
126
-			$_sections[$i] = $this->filter_text( $_sections[$i], true );
127
-			$title = $this->sanitize_text( $_sections[$i-1] );
126
+			$_sections[$i] = $this->filter_text($_sections[$i], true);
127
+			$title = $this->sanitize_text($_sections[$i - 1]);
128 128
 			$sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]);
129 129
 		}
130 130
 
@@ -133,21 +133,21 @@  discard block
 block discarded – undo
133 133
 		// This is where we nab our special sections, so we can enforce their order and treat them differently, if needed
134 134
 		// upgrade_notice is not a section, but parse it like it is for now
135 135
 		$final_sections = array();
136
-		foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) {
137
-			if ( isset($sections[$special_section]) ) {
136
+		foreach (array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section) {
137
+			if (isset($sections[$special_section])) {
138 138
 				$final_sections[$special_section] = $sections[$special_section]['content'];
139 139
 				unset($sections[$special_section]);
140 140
 			}
141 141
 		}
142
-		if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) )
142
+		if (isset($final_sections['change_log']) && empty($final_sections['changelog']))
143 143
 			$final_sections['changelog'] = $final_sections['change_log'];
144 144
 
145 145
 
146 146
 		$final_screenshots = array();
147
-		if ( isset($final_sections['screenshots']) ) {
147
+		if (isset($final_sections['screenshots'])) {
148 148
 			preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER);
149
-			if ( $screenshots ) {
150
-				foreach ( (array) $screenshots as $ss )
149
+			if ($screenshots) {
150
+				foreach ((array) $screenshots as $ss)
151 151
 					$final_screenshots[] = $ss[1];
152 152
 			}
153 153
 		}
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 		// Parse the upgrade_notice section specially:
156 156
 		// 1.0 => blah, 1.1 => fnord
157 157
 		$upgrade_notice = array();
158
-		if ( isset($final_sections['upgrade_notice']) ) {
159
-			$split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
160
-			for ( $i = 0; $i < count( $split ); $i += 2 )
161
-				$upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
162
-			unset( $final_sections['upgrade_notice'] );
158
+		if (isset($final_sections['upgrade_notice'])) {
159
+			$split = preg_split('#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
160
+			for ($i = 0; $i < count($split); $i += 2)
161
+				$upgrade_notice[$this->sanitize_text($split[$i])] = substr($this->sanitize_text($split[$i + 1]), 0, 300);
162
+			unset($final_sections['upgrade_notice']);
163 163
 		}
164 164
 
165 165
 		// No description?
166 166
 		// No problem... we'll just fall back to the old style of description
167 167
 		// We'll even let you use markup this time!
168 168
 		$excerpt = false;
169
-		if ( !isset($final_sections['description']) ) {
170
-			$final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections);
169
+		if (!isset($final_sections['description'])) {
170
+			$final_sections = array_merge(array('description' => $this->filter_text($_short_description[2], true)), $final_sections);
171 171
 			$excerpt = true;
172 172
 		}
173 173
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		// dump the non-special sections into $remaining_content
176 176
 		// their order will be determined by their original order in the readme.txt
177 177
 		$remaining_content = '';
178
-		foreach ( $sections as $s_name => $s_data ) {
178
+		foreach ($sections as $s_name => $s_data) {
179 179
 			$remaining_content .= "\n<h3>{$s_data['title']}</h3>\n{$s_data['content']}";
180 180
 		}
181 181
 		$remaining_content = trim($remaining_content);
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 		return $r;
205 205
 	}
206 206
 
207
-	function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos
208
-		if ( $_string = strstr($string, $chop) ) {
207
+	function chop_string($string, $chop) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos
208
+		if ($_string = strstr($string, $chop)) {
209 209
 			$_string = substr($_string, strlen($chop));
210 210
 			return trim($_string);
211 211
 		} else {
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 		}
214 214
 	}
215 215
 
216
-	function user_sanitize( $text, $strict = false ) { // whitelisted chars
217
-		if ( function_exists('user_sanitize') ) // bbPress native
218
-			return user_sanitize( $text, $strict );
216
+	function user_sanitize($text, $strict = false) { // whitelisted chars
217
+		if (function_exists('user_sanitize')) // bbPress native
218
+			return user_sanitize($text, $strict);
219 219
 
220
-		if ( $strict ) {
220
+		if ($strict) {
221 221
 			$text = preg_replace('/[^a-z0-9-]/i', '', $text);
222 222
 			$text = preg_replace('|-+|', '-', $text);
223 223
 		} else {
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
 		return $text;
227 227
 	}
228 228
 
229
-	function sanitize_text( $text ) { // not fancy
229
+	function sanitize_text($text) { // not fancy
230 230
 		$text = strip_tags($text);
231 231
 		$text = esc_html($text);
232 232
 		$text = trim($text);
233 233
 		return $text;
234 234
 	}
235 235
 
236
-	function filter_text( $text, $markdown = false ) { // fancy, Markdown
236
+	function filter_text($text, $markdown = false) { // fancy, Markdown
237 237
 		$text = trim($text);
238 238
 
239
-		$text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE
239
+		$text = call_user_func(array(__CLASS__, 'code_trick'), $text, $markdown); // A better parser than Markdown's for: backticks -> CODE
240 240
 
241
-		if ( $markdown ) { // Parse markdown.
242
-			if ( !class_exists('Parsedown', false) ) {
241
+		if ($markdown) { // Parse markdown.
242
+			if (!class_exists('Parsedown', false)) {
243 243
 				/** @noinspection PhpIncludeInspection */
244
-				require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
244
+				require_once(dirname(__FILE__).'/Parsedown'.(version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy').'.php');
245 245
 			}
246 246
 			$instance = Parsedown::instance();
247 247
 			$text = $instance->text($text);
@@ -268,39 +268,39 @@  discard block
 block discarded – undo
268 268
 
269 269
 		$text = balanceTags($text);
270 270
 		
271
-		$text = wp_kses( $text, $allowed );
271
+		$text = wp_kses($text, $allowed);
272 272
 		$text = trim($text);
273 273
 		return $text;
274 274
 	}
275 275
 
276
-	function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown
276
+	function code_trick($text, $markdown) { // Don't use bbPress native function - it's incompatible with Markdown
277 277
 		// If doing markdown, first take any user formatted code blocks and turn them into backticks so that
278 278
 		// markdown will preserve things like underscores in code blocks
279
-		if ( $markdown )
280
-			$text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( __CLASS__,'decodeit'), $text);
279
+		if ($markdown)
280
+			$text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array(__CLASS__, 'decodeit'), $text);
281 281
 
282 282
 		$text = str_replace(array("\r\n", "\r"), "\n", $text);
283
-		if ( !$markdown ) {
283
+		if (!$markdown) {
284 284
 			// This gets the "inline" code blocks, but can't be used with Markdown.
285
-			$text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text);
285
+			$text = preg_replace_callback("|(`)(.*?)`|", array(__CLASS__, 'encodeit'), $text);
286 286
 			// This gets the "block level" code blocks and converts them to PRE CODE
287
-			$text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text);
287
+			$text = preg_replace_callback("!(^|\n)`(.*?)`!s", array(__CLASS__, 'encodeit'), $text);
288 288
 		} else {
289 289
 			// Markdown can do inline code, we convert bbPress style block level code to Markdown style
290
-			$text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text);
290
+			$text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array(__CLASS__, 'indent'), $text);
291 291
 		}
292 292
 		return $text;
293 293
 	}
294 294
 
295
-	function indent( $matches ) {
295
+	function indent($matches) {
296 296
 		$text = $matches[3];
297
-		$text = preg_replace('|^|m', $matches[2] . '    ', $text);
298
-		return $matches[1] . $text;
297
+		$text = preg_replace('|^|m', $matches[2].'    ', $text);
298
+		return $matches[1].$text;
299 299
 	}
300 300
 
301
-	function encodeit( $matches ) {
302
-		if ( function_exists('encodeit') ) // bbPress native
303
-			return encodeit( $matches );
301
+	function encodeit($matches) {
302
+		if (function_exists('encodeit')) // bbPress native
303
+			return encodeit($matches);
304 304
 
305 305
 		$text = trim($matches[2]);
306 306
 		$text = htmlspecialchars($text, ENT_QUOTES);
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
 		$text = str_replace('&amp;lt;', '&lt;', $text);
310 310
 		$text = str_replace('&amp;gt;', '&gt;', $text);
311 311
 		$text = "<code>$text</code>";
312
-		if ( "`" != $matches[1] )
312
+		if ("`" != $matches[1])
313 313
 			$text = "<pre>$text</pre>";
314 314
 		return $text;
315 315
 	}
316 316
 
317
-	function decodeit( $matches ) {
318
-		if ( function_exists('decodeit') ) // bbPress native
319
-			return decodeit( $matches );
317
+	function decodeit($matches) {
318
+		if (function_exists('decodeit')) // bbPress native
319
+			return decodeit($matches);
320 320
 
321 321
 		$text = $matches[2];
322 322
 		$trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		$text = str_replace('<br />', '', $text);
325 325
 		$text = str_replace('&#38;', '&', $text);
326 326
 		$text = str_replace('&#39;', "'", $text);
327
-		if ( '<pre><code>' == $matches[1] )
327
+		if ('<pre><code>' == $matches[1])
328 328
 			$text = "\n$text\n";
329 329
 		return "`$text`";
330 330
 	}
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/Puc/v4p4/Utils.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( !class_exists('Puc_v4p4_Utils', false) ):
3
+if (!class_exists('Puc_v4p4_Utils', false)):
4 4
 
5 5
 	class Puc_v4p4_Utils {
6 6
 		/**
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
13 13
 		 * @return mixed
14 14
 		 */
15 15
 		public static function get($collection, $path, $default = null, $separator = '.') {
16
-			if ( is_string($path) ) {
16
+			if (is_string($path)) {
17 17
 				$path = explode($separator, $path);
18 18
 			}
19 19
 
20 20
 			//Follow the $path into $input as far as possible.
21 21
 			$currentValue = $collection;
22 22
 			foreach ($path as $node) {
23
-				if ( is_array($currentValue) && isset($currentValue[$node]) ) {
23
+				if (is_array($currentValue) && isset($currentValue[$node])) {
24 24
 					$currentValue = $currentValue[$node];
25
-				} else if ( is_object($currentValue) && isset($currentValue->$node) ) {
25
+				} else if (is_object($currentValue) && isset($currentValue->$node)) {
26 26
 					$currentValue = $currentValue->$node;
27 27
 				} else {
28 28
 					return $default;
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 * @return mixed|null
41 41
 		 */
42 42
 		public static function findNotEmpty($values, $default = null) {
43
-			if ( empty($values) ) {
43
+			if (empty($values)) {
44 44
 				return $default;
45 45
 			}
46 46
 
47 47
 			foreach ($values as $value) {
48
-				if ( !empty($value) ) {
48
+				if (!empty($value)) {
49 49
 					return $value;
50 50
 				}
51 51
 			}
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/Puc/v4p4/Vcs/BaseChecker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if ( !interface_exists('Puc_v4p4_Vcs_BaseChecker', false) ):
2
+if (!interface_exists('Puc_v4p4_Vcs_BaseChecker', false)):
3 3
 
4 4
 	interface Puc_v4p4_Vcs_BaseChecker {
5 5
 		/**
Please login to merge, or discard this patch.