A2 Optimized WP - Version 2.1.3.2

Version Description

= 2.0.10.9 = Important security update. Please upgrade immediately.

= 2.0 = New GPL plugin, now updates are through the wordpress.org repository

Download this release

Release Info

Developer a2hosting
Plugin Icon 128x128 A2 Optimized WP
Version 2.1.3.2
Comparing to
See all releases

Code changes from version 2.1.3.1 to 2.1.3.2

A2_Optimized_Cache.php CHANGED
@@ -287,7 +287,8 @@ final class A2_Optimized_Cache {
287
  // switch to each site in network
288
  foreach ( $blog_ids as $blog_id ) {
289
  switch_to_blog( $blog_id );
290
- $callback_return[] = (int) call_user_func_array( $callback, $callback_params );
 
291
  restore_current_blog();
292
  }
293
  } else {
@@ -334,11 +335,11 @@ final class A2_Optimized_Cache {
334
  */
335
 
336
  private static function get_blog_ids() {
337
- $blog_ids = array( '1' );
338
 
339
  if ( is_multisite() ) {
340
  global $wpdb;
341
- $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
342
  }
343
 
344
  return $blog_ids;
287
  // switch to each site in network
288
  foreach ( $blog_ids as $blog_id ) {
289
  switch_to_blog( $blog_id );
290
+ $callback_return[ $blog_id ] = call_user_func_array( $callback, $callback_params );
291
+
292
  restore_current_blog();
293
  }
294
  } else {
335
  */
336
 
337
  private static function get_blog_ids() {
338
+ $blog_ids = array( 1 );
339
 
340
  if ( is_multisite() ) {
341
  global $wpdb;
342
+ $blog_ids = array_map( 'absint', $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) );
343
  }
344
 
345
  return $blog_ids;
A2_Optimized_CacheDisk.php CHANGED
@@ -915,7 +915,7 @@ final class A2_Optimized_Cache_Disk {
915
  // if setting selected remove CSS and JavaScript comments
916
  if ( A2_Optimized_Cache_Engine::$settings['minify_inline_css_js'] ) {
917
  $minified_html = preg_replace(
918
- '#/\*[\s\S]*?\*/|([^\'\"\\:\w]|^)//.*$#m',
919
  '$1',
920
  $minified_html
921
  );
915
  // if setting selected remove CSS and JavaScript comments
916
  if ( A2_Optimized_Cache_Engine::$settings['minify_inline_css_js'] ) {
917
  $minified_html = preg_replace(
918
+ '#/\*(?!!)[\s\S]*?\*/|(?:^[ \t]*)//.*$|((?<!\()[ \t>;,{}[\]])//[^;\n]*$#m',
919
  '$1',
920
  $minified_html
921
  );
A2_Optimized_CacheEngine.php CHANGED
@@ -30,6 +30,13 @@ final class A2_Optimized_Cache_Engine {
30
 
31
  public static $started = false;
32
 
 
 
 
 
 
 
 
33
  /**
34
  * engine settings from disk or database
35
  *
@@ -44,6 +51,9 @@ final class A2_Optimized_Cache_Engine {
44
  */
45
 
46
  public function __construct() {
 
 
 
47
  // get settings from disk if directory index file
48
  if ( self::is_index() ) {
49
  self::$settings = A2_Optimized_Cache_Disk::get_settings();
@@ -131,6 +141,28 @@ final class A2_Optimized_Cache_Engine {
131
  }
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  /**
135
  * check if directory index file
136
  *
@@ -202,7 +234,10 @@ final class A2_Optimized_Cache_Engine {
202
  private static function is_excluded() {
203
  // if post ID excluded
204
  if ( ! empty( self::$settings['excluded_post_ids'] ) && function_exists( 'is_singular' ) && is_singular() ) {
205
- if ( in_array( get_queried_object_id(), (array) explode( ',', self::$settings['excluded_post_ids'] ) ) ) {
 
 
 
206
  return true;
207
  }
208
  }
@@ -324,8 +359,26 @@ final class A2_Optimized_Cache_Engine {
324
  */
325
 
326
  public static function deliver_cache() {
327
- if ( A2_Optimized_Cache_Disk::cache_exists() && ! A2_Optimized_Cache_Disk::cache_expired() && ! self::bypass_cache() ) {
328
- readfile( A2_Optimized_Cache_Disk::get_cache() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  exit;
330
  }
331
 
30
 
31
  public static $started = false;
32
 
33
+ /**
34
+ * specific HTTP request headers from current request
35
+ *
36
+ */
37
+
38
+ public static $request_headers;
39
+
40
  /**
41
  * engine settings from disk or database
42
  *
51
  */
52
 
53
  public function __construct() {
54
+ // get request headers
55
+ self::$request_headers = self::get_request_headers();
56
+
57
  // get settings from disk if directory index file
58
  if ( self::is_index() ) {
59
  self::$settings = A2_Optimized_Cache_Disk::get_settings();
141
  }
142
  }
143
 
144
+ /**
145
+ * get specific HTTP request headers from current request
146
+ *
147
+ * @return array $request_headers specific HTTP request headers from current request
148
+ */
149
+
150
+ private static function get_request_headers() {
151
+ $request_headers = ( function_exists( 'apache_request_headers' ) ) ? apache_request_headers() : array();
152
+
153
+ $request_headers = array(
154
+ 'Accept' => ( isset( $request_headers['Accept'] ) ) ? $request_headers['Accept'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT' ] : '' ),
155
+ 'Accept-Encoding' => ( isset( $request_headers['Accept-Encoding'] ) ) ? $request_headers['Accept-Encoding'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] : '' ),
156
+ 'Host' => ( isset( $request_headers['Host'] ) ) ? $request_headers['Host'] : ( ( isset( $_SERVER[ 'HTTP_HOST' ] ) ) ? $_SERVER[ 'HTTP_HOST' ] : '' ),
157
+ 'If-Modified-Since' => ( isset( $request_headers['If-Modified-Since'] ) ) ? $request_headers['If-Modified-Since'] : ( ( isset( $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ] ) ) ? $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ] : '' ),
158
+ 'User-Agent' => ( isset( $request_headers['User-Agent'] ) ) ? $request_headers['User-Agent'] : ( ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) ? $_SERVER[ 'HTTP_USER_AGENT' ] : '' ),
159
+ 'X-Forwarded-Proto' => ( isset( $request_headers['X-Forwarded-Proto'] ) ) ? $request_headers['X-Forwarded-Proto'] : ( ( isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) ) ? $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] : '' ),
160
+ 'X-Forwarded-Scheme' => ( isset( $request_headers['X-Forwarded-Scheme'] ) ) ? $request_headers['X-Forwarded-Scheme'] : ( ( isset( $_SERVER[ 'HTTP_X_FORWARDED_SCHEME' ] ) ) ? $_SERVER[ 'HTTP_X_FORWARDED_SCHEME' ] : '' ),
161
+ );
162
+
163
+ return $request_headers;
164
+ }
165
+
166
  /**
167
  * check if directory index file
168
  *
234
  private static function is_excluded() {
235
  // if post ID excluded
236
  if ( ! empty( self::$settings['excluded_post_ids'] ) && function_exists( 'is_singular' ) && is_singular() ) {
237
+ $post_id = get_queried_object_id();
238
+ $excluded_post_ids = array_map( 'absint', (array) explode( ',', self::$settings['excluded_post_ids'] ) );
239
+
240
+ if ( in_array( $post_id, $excluded_post_ids, true ) ) {
241
  return true;
242
  }
243
  }
359
  */
360
 
361
  public static function deliver_cache() {
362
+ $cache_file = A2_Optimized_Cache_Disk::get_cache();
363
+
364
+ if ( A2_Optimized_Cache_Disk::cache_exists( $cache_file ) && ! A2_Optimized_Cache_Disk::cache_expired( $cache_file ) && ! self::bypass_cache() ) {
365
+ // set X-Cache-Handler response header
366
+ header( 'X-Cache-Handler: cache-enabler-engine' );
367
+
368
+ // return 304 Not Modified with empty body if applicable
369
+ if ( strtotime( self::$request_headers['If-Modified-Since'] >= filemtime( $cache_file ) ) ) {
370
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304 );
371
+ exit;
372
+ }
373
+
374
+ // set Content-Encoding response header if applicable
375
+ if ( strpos( basename( $cache_file ), 'gz' ) !== false ) {
376
+ header( 'Content-Encoding: gzip' );
377
+ }
378
+
379
+ // deliver cache
380
+ readfile( $cache_file );
381
+
382
  exit;
383
  }
384
 
A2_Optimized_Optimizations.php CHANGED
@@ -492,9 +492,7 @@ class A2_Optimized_Optimizations {
492
  }
493
  }
494
  },
495
- 'description' => '
496
- <p>Generate new salt values for wp-config.php<br /><strong>This will log out all users including yourself</strong></p>
497
- ',
498
  'last_updated' => true,
499
  'update' => true,
500
  'enable' => function () use (&$thisclass) {
492
  }
493
  }
494
  },
495
+ 'description' => "<p>Generate new salt values for wp-config.php</p><p>WordPress salts and security keys help secure your site's login process and the cookies that WordPress uses to authenticate users. There are security benefits to periodically changing your salts to make it even harder for malicious actors to access them. You may need to clear your browser cookies after activating this option.</p><p><strong>This will log out all users including yourself</strong></p>",
 
 
496
  'last_updated' => true,
497
  'update' => true,
498
  'enable' => function () use (&$thisclass) {
a2-optimized.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: A2 Optimized WP
4
  Plugin URI: https://wordpress.org/plugins/a2-optimized/
5
- Version: 2.1.3.1
6
  Author: A2 Hosting
7
  Author URI: https://www.a2hosting.com/
8
  Description: A2 Optimized - WordPress Optimization Plugin
2
  /*
3
  Plugin Name: A2 Optimized WP
4
  Plugin URI: https://wordpress.org/plugins/a2-optimized/
5
+ Version: 2.1.3.2
6
  Author: A2 Hosting
7
  Author URI: https://www.a2hosting.com/
8
  Description: A2 Optimized - WordPress Optimization Plugin
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: A2BCool, a2hosting, dmatteson, sputala
3
  Tags: Speed, Optimize, Secure, Fast, W3 Total Cache, W3TC, Hosting
4
  Requires at least: 5.1
5
  Tested up to: 5.7.1
6
- Stable tag: 2.1.3.1
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -123,6 +123,9 @@ Yes. A2 Optimized works on any host that supports WordPress; however, A2 Hostin
123
 
124
  == Changelog ==
125
 
 
 
 
126
  = 2.1.3.1 =
127
  * Fixed issue with handling of some regex formulas in the advanced cache settings exclusion list
128
  * Additional checks when adding memcached server for object caching
3
  Tags: Speed, Optimize, Secure, Fast, W3 Total Cache, W3TC, Hosting
4
  Requires at least: 5.1
5
  Tested up to: 5.7.1
6
+ Stable tag: 2.1.3.2
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
123
 
124
  == Changelog ==
125
 
126
+ = 2.1.3.1 =
127
+ * Small improvments to disk caching
128
+
129
  = 2.1.3.1 =
130
  * Fixed issue with handling of some regex formulas in the advanced cache settings exclusion list
131
  * Additional checks when adding memcached server for object caching