Version Description
- Update URL cache clearing
- Update advcache settings
Download this release
Release Info
Developer | keycdn |
Plugin | Cache Enabler – WordPress Cache |
Version | 1.4.3 |
Comparing to | |
See all releases |
Code changes from version 1.4.2 to 1.4.3
- advanced-cache.php +1 -1
- cache-enabler.php +1 -1
- inc/cache_enabler.class.php +78 -80
- readme.txt +5 -1
advanced-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Cache Enabler advanced cache
|
4 |
*
|
5 |
* @since 1.2.0
|
6 |
-
* @change 1.4.
|
7 |
*/
|
8 |
|
9 |
// check if request method is GET
|
3 |
* Cache Enabler advanced cache
|
4 |
*
|
5 |
* @since 1.2.0
|
6 |
+
* @change 1.4.2
|
7 |
*/
|
8 |
|
9 |
// check if request method is GET
|
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.
|
10 |
*/
|
11 |
|
12 |
/*
|
6 |
Author: KeyCDN
|
7 |
Author URI: https://www.keycdn.com
|
8 |
License: GPLv2 or later
|
9 |
+
Version: 1.4.3
|
10 |
*/
|
11 |
|
12 |
/*
|
inc/cache_enabler.class.php
CHANGED
@@ -312,22 +312,13 @@ final class Cache_Enabler {
|
|
312 |
* create or update advanced cache settings
|
313 |
*
|
314 |
* @since 1.4.0
|
315 |
-
* @change 1.4.
|
316 |
*/
|
317 |
|
318 |
public static function create_advcache_settings() {
|
319 |
|
320 |
-
//
|
321 |
-
|
322 |
-
|
323 |
-
// create advanced cache settings file
|
324 |
-
if ( empty( $options ) ) {
|
325 |
-
// ignore results and only call permalink structure recording
|
326 |
-
self::handle_trailing_slash();
|
327 |
-
} else {
|
328 |
-
// ignore results and call all advance cache settings recordings
|
329 |
-
self::validate_settings( $options );
|
330 |
-
}
|
331 |
}
|
332 |
|
333 |
|
@@ -909,7 +900,7 @@ final class Cache_Enabler {
|
|
909 |
} else {
|
910 |
if ( $_GET['_action'] === 'clearurl' ) {
|
911 |
// clear specific site URL cache
|
912 |
-
self::
|
913 |
} elseif ( $_GET['_action'] === 'clear' ) {
|
914 |
// clear specific site complete cache
|
915 |
self::clear_blog_id_cache( get_current_blog_id() );
|
@@ -930,7 +921,7 @@ final class Cache_Enabler {
|
|
930 |
} else {
|
931 |
if ( $_GET['_action'] === 'clearurl' ) {
|
932 |
// clear URL cache
|
933 |
-
self::
|
934 |
} elseif ( $_GET['_action'] === 'clear' ) {
|
935 |
// clear complete cache
|
936 |
self::clear_total_cache();
|
@@ -961,29 +952,6 @@ final class Cache_Enabler {
|
|
961 |
}
|
962 |
|
963 |
|
964 |
-
/**
|
965 |
-
* process clear request URL
|
966 |
-
*
|
967 |
-
* @since 1.4.2
|
968 |
-
* @change 1.4.2
|
969 |
-
*
|
970 |
-
* @param string $clear_url URL to be processed
|
971 |
-
*/
|
972 |
-
|
973 |
-
public static function process_clear_request_url( $clear_url ) {
|
974 |
-
|
975 |
-
// get home page URL
|
976 |
-
$home_page_url = get_site_url( null, '/' );
|
977 |
-
|
978 |
-
// check clear URL
|
979 |
-
if ( $clear_url === $home_page_url ) {
|
980 |
-
self::clear_home_page_cache();
|
981 |
-
} else {
|
982 |
-
self::clear_page_cache_by_url( $clear_url );
|
983 |
-
}
|
984 |
-
}
|
985 |
-
|
986 |
-
|
987 |
/**
|
988 |
* notification after clear cache
|
989 |
*
|
@@ -1258,7 +1226,7 @@ final class Cache_Enabler {
|
|
1258 |
* clear page cache by URL
|
1259 |
*
|
1260 |
* @since 1.0.0
|
1261 |
-
* @change 1.
|
1262 |
*
|
1263 |
* @param string $url URL of a page
|
1264 |
*/
|
@@ -1270,13 +1238,21 @@ final class Cache_Enabler {
|
|
1270 |
return;
|
1271 |
}
|
1272 |
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1280 |
|
1281 |
// clear cache by URL post hook
|
1282 |
do_action( 'ce_action_cache_by_url_cleared' );
|
@@ -1432,7 +1408,7 @@ final class Cache_Enabler {
|
|
1432 |
* check to bypass the cache
|
1433 |
*
|
1434 |
* @since 1.0.0
|
1435 |
-
* @change 1.4.
|
1436 |
*
|
1437 |
* @return boolean true if exception, false otherwise
|
1438 |
*
|
@@ -1451,7 +1427,12 @@ final class Cache_Enabler {
|
|
1451 |
return true;
|
1452 |
}
|
1453 |
|
1454 |
-
// check
|
|
|
|
|
|
|
|
|
|
|
1455 |
if ( self::_is_index() || is_search() || is_404() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() ) {
|
1456 |
return true;
|
1457 |
}
|
@@ -1519,6 +1500,33 @@ final class Cache_Enabler {
|
|
1519 |
}
|
1520 |
|
1521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1522 |
/**
|
1523 |
* minify HTML
|
1524 |
*
|
@@ -1672,12 +1680,12 @@ final class Cache_Enabler {
|
|
1672 |
* handle cache
|
1673 |
*
|
1674 |
* @since 1.0.0
|
1675 |
-
* @change 1.4.
|
1676 |
*/
|
1677 |
|
1678 |
public static function handle_cache() {
|
1679 |
|
1680 |
-
//
|
1681 |
if ( self::_bypass_cache() ) {
|
1682 |
return;
|
1683 |
}
|
@@ -1696,11 +1704,6 @@ final class Cache_Enabler {
|
|
1696 |
return;
|
1697 |
}
|
1698 |
|
1699 |
-
// check trailing slash
|
1700 |
-
if ( self::handle_trailing_slash() ) {
|
1701 |
-
return;
|
1702 |
-
}
|
1703 |
-
|
1704 |
// get cache expiry status
|
1705 |
$expired = call_user_func(
|
1706 |
array(
|
@@ -1978,39 +1981,26 @@ final class Cache_Enabler {
|
|
1978 |
|
1979 |
|
1980 |
/**
|
1981 |
-
*
|
1982 |
*
|
1983 |
-
* @since 1.
|
1984 |
-
* @change 1.4.
|
1985 |
*
|
1986 |
-
* @return boolean true if
|
1987 |
*/
|
1988 |
|
1989 |
-
public static function
|
1990 |
|
1991 |
$permalink_structure = get_option( 'permalink_structure' );
|
1992 |
|
|
|
1993 |
if ( $permalink_structure && preg_match( '/\/$/', $permalink_structure ) ) {
|
1994 |
-
//
|
1995 |
-
|
1996 |
-
'permalink_trailing_slash' => true,
|
1997 |
-
) );
|
1998 |
-
// if trailing slash is missing, check if we have to bypass the cache to allow a redirect
|
1999 |
-
if ( ! preg_match( '/\/(|\?.*)$/', $_SERVER['REQUEST_URI'] ) ) {
|
2000 |
-
return true;
|
2001 |
-
}
|
2002 |
} else {
|
2003 |
-
//
|
2004 |
-
|
2005 |
-
'permalink_trailing_slash' => false,
|
2006 |
-
) );
|
2007 |
-
// if trailing slash is appended, check if we have to bypass the cache to allow a redirect
|
2008 |
-
if ( preg_match( '/(?!^)\/(|\?.*)$/', $_SERVER['REQUEST_URI'] ) ) {
|
2009 |
-
return true;
|
2010 |
-
}
|
2011 |
}
|
2012 |
-
|
2013 |
-
return false;
|
2014 |
}
|
2015 |
|
2016 |
|
@@ -2063,11 +2053,19 @@ final class Cache_Enabler {
|
|
2063 |
self::clear_total_cache();
|
2064 |
}
|
2065 |
|
2066 |
-
//
|
2067 |
-
self::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2068 |
|
2069 |
// record cache expiry for advanced cache
|
2070 |
-
if ( $data['expires'] > 0 ){
|
2071 |
Cache_Enabler_Disk::record_advcache_settings( array(
|
2072 |
'expires' => $data['expires'],
|
2073 |
) );
|
312 |
* create or update advanced cache settings
|
313 |
*
|
314 |
* @since 1.4.0
|
315 |
+
* @change 1.4.3
|
316 |
*/
|
317 |
|
318 |
public static function create_advcache_settings() {
|
319 |
|
320 |
+
// ignore results and create advanced cache settings file
|
321 |
+
self::validate_settings( self::_get_options() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
}
|
323 |
|
324 |
|
900 |
} else {
|
901 |
if ( $_GET['_action'] === 'clearurl' ) {
|
902 |
// clear specific site URL cache
|
903 |
+
self::clear_page_cache_by_url( $clear_url );
|
904 |
} elseif ( $_GET['_action'] === 'clear' ) {
|
905 |
// clear specific site complete cache
|
906 |
self::clear_blog_id_cache( get_current_blog_id() );
|
921 |
} else {
|
922 |
if ( $_GET['_action'] === 'clearurl' ) {
|
923 |
// clear URL cache
|
924 |
+
self::clear_page_cache_by_url( $clear_url );
|
925 |
} elseif ( $_GET['_action'] === 'clear' ) {
|
926 |
// clear complete cache
|
927 |
self::clear_total_cache();
|
952 |
}
|
953 |
|
954 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
955 |
/**
|
956 |
* notification after clear cache
|
957 |
*
|
1226 |
* clear page cache by URL
|
1227 |
*
|
1228 |
* @since 1.0.0
|
1229 |
+
* @change 1.4.3
|
1230 |
*
|
1231 |
* @param string $url URL of a page
|
1232 |
*/
|
1238 |
return;
|
1239 |
}
|
1240 |
|
1241 |
+
// get home page URL
|
1242 |
+
$home_page_url = get_site_url( null, '/' );
|
1243 |
+
|
1244 |
+
// check if URL is the home page
|
1245 |
+
if ( $url === $home_page_url ) {
|
1246 |
+
self::clear_home_page_cache();
|
1247 |
+
} else {
|
1248 |
+
call_user_func(
|
1249 |
+
array(
|
1250 |
+
self::$disk,
|
1251 |
+
'delete_asset',
|
1252 |
+
),
|
1253 |
+
$url
|
1254 |
+
);
|
1255 |
+
}
|
1256 |
|
1257 |
// clear cache by URL post hook
|
1258 |
do_action( 'ce_action_cache_by_url_cleared' );
|
1408 |
* check to bypass the cache
|
1409 |
*
|
1410 |
* @since 1.0.0
|
1411 |
+
* @change 1.4.3
|
1412 |
*
|
1413 |
* @return boolean true if exception, false otherwise
|
1414 |
*
|
1427 |
return true;
|
1428 |
}
|
1429 |
|
1430 |
+
// check trailing slash
|
1431 |
+
if ( self::_bypass_cache_for_trailing_slash() ) {
|
1432 |
+
return true;
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
// check conditional tags
|
1436 |
if ( self::_is_index() || is_search() || is_404() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() ) {
|
1437 |
return true;
|
1438 |
}
|
1500 |
}
|
1501 |
|
1502 |
|
1503 |
+
/**
|
1504 |
+
* bypass cache for trailing slash
|
1505 |
+
*
|
1506 |
+
* @since 1.4.3
|
1507 |
+
* @change 1.4.3
|
1508 |
+
*
|
1509 |
+
* @return boolean true if cache should be bypassed to allow a redirect, false otherwise
|
1510 |
+
*/
|
1511 |
+
|
1512 |
+
private static function _bypass_cache_for_trailing_slash() {
|
1513 |
+
|
1514 |
+
if ( self::permalink_structure_has_trailing_slash() ) {
|
1515 |
+
// if trailing slash is missing, check if we have to bypass the cache to allow a redirect
|
1516 |
+
if ( ! preg_match( '/\/(|\?.*)$/', $_SERVER['REQUEST_URI'] ) ) {
|
1517 |
+
return true;
|
1518 |
+
}
|
1519 |
+
} else {
|
1520 |
+
// if trailing slash is appended, check if we have to bypass the cache to allow a redirect
|
1521 |
+
if ( preg_match( '/(?!^)\/(|\?.*)$/', $_SERVER['REQUEST_URI'] ) ) {
|
1522 |
+
return true;
|
1523 |
+
}
|
1524 |
+
}
|
1525 |
+
|
1526 |
+
return false;
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
|
1530 |
/**
|
1531 |
* minify HTML
|
1532 |
*
|
1680 |
* handle cache
|
1681 |
*
|
1682 |
* @since 1.0.0
|
1683 |
+
* @change 1.4.3
|
1684 |
*/
|
1685 |
|
1686 |
public static function handle_cache() {
|
1687 |
|
1688 |
+
// check if cache needs to be bypassed
|
1689 |
if ( self::_bypass_cache() ) {
|
1690 |
return;
|
1691 |
}
|
1704 |
return;
|
1705 |
}
|
1706 |
|
|
|
|
|
|
|
|
|
|
|
1707 |
// get cache expiry status
|
1708 |
$expired = call_user_func(
|
1709 |
array(
|
1981 |
|
1982 |
|
1983 |
/**
|
1984 |
+
* permalink structure has trailing slash
|
1985 |
*
|
1986 |
+
* @since 1.4.3
|
1987 |
+
* @change 1.4.3
|
1988 |
*
|
1989 |
+
* @return boolean true if permalink structure has a trailing slash, false otherwise
|
1990 |
*/
|
1991 |
|
1992 |
+
public static function permalink_structure_has_trailing_slash() {
|
1993 |
|
1994 |
$permalink_structure = get_option( 'permalink_structure' );
|
1995 |
|
1996 |
+
// check permalink structure
|
1997 |
if ( $permalink_structure && preg_match( '/\/$/', $permalink_structure ) ) {
|
1998 |
+
// permalink structure has a trailing slash
|
1999 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
2000 |
} else {
|
2001 |
+
// permalink structure does not have a trailing slash
|
2002 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
2003 |
}
|
|
|
|
|
2004 |
}
|
2005 |
|
2006 |
|
2053 |
self::clear_total_cache();
|
2054 |
}
|
2055 |
|
2056 |
+
// record permalink structure for advanced cache
|
2057 |
+
if ( self::permalink_structure_has_trailing_slash() ) {
|
2058 |
+
Cache_Enabler_Disk::record_advcache_settings( array(
|
2059 |
+
'permalink_trailing_slash' => true,
|
2060 |
+
) );
|
2061 |
+
} else {
|
2062 |
+
Cache_Enabler_Disk::record_advcache_settings( array(
|
2063 |
+
'permalink_trailing_slash' => false,
|
2064 |
+
) );
|
2065 |
+
}
|
2066 |
|
2067 |
// record cache expiry for advanced cache
|
2068 |
+
if ( $data['expires'] > 0 ) {
|
2069 |
Cache_Enabler_Disk::record_advcache_settings( array(
|
2070 |
'expires' => $data['expires'],
|
2071 |
) );
|
readme.txt
CHANGED
@@ -81,13 +81,17 @@ When combined with Optimus, the WordPress Cache Enabler allows you to easily del
|
|
81 |
|
82 |
== Changelog ==
|
83 |
|
|
|
|
|
|
|
|
|
84 |
= 1.4.2 =
|
85 |
* Update cache clearing for the Clear URL Cache admin bar button
|
86 |
* Update scheme-based caching
|
87 |
* Fix advanced cache
|
88 |
|
89 |
= 1.4.1 =
|
90 |
-
* Fix
|
91 |
|
92 |
= 1.4.0 =
|
93 |
* Update default cache behavior for WooCommerce stock update
|
81 |
|
82 |
== Changelog ==
|
83 |
|
84 |
+
= 1.4.3 =
|
85 |
+
* Update URL cache clearing
|
86 |
+
* Update advcache settings
|
87 |
+
|
88 |
= 1.4.2 =
|
89 |
* Update cache clearing for the Clear URL Cache admin bar button
|
90 |
* Update scheme-based caching
|
91 |
* Fix advanced cache
|
92 |
|
93 |
= 1.4.1 =
|
94 |
+
* Fix undefined constant
|
95 |
|
96 |
= 1.4.0 =
|
97 |
* Update default cache behavior for WooCommerce stock update
|