Cache Enabler – WordPress Cache - Version 1.4.6

Version Description

  • Add cache bypass method for sitemaps (#104)
  • Fix cache clearing for subdirectory multisite networks (#103)
Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 Cache Enabler – WordPress Cache
Version 1.4.6
Comparing to
See all releases

Code changes from version 1.4.5 to 1.4.6

Files changed (3) hide show
  1. cache-enabler.php +1 -1
  2. inc/cache_enabler.class.php +26 -9
  3. readme.txt +4 -0
cache-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress disk caching plugin.
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 1.4.5
10
  */
11
 
12
  /*
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 1.4.6
10
  */
11
 
12
  /*
inc/cache_enabler.class.php CHANGED
@@ -854,7 +854,7 @@ final class Cache_Enabler {
854
  * process clear request
855
  *
856
  * @since 1.0.0
857
- * @change 1.4.0
858
  *
859
  * @param array $data array of metadata
860
  */
@@ -862,7 +862,7 @@ final class Cache_Enabler {
862
  public static function process_clear_request( $data ) {
863
 
864
  // check if clear request
865
- if ( empty( $_GET['_cache'] ) || empty( $_GET['_action'] || $_GET['_cache'] !== 'cache-enabler' && $_GET['_action'] !== 'clear' || $_GET['_action'] !== 'clearurl' ) ) {
866
  return;
867
  }
868
 
@@ -955,7 +955,7 @@ final class Cache_Enabler {
955
  if ( ! is_admin() ) {
956
  wp_safe_redirect(
957
  remove_query_arg(
958
- '_action',
959
  wp_get_referer()
960
  )
961
  );
@@ -1297,7 +1297,7 @@ final class Cache_Enabler {
1297
  * clear blog ID cache
1298
  *
1299
  * @since 1.4.0
1300
- * @change 1.4.0
1301
  *
1302
  * @param integer $blog_id blog ID
1303
  */
@@ -1343,9 +1343,8 @@ final class Cache_Enabler {
1343
  $page_path = str_replace( $glob_path, '', $page_path );
1344
  // if cached page belongs to main site
1345
  if ( ! in_array( $page_path, $blog_paths ) ) {
1346
- $clear_url .= $page_path;
1347
  // clear page cache
1348
- self::clear_page_cache_by_url( $clear_url );
1349
  }
1350
  }
1351
 
@@ -1353,7 +1352,6 @@ final class Cache_Enabler {
1353
  self::clear_home_page_cache();
1354
  // subsite
1355
  } else {
1356
- $clear_url .= $blog_path;
1357
  // clear subsite cache
1358
  self::clear_page_cache_by_url( $clear_url );
1359
  }
@@ -1395,6 +1393,25 @@ final class Cache_Enabler {
1395
  }
1396
 
1397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398
  /**
1399
  * check if mobile
1400
  *
@@ -1440,7 +1457,7 @@ final class Cache_Enabler {
1440
  * check to bypass the cache
1441
  *
1442
  * @since 1.0.0
1443
- * @change 1.4.5
1444
  *
1445
  * @return boolean true if exception, false otherwise
1446
  *
@@ -1465,7 +1482,7 @@ final class Cache_Enabler {
1465
  }
1466
 
1467
  // check conditional tags
1468
- if ( self::_is_wp_cache_disabled() || self::_is_index() || is_search() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() ) {
1469
  return true;
1470
  }
1471
 
854
  * process clear request
855
  *
856
  * @since 1.0.0
857
+ * @change 1.4.6
858
  *
859
  * @param array $data array of metadata
860
  */
862
  public static function process_clear_request( $data ) {
863
 
864
  // check if clear request
865
+ if ( empty( $_GET['_cache'] ) || empty( $_GET['_action'] ) || $_GET['_cache'] !== 'cache-enabler' && ( $_GET['_action'] !== 'clear' || $_GET['_action'] !== 'clearurl' ) ) {
866
  return;
867
  }
868
 
955
  if ( ! is_admin() ) {
956
  wp_safe_redirect(
957
  remove_query_arg(
958
+ '_cache',
959
  wp_get_referer()
960
  )
961
  );
1297
  * clear blog ID cache
1298
  *
1299
  * @since 1.4.0
1300
+ * @change 1.4.6
1301
  *
1302
  * @param integer $blog_id blog ID
1303
  */
1343
  $page_path = str_replace( $glob_path, '', $page_path );
1344
  // if cached page belongs to main site
1345
  if ( ! in_array( $page_path, $blog_paths ) ) {
 
1346
  // clear page cache
1347
+ self::clear_page_cache_by_url( $clear_url . $page_path );
1348
  }
1349
  }
1350
 
1352
  self::clear_home_page_cache();
1353
  // subsite
1354
  } else {
 
1355
  // clear subsite cache
1356
  self::clear_page_cache_by_url( $clear_url );
1357
  }
1393
  }
1394
 
1395
 
1396
+ /**
1397
+ * check if sitemap
1398
+ *
1399
+ * @since 1.4.6
1400
+ * @change 1.4.6
1401
+ *
1402
+ * @return boolean true if sitemap, false otherwise
1403
+ */
1404
+
1405
+ private static function _is_sitemap() {
1406
+
1407
+ if ( preg_match( '/\.x(m|s)l$/', $_SERVER['REQUEST_URI'] ) ) {
1408
+ return true;
1409
+ }
1410
+
1411
+ return false;
1412
+ }
1413
+
1414
+
1415
  /**
1416
  * check if mobile
1417
  *
1457
  * check to bypass the cache
1458
  *
1459
  * @since 1.0.0
1460
+ * @change 1.4.6
1461
  *
1462
  * @return boolean true if exception, false otherwise
1463
  *
1482
  }
1483
 
1484
  // check conditional tags
1485
+ if ( self::_is_wp_cache_disabled() || self::_is_index() || is_search() || self::_is_sitemap() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() ) {
1486
  return true;
1487
  }
1488
 
readme.txt CHANGED
@@ -81,6 +81,10 @@ When combined with Optimus, the WordPress Cache Enabler allows you to easily del
81
 
82
  == Changelog ==
83
 
 
 
 
 
84
  = 1.4.5 =
85
  * Update WP_CACHE constant handling (#102)
86
  * Add cache bypass method for WP_CACHE constant (#102)
81
 
82
  == Changelog ==
83
 
84
+ = 1.4.6 =
85
+ * Add cache bypass method for sitemaps (#104)
86
+ * Fix cache clearing for subdirectory multisite networks (#103)
87
+
88
  = 1.4.5 =
89
  * Update WP_CACHE constant handling (#102)
90
  * Add cache bypass method for WP_CACHE constant (#102)