Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.8 |
Comparing to | |
See all releases |
Code changes from version 1.6.7 to 1.6.8
- readme.txt +10 -3
- rest/class.wp-super-cache-rest-update-settings.php +3 -3
- wp-cache-config-sample.php +1 -1
- wp-cache-phase1.php +5 -14
- wp-cache-phase2.php +324 -237
- wp-cache.php +32 -39
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
-
* Tested up to: 5.2.
|
5 |
-
* Stable tag: 1.6.
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -266,6 +266,13 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
266 |
|
267 |
## Changelog ##
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
### 1.6.7 ###
|
270 |
* wp_cache_setting() can now save boolean values since many of the settings are bools. #676
|
271 |
* Check if $super_cache_enabled is true in a less strict way because it might be '1' rather than true. #677
|
@@ -722,4 +729,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
722 |
|
723 |
|
724 |
## Upgrade Notice ##
|
725 |
-
Bug fixes
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
+
* Tested up to: 5.2.2
|
5 |
+
* Stable tag: 1.6.8
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
266 |
|
267 |
## Changelog ##
|
268 |
|
269 |
+
### 1.6.8 ###
|
270 |
+
* Added new constants, WPSC_SERVE_DISABLED (disable serving of cached files) and WPSC_SUPERCACHE_ONLY (only serve supercache cache files). #682 and #672
|
271 |
+
* Hide get_post() warning on some sites. #684
|
272 |
+
* Check if WPCACHEHOME is set correctly before maybe updating it. #683
|
273 |
+
* Remove object cache support as it never worked properly. #681
|
274 |
+
* Add "logged in users" to the "do not cache for users" setting and rename that setting to "Cache Restrictions" #657
|
275 |
+
|
276 |
### 1.6.7 ###
|
277 |
* wp_cache_setting() can now save boolean values since many of the settings are bools. #676
|
278 |
* Check if $super_cache_enabled is true in a less strict way because it might be '1' rather than true. #677
|
729 |
|
730 |
|
731 |
## Upgrade Notice ##
|
732 |
+
Bug fixes and changes to settings page.
|
rest/class.wp-super-cache-rest-update-settings.php
CHANGED
@@ -233,12 +233,12 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
233 |
protected function set_wp_cache_not_logged_in( $value ) {
|
234 |
global $wp_cache_not_logged_in, $cache_path;
|
235 |
|
236 |
-
if (
|
237 |
if ( 0 == $wp_cache_not_logged_in && function_exists( 'prune_super_cache' ) ) {
|
238 |
prune_super_cache( $cache_path, true );
|
239 |
}
|
240 |
|
241 |
-
$wp_cache_not_logged_in =
|
242 |
|
243 |
} else {
|
244 |
$wp_cache_not_logged_in = 0;
|
@@ -454,6 +454,7 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
454 |
'is_cache_enabled' => 1,
|
455 |
'cache_rebuild_files' => 1,
|
456 |
'cache_compression' => 0,
|
|
|
457 |
);
|
458 |
wp_cache_enable();
|
459 |
if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
|
@@ -489,7 +490,6 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
489 |
'wp_supercache_cache_list',
|
490 |
'wp_cache_hello_world',
|
491 |
'wp_cache_clear_on_post_edit',
|
492 |
-
'wp_cache_not_logged_in',
|
493 |
'wp_cache_make_known_anon',
|
494 |
'wp_cache_object_cache',
|
495 |
'wp_cache_refresh_single_only',
|
233 |
protected function set_wp_cache_not_logged_in( $value ) {
|
234 |
global $wp_cache_not_logged_in, $cache_path;
|
235 |
|
236 |
+
if ( 0 != $value ) {
|
237 |
if ( 0 == $wp_cache_not_logged_in && function_exists( 'prune_super_cache' ) ) {
|
238 |
prune_super_cache( $cache_path, true );
|
239 |
}
|
240 |
|
241 |
+
$wp_cache_not_logged_in = (int) $value;
|
242 |
|
243 |
} else {
|
244 |
$wp_cache_not_logged_in = 0;
|
454 |
'is_cache_enabled' => 1,
|
455 |
'cache_rebuild_files' => 1,
|
456 |
'cache_compression' => 0,
|
457 |
+
'wp_cache_not_logged_in' => 2,
|
458 |
);
|
459 |
wp_cache_enable();
|
460 |
if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
|
490 |
'wp_supercache_cache_list',
|
491 |
'wp_cache_hello_world',
|
492 |
'wp_cache_clear_on_post_edit',
|
|
|
493 |
'wp_cache_make_known_anon',
|
494 |
'wp_cache_object_cache',
|
495 |
'wp_cache_refresh_single_only',
|
wp-cache-config-sample.php
CHANGED
@@ -54,7 +54,6 @@ $wp_super_cache_front_page_clear = 0;
|
|
54 |
$wp_super_cache_front_page_check = 0;
|
55 |
$wp_super_cache_front_page_notification = '0';
|
56 |
|
57 |
-
$wp_cache_object_cache = 0;
|
58 |
$wp_cache_anon_only = 0;
|
59 |
$wp_supercache_cache_list = 0;
|
60 |
$wp_cache_debug_to_file = 0;
|
@@ -76,6 +75,7 @@ $wp_cache_pages[ "author" ] = 0;
|
|
76 |
$wp_cache_hide_donation = 0;
|
77 |
$wp_cache_not_logged_in = 0;
|
78 |
$wp_cache_clear_on_post_edit = 0;
|
|
|
79 |
$wp_cache_mobile_enabled = 0;
|
80 |
$wp_cache_cron_check = 0;
|
81 |
$wp_cache_mfunc_enabled = 0;
|
54 |
$wp_super_cache_front_page_check = 0;
|
55 |
$wp_super_cache_front_page_notification = '0';
|
56 |
|
|
|
57 |
$wp_cache_anon_only = 0;
|
58 |
$wp_supercache_cache_list = 0;
|
59 |
$wp_cache_debug_to_file = 0;
|
75 |
$wp_cache_hide_donation = 0;
|
76 |
$wp_cache_not_logged_in = 0;
|
77 |
$wp_cache_clear_on_post_edit = 0;
|
78 |
+
$wp_cache_hello_world = 0;
|
79 |
$wp_cache_mobile_enabled = 0;
|
80 |
$wp_cache_cron_check = 0;
|
81 |
$wp_cache_mfunc_enabled = 0;
|
wp-cache-phase1.php
CHANGED
@@ -73,7 +73,11 @@ if (
|
|
73 |
|
74 |
$wp_start_time = microtime();
|
75 |
|
76 |
-
if (
|
|
|
|
|
|
|
|
|
77 |
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
|
78 |
return true;
|
79 |
}
|
@@ -84,7 +88,6 @@ if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon ) {
|
|
84 |
|
85 |
do_cacheaction( 'cache_init' );
|
86 |
|
87 |
-
|
88 |
if ( ! $cache_enabled || ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
|
89 |
return true;
|
90 |
}
|
@@ -108,18 +111,6 @@ if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6
|
|
108 |
|
109 |
$wp_cache_request_uri = $_SERVER['REQUEST_URI']; // Cache this in case any plugin modifies it.
|
110 |
|
111 |
-
if ( $wp_cache_object_cache ) {
|
112 |
-
if ( ! include_once WP_CONTENT_DIR . '/object-cache.php' ) {
|
113 |
-
return;
|
114 |
-
}
|
115 |
-
|
116 |
-
wp_cache_init(); // Note: wp-settings.php calls wp_cache_init() which clobbers the object made here.
|
117 |
-
|
118 |
-
if ( ! is_object( $wp_object_cache ) ) {
|
119 |
-
return;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
if ( defined( 'DOING_CRON' ) ) {
|
124 |
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
|
125 |
return true;
|
73 |
|
74 |
$wp_start_time = microtime();
|
75 |
|
76 |
+
if ( wpsc_is_backend() ) {
|
77 |
+
return true;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( wpsc_is_caching_user_disabled() ) {
|
81 |
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
|
82 |
return true;
|
83 |
}
|
88 |
|
89 |
do_cacheaction( 'cache_init' );
|
90 |
|
|
|
91 |
if ( ! $cache_enabled || ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
|
92 |
return true;
|
93 |
}
|
111 |
|
112 |
$wp_cache_request_uri = $_SERVER['REQUEST_URI']; // Cache this in case any plugin modifies it.
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
if ( defined( 'DOING_CRON' ) ) {
|
115 |
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
|
116 |
return true;
|
wp-cache-phase2.php
CHANGED
@@ -44,7 +44,7 @@ function wp_super_cache_init() {
|
|
44 |
|
45 |
function wp_cache_serve_cache_file() {
|
46 |
global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname, $wp_cache_gzip_encoding, $meta;
|
47 |
-
global $
|
48 |
global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled, $wpsc_served_header;
|
49 |
|
50 |
if ( wpsc_is_backend() ) {
|
@@ -57,27 +57,20 @@ function wp_cache_serve_cache_file() {
|
|
57 |
return false;
|
58 |
}
|
59 |
|
60 |
-
|
|
|
|
|
|
|
61 |
|
62 |
-
|
63 |
-
if ( !empty( $_GET ) ) {
|
64 |
-
wp_cache_debug( 'Non empty GET request. Not serving request from object cache. ' . wpsc_dump_get_request(), 1 );
|
65 |
-
return false;
|
66 |
-
}
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
$meta = json_decode( wp_cache_get( $meta_filename, 'supercache' ), true );
|
76 |
-
if ( is_array( $meta ) == false ) {
|
77 |
-
wp_cache_debug( 'Meta array from object cache corrupt. Ignoring cache.', 1 );
|
78 |
-
return true;
|
79 |
-
}
|
80 |
-
} elseif ( ( $cache_file && file_exists( $cache_file ) ) || file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
|
81 |
if ( file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
|
82 |
$cache_file = get_current_url_supercache_dir() . $cache_filename;
|
83 |
$meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
|
@@ -230,64 +223,41 @@ function wp_cache_serve_cache_file() {
|
|
230 |
if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
|
231 |
header( 'X-WP-Super-Cache: Served WPCache cache file' );
|
232 |
}
|
233 |
-
if ( $
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
}
|
244 |
-
if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
|
245 |
-
wp_cache_debug( 'Serving wp-cache dynamic file from object cache', 5 );
|
246 |
-
echo do_cacheaction( 'wpsc_cachedata', $cache );
|
247 |
} else {
|
248 |
-
|
249 |
-
echo $cache;
|
250 |
}
|
251 |
-
|
252 |
-
|
253 |
}
|
254 |
} else {
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
263 |
-
unset( $cache );
|
264 |
-
echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
|
265 |
-
} else {
|
266 |
-
echo do_cacheaction( 'wpsc_cachedata', $cache );
|
267 |
-
}
|
268 |
} else {
|
269 |
-
|
|
|
270 |
}
|
271 |
} else {
|
272 |
-
wp_cache_debug( '
|
273 |
-
|
274 |
-
$cache = wp_cache_get_legacy_cache( $cache_file );
|
275 |
-
$uncompressed = gzuncompress( $cache );
|
276 |
-
if ( $uncompressed ) {
|
277 |
-
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
278 |
-
echo $uncompressed;
|
279 |
-
} else {
|
280 |
-
wp_cache_debug( 'Compressed gzipped cache file from wp-cache', 1 );
|
281 |
-
echo $cache;
|
282 |
-
}
|
283 |
-
} else {
|
284 |
-
wp_cache_debug( 'Getting legacy cache file ' . $cache_file, 1 );
|
285 |
-
echo( wp_cache_get_legacy_cache( $cache_file ) );
|
286 |
-
}
|
287 |
}
|
288 |
-
wp_cache_debug( 'exit request', 5 );
|
289 |
-
die();
|
290 |
}
|
|
|
|
|
291 |
}
|
292 |
|
293 |
function wp_cache_get_legacy_cache( $cache_file ) {
|
@@ -315,6 +285,91 @@ function wp_cache_late_loader() {
|
|
315 |
wp_cache_phase2();
|
316 |
}
|
317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
function wp_cache_get_cookies_values() {
|
319 |
global $wpsc_cookies;
|
320 |
static $string = '';
|
@@ -829,28 +884,52 @@ function get_oc_key( $url = false ) {
|
|
829 |
}
|
830 |
|
831 |
function wp_supercache_cache_for_admins() {
|
832 |
-
if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() || defined( 'DOING_AJAX' ) )
|
833 |
-
return true;
|
834 |
|
835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
return true;
|
|
|
837 |
|
838 |
-
if (
|
839 |
return true;
|
|
|
840 |
|
841 |
-
$
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
wp_cache_debug( 'Removing auth from $_COOKIE to allow caching for logged in user (' . $cookie . ')', 5 );
|
850 |
-
unset( $_COOKIE[ $cookie ] );
|
851 |
-
}
|
852 |
}
|
853 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
}
|
855 |
|
856 |
/* returns true/false depending on location of $dir. */
|
@@ -1163,11 +1242,29 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1163 |
return true;
|
1164 |
}
|
1165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1166 |
function wp_cache_phase2() {
|
1167 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
|
1168 |
|
1169 |
if ( $cache_enabled == false ) {
|
1170 |
-
wp_cache_debug( 'Caching disabled!
|
|
|
|
|
1171 |
return false;
|
1172 |
}
|
1173 |
|
@@ -1213,6 +1310,20 @@ function wp_cache_phase2() {
|
|
1213 |
header( 'Vary: Accept-Encoding, Cookie' );
|
1214 |
}
|
1215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1216 |
ob_start( 'wp_cache_ob_callback' );
|
1217 |
wp_cache_debug( 'Created output buffer', 4 );
|
1218 |
|
@@ -1646,7 +1757,7 @@ function wpsc_is_fatal_error() {
|
|
1646 |
}
|
1647 |
|
1648 |
function wp_cache_ob_callback( $buffer ) {
|
1649 |
-
global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $
|
1650 |
$script = basename( $_SERVER[ 'PHP_SELF' ] );
|
1651 |
|
1652 |
// All the things that can stop a page being cached
|
@@ -1678,9 +1789,6 @@ function wp_cache_ob_callback( $buffer ) {
|
|
1678 |
} elseif ( $_SERVER["REQUEST_METHOD"] == 'DELETE' ) {
|
1679 |
wp_cache_debug( 'Not caching DELETE request.', 5 );
|
1680 |
$cache_this_page = false;
|
1681 |
-
} elseif ( $wp_cache_object_cache && !empty( $_GET ) ) {
|
1682 |
-
wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
|
1683 |
-
$cache_this_page = false;
|
1684 |
} elseif ( isset( $_GET[ 'preview' ] ) ) {
|
1685 |
wp_cache_debug( 'Not caching preview post.', 2 );
|
1686 |
$cache_this_page = false;
|
@@ -1835,7 +1943,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1835 |
global $wp_cache_gzip_encoding, $super_cache_enabled;
|
1836 |
global $gzsize, $supercacheonly;
|
1837 |
global $blog_cache_dir, $wp_supercache_cache_list;
|
1838 |
-
global $wp_cache_not_logged_in, $
|
1839 |
global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
|
1840 |
|
1841 |
if ( isset( $wp_cache_mfunc_enabled ) == false )
|
@@ -1899,7 +2007,13 @@ function wp_cache_get_ob(&$buffer) {
|
|
1899 |
|
1900 |
$tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
|
1901 |
|
1902 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1903 |
if( $super_cache_enabled ) {
|
1904 |
if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
|
1905 |
wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
|
@@ -1908,23 +2022,13 @@ function wp_cache_get_ob(&$buffer) {
|
|
1908 |
}
|
1909 |
|
1910 |
$cache_error = '';
|
1911 |
-
if (
|
1912 |
$super_cache_enabled = false;
|
1913 |
$cache_enabled = false;
|
1914 |
$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
|
1915 |
wp_cache_debug( 'Not caching for known user.', 5 );
|
1916 |
}
|
1917 |
|
1918 |
-
if ( $wp_cache_object_cache ) { // half on mode when using the object cache
|
1919 |
-
if ( wp_cache_get_cookies_values() != '' ) {
|
1920 |
-
$cache_enabled = false;
|
1921 |
-
$cache_error = 'Known User and using object. Only anonymous users cached.';
|
1922 |
-
}
|
1923 |
-
$super_cache_enabled = false;
|
1924 |
-
$supercacheonly = false;
|
1925 |
-
wp_cache_init(); // PHP5 destroys objects during shutdown
|
1926 |
-
}
|
1927 |
-
|
1928 |
if ( !$cache_enabled ) {
|
1929 |
wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
|
1930 |
wp_cache_writers_exit();
|
@@ -1956,42 +2060,51 @@ function wp_cache_get_ob(&$buffer) {
|
|
1956 |
|
1957 |
$fr = $fr2 = $gz = false;
|
1958 |
// Open wp-cache cache file
|
1959 |
-
if (
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1965 |
wp_cache_writers_exit();
|
1966 |
return wp_cache_maybe_dynamic( $buffer );
|
1967 |
-
}
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
$
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
|
1979 |
@fclose( $fr );
|
1980 |
@unlink( $tmp_wpcache_filename );
|
|
|
|
|
1981 |
wp_cache_writers_exit();
|
1982 |
return wp_cache_maybe_dynamic( $buffer );
|
1983 |
-
} elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
|
1984 |
-
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
1985 |
-
if (!$gz) {
|
1986 |
-
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
|
1987 |
-
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
|
1988 |
-
@fclose( $fr );
|
1989 |
-
@unlink( $tmp_wpcache_filename );
|
1990 |
-
@fclose( $fr2 );
|
1991 |
-
@unlink( $tmp_cache_filename );
|
1992 |
-
wp_cache_writers_exit();
|
1993 |
-
return wp_cache_maybe_dynamic( $buffer );
|
1994 |
-
}
|
1995 |
}
|
1996 |
}
|
1997 |
}
|
@@ -2024,8 +2137,6 @@ function wp_cache_get_ob(&$buffer) {
|
|
2024 |
wp_cache_debug( 'Writing dynamic buffer to supercache file.' );
|
2025 |
wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
|
2026 |
fputs( $fr2, $buffer );
|
2027 |
-
} elseif ( true == $wp_cache_object_cache ) {
|
2028 |
-
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
2029 |
}
|
2030 |
$wp_cache_meta[ 'dynamic' ] = true;
|
2031 |
if ( $wp_cache_mfunc_enabled == 1 && do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 ) {
|
@@ -2062,15 +2173,9 @@ function wp_cache_get_ob(&$buffer) {
|
|
2062 |
if ( $fr ) {
|
2063 |
wp_cache_debug( 'Writing gzipped buffer to wp-cache cache file.', 5 );
|
2064 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
2065 |
-
} elseif ( $cache_enabled && $wp_cache_object_cache ) {
|
2066 |
-
wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
|
2067 |
-
$added_cache = 1;
|
2068 |
}
|
2069 |
} else { // no compression
|
2070 |
-
if ( $
|
2071 |
-
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
2072 |
-
$added_cache = 1;
|
2073 |
-
} elseif ( $fr ) {
|
2074 |
wp_cache_debug( 'Writing non-gzipped buffer to wp-cache cache file.' );
|
2075 |
fputs($fr, '<?php die(); ?>' . $buffer);
|
2076 |
}
|
@@ -2087,61 +2192,62 @@ function wp_cache_get_ob(&$buffer) {
|
|
2087 |
}
|
2088 |
|
2089 |
$new_cache = true;
|
2090 |
-
if (
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
if (
|
2099 |
-
|
2100 |
-
@wp_mkdir_p( $dir );
|
2101 |
-
@unlink( $dir . $cache_filename );
|
2102 |
-
@rename( $tmp_wpcache_filename, $dir . $cache_filename );
|
2103 |
-
}
|
2104 |
-
if ( file_exists( $dir . $cache_filename ) ) {
|
2105 |
-
wp_cache_debug( "Renamed temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
2106 |
-
} else {
|
2107 |
-
wp_cache_debug( "FAILED to rename temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
2108 |
}
|
2109 |
-
$
|
|
|
2110 |
}
|
2111 |
-
|
2112 |
-
|
2113 |
-
fclose($fr2);
|
2114 |
-
if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
|
2115 |
-
wp_cache_writers_exit();
|
2116 |
-
wp_cache_debug( 'Warning! Not writing another page to front page cache.', 1 );
|
2117 |
-
return $buffer;
|
2118 |
-
} elseif ( filesize( $tmp_cache_filename ) == 0 ) {
|
2119 |
-
wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
|
2120 |
-
@unlink( $tmp_cache_filename );
|
2121 |
} else {
|
2122 |
-
|
2123 |
-
@unlink( $cache_fname );
|
2124 |
-
@rename( $tmp_cache_filename, $cache_fname );
|
2125 |
-
}
|
2126 |
-
wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
|
2127 |
-
$added_cache = 1;
|
2128 |
}
|
|
|
2129 |
}
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
|
|
|
|
|
|
2142 |
}
|
|
|
|
|
2143 |
}
|
2144 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2145 |
if ( $added_cache && isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
|
2146 |
update_option( 'wpsupercache_count', ( get_option( 'wpsupercache_count' ) + 1 ) );
|
2147 |
$last_urls = (array)get_option( 'supercache_last_cached' );
|
@@ -2407,7 +2513,7 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
|
|
2407 |
|
2408 |
function wp_cache_shutdown_callback() {
|
2409 |
global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
|
2410 |
-
global $wp_cache_request_uri, $wp_cache_key, $
|
2411 |
global $WPSC_HTTP_HOST, $wp_super_cache_query;
|
2412 |
|
2413 |
if ( ! function_exists( 'wpsc_init' ) ) {
|
@@ -2518,26 +2624,20 @@ function wp_cache_shutdown_callback() {
|
|
2518 |
|
2519 |
if( wp_cache_writers_entry() ) {
|
2520 |
wp_cache_debug( "Writing meta file: {$dir}meta-{$meta_file}", 2 );
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
}
|
2533 |
-
} else {
|
2534 |
-
wp_cache_debug( "Problem writing meta file: {$final_meta_filename}" );
|
2535 |
}
|
2536 |
-
}
|
2537 |
-
|
2538 |
-
if ( gzip_accepted() )
|
2539 |
-
$oc_key .= ".gz";
|
2540 |
-
wp_cache_set( $oc_key, $serial, 'supercache', $cache_max_time );
|
2541 |
}
|
2542 |
wp_cache_writers_exit();
|
2543 |
|
@@ -2552,7 +2652,7 @@ function wp_cache_shutdown_callback() {
|
|
2552 |
}
|
2553 |
}
|
2554 |
} else {
|
2555 |
-
wp_cache_debug( "Did not write meta file: meta-{$meta_file}
|
2556 |
}
|
2557 |
global $time_to_gc_cache;
|
2558 |
if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
|
@@ -2637,25 +2737,23 @@ function wp_cache_clear_cache_on_menu() {
|
|
2637 |
|
2638 |
/* Clear out the cache directory. */
|
2639 |
function wp_cache_clear_cache( $blog_id = 0 ) {
|
2640 |
-
global $cache_path
|
2641 |
-
|
2642 |
-
|
|
|
|
|
|
|
2643 |
} else {
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
prune_super_cache( $cache_path, true );
|
2648 |
-
} else {
|
2649 |
-
wp_cache_debug( "Clearing all cached files for blog $blog_id in wp_cache_clear_cache()", 4 );
|
2650 |
-
prune_super_cache( get_supercache_dir( $blog_id ), true );
|
2651 |
-
prune_super_cache( $cache_path . 'blogs/', true );
|
2652 |
-
}
|
2653 |
}
|
|
|
2654 |
do_action( 'wp_cache_cleared' );
|
2655 |
}
|
2656 |
|
2657 |
function wpsc_delete_post_archives( $post ) {
|
2658 |
-
$post = get_post( $post );
|
2659 |
if ( ! is_object( $post ) ) {
|
2660 |
return;
|
2661 |
}
|
@@ -2764,7 +2862,7 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
|
|
2764 |
|
2765 |
/* check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change() */
|
2766 |
function wp_cache_post_edit( $post_id ) {
|
2767 |
-
global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir
|
2768 |
static $last_post_edited = -1;
|
2769 |
|
2770 |
if ( $post_id == $last_post_edited ) {
|
@@ -2789,12 +2887,8 @@ function wp_cache_post_edit( $post_id ) {
|
|
2789 |
$last_post_edited = $post_id;
|
2790 |
if( $wp_cache_clear_on_post_edit ) {
|
2791 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
|
2792 |
-
|
2793 |
-
|
2794 |
-
} else {
|
2795 |
-
prune_super_cache( $blog_cache_dir, true );
|
2796 |
-
prune_super_cache( get_supercache_dir(), true );
|
2797 |
-
}
|
2798 |
} else {
|
2799 |
$action = current_filter();
|
2800 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on ${action}", 2 );
|
@@ -2804,10 +2898,6 @@ function wp_cache_post_edit( $post_id ) {
|
|
2804 |
}
|
2805 |
|
2806 |
function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
|
2807 |
-
global $wp_cache_object_cache;
|
2808 |
-
|
2809 |
-
if ( $wp_cache_object_cache )
|
2810 |
-
reset_oc_version();
|
2811 |
|
2812 |
$post_id = intval( $post_id );
|
2813 |
if( $post_id == 0 )
|
@@ -2837,7 +2927,7 @@ function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
|
|
2837 |
}
|
2838 |
|
2839 |
function wp_cache_post_change( $post_id ) {
|
2840 |
-
global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $wp_cache_refresh_single_only
|
2841 |
static $last_processed = -1;
|
2842 |
|
2843 |
if ( $post_id == $last_processed ) {
|
@@ -2889,9 +2979,6 @@ function wp_cache_post_change( $post_id ) {
|
|
2889 |
if ( $all != $all_backup )
|
2890 |
wp_cache_debug( 'wp_cache_post_change: $all changed by wpsc_delete_related_pages_on_edit filter: ' . intval( $all ) );
|
2891 |
|
2892 |
-
if ( $wp_cache_object_cache )
|
2893 |
-
reset_oc_version();
|
2894 |
-
|
2895 |
// Delete supercache files whenever a post change event occurs, even if supercache is currently disabled.
|
2896 |
$dir = get_supercache_dir();
|
2897 |
// make sure the front page has a rebuild file
|
44 |
|
45 |
function wp_cache_serve_cache_file() {
|
46 |
global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname, $wp_cache_gzip_encoding, $meta;
|
47 |
+
global $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get;
|
48 |
global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled, $wpsc_served_header;
|
49 |
|
50 |
if ( wpsc_is_backend() ) {
|
57 |
return false;
|
58 |
}
|
59 |
|
60 |
+
if ( defined( 'WPSC_SERVE_DISABLED' ) ) {
|
61 |
+
wp_cache_debug( 'wp_cache_serve_cache_file: WPSC_SERVE_DISABLED defined. Not serving cached files.' );
|
62 |
+
return false;
|
63 |
+
}
|
64 |
|
65 |
+
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
if (
|
68 |
+
! defined( 'WPSC_SUPERCACHE_ONLY' ) &&
|
69 |
+
(
|
70 |
+
( $cache_file && file_exists( $cache_file ) ) ||
|
71 |
+
file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename )
|
72 |
+
)
|
73 |
+
) {
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
if ( file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
|
75 |
$cache_file = get_current_url_supercache_dir() . $cache_filename;
|
76 |
$meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
|
223 |
if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
|
224 |
header( 'X-WP-Super-Cache: Served WPCache cache file' );
|
225 |
}
|
226 |
+
if ( isset( $meta[ 'dynamic' ] ) ) {
|
227 |
+
wp_cache_debug( 'Serving wp-cache dynamic file', 5 );
|
228 |
+
if ( $ungzip ) {
|
229 |
+
// attempt to uncompress the cached file just in case it's gzipped
|
230 |
+
$cache = wp_cache_get_legacy_cache( $cache_file );
|
231 |
+
$uncompressed = @gzuncompress( $cache );
|
232 |
+
if ( $uncompressed ) {
|
233 |
+
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
234 |
+
unset( $cache );
|
235 |
+
echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
|
|
|
|
|
|
|
|
|
236 |
} else {
|
237 |
+
echo do_cacheaction( 'wpsc_cachedata', $cache );
|
|
|
238 |
}
|
239 |
+
} else {
|
240 |
+
echo do_cacheaction( 'wpsc_cachedata', wp_cache_get_legacy_cache( $cache_file ) );
|
241 |
}
|
242 |
} else {
|
243 |
+
wp_cache_debug( 'Serving wp-cache static file', 5 );
|
244 |
+
if ( $ungzip ) {
|
245 |
+
$cache = wp_cache_get_legacy_cache( $cache_file );
|
246 |
+
$uncompressed = gzuncompress( $cache );
|
247 |
+
if ( $uncompressed ) {
|
248 |
+
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
249 |
+
echo $uncompressed;
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
} else {
|
251 |
+
wp_cache_debug( 'Compressed gzipped cache file from wp-cache', 1 );
|
252 |
+
echo $cache;
|
253 |
}
|
254 |
} else {
|
255 |
+
wp_cache_debug( 'Getting legacy cache file ' . $cache_file, 1 );
|
256 |
+
echo( wp_cache_get_legacy_cache( $cache_file ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
|
|
|
|
258 |
}
|
259 |
+
wp_cache_debug( 'exit request', 5 );
|
260 |
+
die();
|
261 |
}
|
262 |
|
263 |
function wp_cache_get_legacy_cache( $cache_file ) {
|
285 |
wp_cache_phase2();
|
286 |
}
|
287 |
|
288 |
+
function wpsc_get_auth_cookies() {
|
289 |
+
static $cached_cookies;
|
290 |
+
|
291 |
+
if ( isset( $cached_cookies ) && is_array( $cached_cookies ) ) {
|
292 |
+
return $cached_cookies;
|
293 |
+
}
|
294 |
+
|
295 |
+
$cookies = array_keys( $_COOKIE );
|
296 |
+
if ( empty( $cookies ) ) {
|
297 |
+
return array();
|
298 |
+
}
|
299 |
+
|
300 |
+
$auth_cookies = array();
|
301 |
+
$duplicate_cookies = array();
|
302 |
+
|
303 |
+
$wp_cookies = array(
|
304 |
+
'AUTH_COOKIE' => 'wordpress_',
|
305 |
+
'SECURE_AUTH_COOKIE' => 'wordpress_sec_',
|
306 |
+
'LOGGED_IN_COOKIE' => 'wordpress_logged_in_',
|
307 |
+
);
|
308 |
+
|
309 |
+
foreach ( $wp_cookies as $cookie_const => $cookie_prefix ) {
|
310 |
+
$cookie_key = strtolower( $cookie_const );
|
311 |
+
|
312 |
+
if ( defined( $cookie_const ) ) {
|
313 |
+
if ( in_array( constant( $cookie_const ), $cookies, true ) ) {
|
314 |
+
$auth_cookies[ $cookie_key ] = constant( $cookie_const );
|
315 |
+
}
|
316 |
+
|
317 |
+
continue;
|
318 |
+
}
|
319 |
+
|
320 |
+
$found_cookies = preg_grep( '`^' . preg_quote( $cookie_prefix, '`' ) . '([0-9a-f]+)$`', $cookies );
|
321 |
+
|
322 |
+
if ( count( $found_cookies ) === 1 ) {
|
323 |
+
$auth_cookies[ $cookie_key ] = reset( $found_cookies );
|
324 |
+
} elseif ( count( $found_cookies ) > 1 ) {
|
325 |
+
$duplicate_cookies = array_merge( $duplicate_cookies, $found_cookies );
|
326 |
+
$auth_cookies[ $cookie_key ] = $found_cookies;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
$cookie_hash = defined( 'COOKIEHASH' ) ? COOKIEHASH : '';
|
331 |
+
$other_cookies = array(
|
332 |
+
'comment_cookie' => 'comment_author_',
|
333 |
+
'postpass_cookie' => 'wp-postpass_',
|
334 |
+
);
|
335 |
+
|
336 |
+
foreach ( $other_cookies as $cookie_key => $cookie_prefix ) {
|
337 |
+
|
338 |
+
if ( $cookie_hash ) {
|
339 |
+
if ( in_array( $cookie_prefix . $cookie_hash, $cookies, true ) ) {
|
340 |
+
$auth_cookies[ $cookie_key ] = $cookie_prefix . $cookie_hash;
|
341 |
+
}
|
342 |
+
|
343 |
+
continue;
|
344 |
+
}
|
345 |
+
|
346 |
+
$found_cookies = preg_grep( '`^' . preg_quote( $cookie_prefix, '`' ) . '([0-9a-f]+)$`', $cookies );
|
347 |
+
|
348 |
+
if ( count( $found_cookies ) === 1 ) {
|
349 |
+
$auth_cookies[ $cookie_key ] = reset( $found_cookies );
|
350 |
+
} elseif ( count( $found_cookies ) > 1 ) {
|
351 |
+
$duplicate_cookies = array_merge( $duplicate_cookies, $found_cookies );
|
352 |
+
$auth_cookies[ $cookie_key ] = $found_cookies;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( ! $duplicate_cookies ) {
|
357 |
+
$cached_cookies = $auth_cookies;
|
358 |
+
}
|
359 |
+
|
360 |
+
if ( empty( $auth_cookies ) ) {
|
361 |
+
wp_cache_debug( 'wpsc_get_auth_cookies: no auth cookies detected', 5 );
|
362 |
+
} else {
|
363 |
+
if ( $duplicate_cookies ) {
|
364 |
+
wp_cache_debug( 'wpsc_get_auth_cookies: duplicate cookies detected( ' . implode( ', ', $duplicate_cookies ) . ' )', 5 );
|
365 |
+
} else {
|
366 |
+
wp_cache_debug( 'wpsc_get_auth_cookies: cookies detected: ' . implode( ', ', $auth_cookies ), 5 );
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
return $auth_cookies;
|
371 |
+
}
|
372 |
+
|
373 |
function wp_cache_get_cookies_values() {
|
374 |
global $wpsc_cookies;
|
375 |
static $string = '';
|
884 |
}
|
885 |
|
886 |
function wp_supercache_cache_for_admins() {
|
|
|
|
|
887 |
|
888 |
+
// Don't remove cookies for some requests.
|
889 |
+
if (
|
890 |
+
wpsc_is_backend() ||
|
891 |
+
$_SERVER['REQUEST_METHOD'] !== 'GET' ||
|
892 |
+
isset( $_GET['preview'], $_GET['customize_changeset_uuid'] ) || // WPCS: CSRF ok.
|
893 |
+
strpos( stripslashes( $_SERVER['REQUEST_URI'] ), '/wp-json/' ) !== false // WPCS: sanitization ok.
|
894 |
+
) {
|
895 |
return true;
|
896 |
+
}
|
897 |
|
898 |
+
if ( false === do_cacheaction( 'wp_supercache_remove_cookies', true ) ) {
|
899 |
return true;
|
900 |
+
}
|
901 |
|
902 |
+
$removed_cookies = array();
|
903 |
+
foreach ( wpsc_get_auth_cookies() as $cookie ) {
|
904 |
+
|
905 |
+
$cookies = is_array( $cookie ) ? $cookie : array( $cookie );
|
906 |
+
|
907 |
+
foreach ( $cookies as $cookie_key ) {
|
908 |
+
unset( $_COOKIE[ $cookie_key ] );
|
909 |
+
$removed_cookies[] = $cookie_key;
|
|
|
|
|
|
|
910 |
}
|
911 |
}
|
912 |
+
|
913 |
+
if ( ! empty( $removed_cookies ) ) {
|
914 |
+
wp_cache_debug( 'Removing auth from $_COOKIE to allow caching for logged in user ( ' . implode( ', ', $removed_cookies ) . ' )', 5 );
|
915 |
+
}
|
916 |
+
}
|
917 |
+
|
918 |
+
/*
|
919 |
+
* Check if caching is disabled for the current visitor based on their cookies
|
920 |
+
*/
|
921 |
+
function wpsc_is_caching_user_disabled() {
|
922 |
+
global $wp_cache_not_logged_in;
|
923 |
+
if ( $wp_cache_not_logged_in == 2 && wpsc_get_auth_cookies() ) {
|
924 |
+
wp_cache_debug( 'wpsc_is_caching_user_disabled: true because logged in' );
|
925 |
+
return true;
|
926 |
+
} elseif ( $wp_cache_not_logged_in == 1 && ! empty( $_COOKIE ) ) {
|
927 |
+
wp_cache_debug( 'wpsc_is_caching_user_disabled: true because cookie found' );
|
928 |
+
return true;
|
929 |
+
} else {
|
930 |
+
wp_cache_debug( 'wpsc_is_caching_user_disabled: false' );
|
931 |
+
return false;
|
932 |
+
}
|
933 |
}
|
934 |
|
935 |
/* returns true/false depending on location of $dir. */
|
1242 |
return true;
|
1243 |
}
|
1244 |
|
1245 |
+
function wpsc_shutdown_message() {
|
1246 |
+
static $did_wp_footer = false;
|
1247 |
+
global $wp_super_cache_comments;
|
1248 |
+
|
1249 |
+
if ( ! defined( 'WPSCSHUTDOWNMESSAGE' ) || ( isset( $wp_super_cache_comments) && ! $wp_super_cache_comments ) ) {
|
1250 |
+
return;
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
if ( ! $did_wp_footer ) {
|
1254 |
+
$did_wp_footer = true;
|
1255 |
+
register_shutdown_function( 'wpsc_shutdown_message' );
|
1256 |
+
} else {
|
1257 |
+
echo PHP_EOL . '<!-- WP Super Cache: ' . esc_html( constant( 'WPSCSHUTDOWNMESSAGE' ) ) . ' -->' . PHP_EOL;
|
1258 |
+
}
|
1259 |
+
}
|
1260 |
+
|
1261 |
function wp_cache_phase2() {
|
1262 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
|
1263 |
|
1264 |
if ( $cache_enabled == false ) {
|
1265 |
+
wp_cache_debug( 'wp_cache_phase2: Caching disabled! Exit' );
|
1266 |
+
define( 'WPSCSHUTDOWNMESSAGE', __( 'Caching disabled. Page not cached.', 'wp-super-cache' ) );
|
1267 |
+
add_action( 'wp_footer', 'wpsc_shutdown_message' );
|
1268 |
return false;
|
1269 |
}
|
1270 |
|
1310 |
header( 'Vary: Accept-Encoding, Cookie' );
|
1311 |
}
|
1312 |
|
1313 |
+
if ( wpsc_is_caching_user_disabled() ) {
|
1314 |
+
wp_cache_debug( 'wp_cache_phase2: Caching disabled for known user! Exit.' );
|
1315 |
+
define( 'WPSCSHUTDOWNMESSAGE', __( 'Caching disabled for known user. User logged in or cookie found.', 'wp-super-cache' ) );
|
1316 |
+
add_action( 'wp_footer', 'wpsc_shutdown_message' );
|
1317 |
+
return false;
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
if ( wp_cache_user_agent_is_rejected() ) {
|
1321 |
+
define( 'WPSCSHUTDOWNMESSAGE', __( 'Caching disabled because user agent was rejected.', 'wp-super-cache' ) );
|
1322 |
+
wp_cache_debug( 'wp_cache_phase2: No caching to do as user agent rejected.' );
|
1323 |
+
add_action( 'wp_footer', 'wpsc_shutdown_message' );
|
1324 |
+
return false;
|
1325 |
+
}
|
1326 |
+
|
1327 |
ob_start( 'wp_cache_ob_callback' );
|
1328 |
wp_cache_debug( 'Created output buffer', 4 );
|
1329 |
|
1757 |
}
|
1758 |
|
1759 |
function wp_cache_ob_callback( $buffer ) {
|
1760 |
+
global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled;
|
1761 |
$script = basename( $_SERVER[ 'PHP_SELF' ] );
|
1762 |
|
1763 |
// All the things that can stop a page being cached
|
1789 |
} elseif ( $_SERVER["REQUEST_METHOD"] == 'DELETE' ) {
|
1790 |
wp_cache_debug( 'Not caching DELETE request.', 5 );
|
1791 |
$cache_this_page = false;
|
|
|
|
|
|
|
1792 |
} elseif ( isset( $_GET[ 'preview' ] ) ) {
|
1793 |
wp_cache_debug( 'Not caching preview post.', 2 );
|
1794 |
$cache_this_page = false;
|
1943 |
global $wp_cache_gzip_encoding, $super_cache_enabled;
|
1944 |
global $gzsize, $supercacheonly;
|
1945 |
global $blog_cache_dir, $wp_supercache_cache_list;
|
1946 |
+
global $wp_cache_not_logged_in, $cache_max_time;
|
1947 |
global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
|
1948 |
|
1949 |
if ( isset( $wp_cache_mfunc_enabled ) == false )
|
2007 |
|
2008 |
$tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
|
2009 |
|
2010 |
+
if ( defined( 'WPSC_SUPERCACHE_ONLY' ) ) {
|
2011 |
+
$supercacheonly = true;
|
2012 |
+
wp_cache_debug( 'wp_cache_get_ob: WPSC_SUPERCACHE_ONLY defined. Only creating supercache files.' );
|
2013 |
+
} else {
|
2014 |
+
$supercacheonly = false;
|
2015 |
+
}
|
2016 |
+
|
2017 |
if( $super_cache_enabled ) {
|
2018 |
if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
|
2019 |
wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
|
2022 |
}
|
2023 |
|
2024 |
$cache_error = '';
|
2025 |
+
if ( wpsc_is_caching_user_disabled() ) {
|
2026 |
$super_cache_enabled = false;
|
2027 |
$cache_enabled = false;
|
2028 |
$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
|
2029 |
wp_cache_debug( 'Not caching for known user.', 5 );
|
2030 |
}
|
2031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2032 |
if ( !$cache_enabled ) {
|
2033 |
wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
|
2034 |
wp_cache_writers_exit();
|
2060 |
|
2061 |
$fr = $fr2 = $gz = false;
|
2062 |
// Open wp-cache cache file
|
2063 |
+
if ( ! $supercacheonly ) {
|
2064 |
+
$fr = @fopen( $tmp_wpcache_filename, 'w' );
|
2065 |
+
if ( ! $fr ) {
|
2066 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
|
2067 |
+
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
|
2068 |
+
wp_cache_writers_exit();
|
2069 |
+
return wp_cache_maybe_dynamic( $buffer );
|
2070 |
+
}
|
2071 |
+
} else {
|
2072 |
+
$user_info = wp_cache_get_cookies_values();
|
2073 |
+
$do_cache = apply_filters( 'do_createsupercache', $user_info );
|
2074 |
+
if (
|
2075 |
+
$super_cache_enabled &&
|
2076 |
+
(
|
2077 |
+
$user_info == '' ||
|
2078 |
+
$do_cache === true
|
2079 |
+
)
|
2080 |
+
) {
|
2081 |
+
$cache_fname = $dir . supercache_filename();
|
2082 |
+
$tmp_cache_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
|
2083 |
+
$fr2 = @fopen( $tmp_cache_filename, 'w' );
|
2084 |
+
if ( !$fr2 ) {
|
2085 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $tmp_cache_filename ), 1 );
|
2086 |
+
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
|
2087 |
+
@fclose( $fr );
|
2088 |
+
@unlink( $tmp_wpcache_filename );
|
2089 |
wp_cache_writers_exit();
|
2090 |
return wp_cache_maybe_dynamic( $buffer );
|
2091 |
+
} elseif (
|
2092 |
+
$cache_compression &&
|
2093 |
+
(
|
2094 |
+
! isset( $wp_cache_mfunc_enabled ) ||
|
2095 |
+
$wp_cache_mfunc_enabled == 0
|
2096 |
+
)
|
2097 |
+
) { // don't want to store compressed files if using dynamic content
|
2098 |
+
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
2099 |
+
if ( !$gz ) {
|
2100 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
|
2101 |
+
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
|
|
|
2102 |
@fclose( $fr );
|
2103 |
@unlink( $tmp_wpcache_filename );
|
2104 |
+
@fclose( $fr2 );
|
2105 |
+
@unlink( $tmp_cache_filename );
|
2106 |
wp_cache_writers_exit();
|
2107 |
return wp_cache_maybe_dynamic( $buffer );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2108 |
}
|
2109 |
}
|
2110 |
}
|
2137 |
wp_cache_debug( 'Writing dynamic buffer to supercache file.' );
|
2138 |
wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
|
2139 |
fputs( $fr2, $buffer );
|
|
|
|
|
2140 |
}
|
2141 |
$wp_cache_meta[ 'dynamic' ] = true;
|
2142 |
if ( $wp_cache_mfunc_enabled == 1 && do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 ) {
|
2173 |
if ( $fr ) {
|
2174 |
wp_cache_debug( 'Writing gzipped buffer to wp-cache cache file.', 5 );
|
2175 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
|
|
|
|
|
|
2176 |
}
|
2177 |
} else { // no compression
|
2178 |
+
if ( $fr ) {
|
|
|
|
|
|
|
2179 |
wp_cache_debug( 'Writing non-gzipped buffer to wp-cache cache file.' );
|
2180 |
fputs($fr, '<?php die(); ?>' . $buffer);
|
2181 |
}
|
2192 |
}
|
2193 |
|
2194 |
$new_cache = true;
|
2195 |
+
if ( $fr ) {
|
2196 |
+
$supercacheonly = false;
|
2197 |
+
fclose( $fr );
|
2198 |
+
if ( filesize( $tmp_wpcache_filename ) == 0 ) {
|
2199 |
+
wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$dir}{$cache_filename}", 5 );
|
2200 |
+
@unlink( $tmp_wpcache_filename );
|
2201 |
+
} else {
|
2202 |
+
if ( ! @rename( $tmp_wpcache_filename, $dir . $cache_filename ) ) {
|
2203 |
+
if ( false == is_dir( $dir ) ) {
|
2204 |
+
@wp_mkdir_p( $dir );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2205 |
}
|
2206 |
+
@unlink( $dir . $cache_filename );
|
2207 |
+
@rename( $tmp_wpcache_filename, $dir . $cache_filename );
|
2208 |
}
|
2209 |
+
if ( file_exists( $dir . $cache_filename ) ) {
|
2210 |
+
wp_cache_debug( "Renamed temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2211 |
} else {
|
2212 |
+
wp_cache_debug( "FAILED to rename temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
|
|
|
|
|
|
|
|
|
|
2213 |
}
|
2214 |
+
$added_cache = 1;
|
2215 |
}
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
if ( $fr2 ) {
|
2219 |
+
fclose( $fr2 );
|
2220 |
+
if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
|
2221 |
+
wp_cache_writers_exit();
|
2222 |
+
wp_cache_debug( 'Warning! Not writing another page to front page cache.', 1 );
|
2223 |
+
return $buffer;
|
2224 |
+
} elseif ( filesize( $tmp_cache_filename ) == 0 ) {
|
2225 |
+
wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
|
2226 |
+
@unlink( $tmp_cache_filename );
|
2227 |
+
} else {
|
2228 |
+
if ( ! @rename( $tmp_cache_filename, $cache_fname ) ) {
|
2229 |
+
@unlink( $cache_fname );
|
2230 |
+
@rename( $tmp_cache_filename, $cache_fname );
|
2231 |
}
|
2232 |
+
wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
|
2233 |
+
$added_cache = 1;
|
2234 |
}
|
2235 |
}
|
2236 |
+
if ( $gz ) {
|
2237 |
+
fclose( $gz );
|
2238 |
+
if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
|
2239 |
+
wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
|
2240 |
+
@unlink( $tmp_cache_filename . '.gz' );
|
2241 |
+
} else {
|
2242 |
+
if ( ! @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
|
2243 |
+
@unlink( $cache_fname . '.gz' );
|
2244 |
+
@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
|
2245 |
+
}
|
2246 |
+
wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
|
2247 |
+
$added_cache = 1;
|
2248 |
+
}
|
2249 |
+
}
|
2250 |
+
|
2251 |
if ( $added_cache && isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
|
2252 |
update_option( 'wpsupercache_count', ( get_option( 'wpsupercache_count' ) + 1 ) );
|
2253 |
$last_urls = (array)get_option( 'supercache_last_cached' );
|
2513 |
|
2514 |
function wp_cache_shutdown_callback() {
|
2515 |
global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
|
2516 |
+
global $wp_cache_request_uri, $wp_cache_key, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
|
2517 |
global $WPSC_HTTP_HOST, $wp_super_cache_query;
|
2518 |
|
2519 |
if ( ! function_exists( 'wpsc_init' ) ) {
|
2624 |
|
2625 |
if( wp_cache_writers_entry() ) {
|
2626 |
wp_cache_debug( "Writing meta file: {$dir}meta-{$meta_file}", 2 );
|
2627 |
+
|
2628 |
+
$tmp_meta_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
|
2629 |
+
$final_meta_filename = $dir . "meta-" . $meta_file;
|
2630 |
+
$fr = @fopen( $tmp_meta_filename, 'w');
|
2631 |
+
if ( $fr ) {
|
2632 |
+
fputs($fr, $serial);
|
2633 |
+
fclose($fr);
|
2634 |
+
@chmod( $tmp_meta_filename, 0666 & ~umask());
|
2635 |
+
if( !@rename( $tmp_meta_filename, $final_meta_filename ) ) {
|
2636 |
+
@unlink( $dir . $final_meta_filename );
|
2637 |
+
@rename( $tmp_meta_filename, $final_meta_filename );
|
|
|
|
|
|
|
2638 |
}
|
2639 |
+
} else {
|
2640 |
+
wp_cache_debug( "Problem writing meta file: {$final_meta_filename}" );
|
|
|
|
|
|
|
2641 |
}
|
2642 |
wp_cache_writers_exit();
|
2643 |
|
2652 |
}
|
2653 |
}
|
2654 |
} else {
|
2655 |
+
wp_cache_debug( "Did not write meta file: meta-{$meta_file}\nsupercacheonly: $supercacheonly\nwp_cache_not_logged_in: $wp_cache_not_logged_in\nnew_cache:$new_cache" );
|
2656 |
}
|
2657 |
global $time_to_gc_cache;
|
2658 |
if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
|
2737 |
|
2738 |
/* Clear out the cache directory. */
|
2739 |
function wp_cache_clear_cache( $blog_id = 0 ) {
|
2740 |
+
global $cache_path;
|
2741 |
+
|
2742 |
+
if ( $blog_id == 0 ) {
|
2743 |
+
wp_cache_debug( 'Clearing all cached files in wp_cache_clear_cache()', 4 );
|
2744 |
+
prune_super_cache( $cache_path . 'supercache/', true );
|
2745 |
+
prune_super_cache( $cache_path, true );
|
2746 |
} else {
|
2747 |
+
wp_cache_debug( "Clearing all cached files for blog $blog_id in wp_cache_clear_cache()", 4 );
|
2748 |
+
prune_super_cache( get_supercache_dir( $blog_id ), true );
|
2749 |
+
prune_super_cache( $cache_path . 'blogs/', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
2750 |
}
|
2751 |
+
|
2752 |
do_action( 'wp_cache_cleared' );
|
2753 |
}
|
2754 |
|
2755 |
function wpsc_delete_post_archives( $post ) {
|
2756 |
+
$post = @get_post( $post );
|
2757 |
if ( ! is_object( $post ) ) {
|
2758 |
return;
|
2759 |
}
|
2862 |
|
2863 |
/* check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change() */
|
2864 |
function wp_cache_post_edit( $post_id ) {
|
2865 |
+
global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
|
2866 |
static $last_post_edited = -1;
|
2867 |
|
2868 |
if ( $post_id == $last_post_edited ) {
|
2887 |
$last_post_edited = $post_id;
|
2888 |
if( $wp_cache_clear_on_post_edit ) {
|
2889 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
|
2890 |
+
prune_super_cache( $blog_cache_dir, true );
|
2891 |
+
prune_super_cache( get_supercache_dir(), true );
|
|
|
|
|
|
|
|
|
2892 |
} else {
|
2893 |
$action = current_filter();
|
2894 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on ${action}", 2 );
|
2898 |
}
|
2899 |
|
2900 |
function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
|
|
|
|
|
|
|
|
|
2901 |
|
2902 |
$post_id = intval( $post_id );
|
2903 |
if( $post_id == 0 )
|
2927 |
}
|
2928 |
|
2929 |
function wp_cache_post_change( $post_id ) {
|
2930 |
+
global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $wp_cache_refresh_single_only;
|
2931 |
static $last_processed = -1;
|
2932 |
|
2933 |
if ( $post_id == $last_processed ) {
|
2979 |
if ( $all != $all_backup )
|
2980 |
wp_cache_debug( 'wp_cache_post_change: $all changed by wpsc_delete_related_pages_on_edit filter: ' . intval( $all ) );
|
2981 |
|
|
|
|
|
|
|
2982 |
// Delete supercache files whenever a post change event occurs, even if supercache is currently disabled.
|
2983 |
$dir = get_supercache_dir();
|
2984 |
// make sure the front page has a rebuild file
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 1.6.
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -530,7 +530,7 @@ if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
|
|
530 |
}
|
531 |
|
532 |
function wp_cache_manager_updates() {
|
533 |
-
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $
|
534 |
global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
|
535 |
|
536 |
if ( !wpsupercache_site_admin() )
|
@@ -575,12 +575,13 @@ function wp_cache_manager_updates() {
|
|
575 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
576 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
577 |
}
|
578 |
-
$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_clear_on_post_edit', '
|
579 |
foreach( $advanced_settings as $setting ) {
|
580 |
if ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) {
|
581 |
$_POST[ $setting ] = 1;
|
582 |
}
|
583 |
}
|
|
|
584 |
}
|
585 |
|
586 |
if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
|
@@ -710,10 +711,11 @@ function wp_cache_manager_updates() {
|
|
710 |
}
|
711 |
wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file);
|
712 |
|
713 |
-
if( isset( $_POST[
|
714 |
-
if( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) )
|
715 |
-
prune_super_cache
|
716 |
-
|
|
|
717 |
} else {
|
718 |
$wp_cache_not_logged_in = 0;
|
719 |
}
|
@@ -728,15 +730,6 @@ function wp_cache_manager_updates() {
|
|
728 |
}
|
729 |
wp_cache_replace_line('^ *\$wp_cache_make_known_anon', "\$wp_cache_make_known_anon = " . $wp_cache_make_known_anon . ";", $wp_cache_config_file);
|
730 |
|
731 |
-
if( $_wp_using_ext_object_cache && isset( $_POST[ 'wp_cache_object_cache' ] ) ) {
|
732 |
-
if( $wp_cache_object_cache == 0 && function_exists( 'prune_super_cache' ) )
|
733 |
-
prune_super_cache( $cache_path, true );
|
734 |
-
$wp_cache_object_cache = 1;
|
735 |
-
} else {
|
736 |
-
$wp_cache_object_cache = 0;
|
737 |
-
}
|
738 |
-
wp_cache_replace_line('^ *\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file);
|
739 |
-
|
740 |
if( isset( $_POST[ 'wp_cache_refresh_single_only' ] ) ) {
|
741 |
$wp_cache_refresh_single_only = 1;
|
742 |
} else {
|
@@ -774,7 +767,7 @@ function wp_cache_manager() {
|
|
774 |
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled;
|
775 |
global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get;
|
776 |
global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret;
|
777 |
-
global $wp_super_cache_front_page_check, $
|
778 |
global $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $wp_cache_disable_utf8, $wp_cache_mfunc_enabled;
|
779 |
global $wp_super_cache_comments, $wp_cache_home_path, $wpsc_save_headers, $is_nginx;
|
780 |
|
@@ -1092,7 +1085,10 @@ table.wpsc-settings-table {
|
|
1092 |
<td>
|
1093 |
<fieldset>
|
1094 |
<legend class="hidden">Miscellaneous</legend>
|
1095 |
-
<
|
|
|
|
|
|
|
1096 |
<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php checked( $wp_cache_no_cache_for_get ); ?> value='1'> <?php _e( 'Don’t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
|
1097 |
<?php if ( ! defined( 'WPSC_DISABLE_COMPRESSION' ) ) : ?>
|
1098 |
<?php if ( ! function_exists( 'gzencode' ) ) : ?>
|
@@ -1144,9 +1140,6 @@ table.wpsc-settings-table {
|
|
1144 |
<label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You do not need this as it will slow down your website.', 'wp-super-cache' ); ?></label><br />
|
1145 |
<?php } ?>
|
1146 |
<label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded.', 'wp-super-cache' ); ?></label><br />
|
1147 |
-
<?php if ( $_wp_using_ext_object_cache ) {
|
1148 |
-
?><label><input type='checkbox' name='wp_cache_object_cache' <?php if( $wp_cache_object_cache ) echo "checked"; ?> value='1'> <?php echo __( 'Use object cache to store cached files.', 'wp-super-cache' ) . ' ' . __( '(Experimental)', 'wp-super-cache' ); ?></label><?php
|
1149 |
-
}?>
|
1150 |
<?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
|
1151 |
</fieldset>
|
1152 |
</td>
|
@@ -2585,16 +2578,26 @@ function wp_cache_create_advanced_cache() {
|
|
2585 |
return false;
|
2586 |
}
|
2587 |
|
2588 |
-
$file = file_get_contents( $global_config_file );
|
2589 |
if (
|
2590 |
-
! strpos( $
|
2591 |
(
|
2592 |
-
|
2593 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2594 |
)
|
2595 |
) {
|
2596 |
-
|
2597 |
-
|
|
|
|
|
|
|
|
|
|
|
2598 |
}
|
2599 |
$ret = true;
|
2600 |
|
@@ -2746,7 +2749,7 @@ function wp_cache_regenerate_cache_file_stats() {
|
|
2746 |
|
2747 |
function wp_cache_files() {
|
2748 |
global $cache_path, $file_prefix, $cache_max_time, $valid_nonce, $supercachedir, $super_cache_enabled, $blog_cache_dir, $cache_compression;
|
2749 |
-
global $
|
2750 |
|
2751 |
if ( '/' != substr($cache_path, -1)) {
|
2752 |
$cache_path .= '/';
|
@@ -2769,13 +2772,6 @@ function wp_cache_files() {
|
|
2769 |
echo "<a name='listfiles'></a>";
|
2770 |
echo '<fieldset class="options" id="show-this-fieldset"><h4>' . __( 'Cache Contents', 'wp-super-cache' ) . '</h4>';
|
2771 |
|
2772 |
-
if ( $wp_cache_object_cache ) {
|
2773 |
-
echo "<p>" . __( "Object cache in use. No cache listing available.", 'wp-super-cache' ) . "</p>";
|
2774 |
-
wp_cache_delete_buttons();
|
2775 |
-
echo "</fieldset>";
|
2776 |
-
return false;
|
2777 |
-
}
|
2778 |
-
|
2779 |
$cache_stats = get_option( 'supercache_stats' );
|
2780 |
if ( !is_array( $cache_stats ) || ( isset( $_GET[ 'listfiles' ] ) ) || ( $valid_nonce && array_key_exists('action', $_GET) && $_GET[ 'action' ] == 'regenerate_cache_stats' ) ) {
|
2781 |
$count = 0;
|
@@ -3027,13 +3023,10 @@ function wpsc_dirsize($directory, $sizes) {
|
|
3027 |
}
|
3028 |
|
3029 |
function wp_cache_clean_cache( $file_prefix, $all = false ) {
|
3030 |
-
global $cache_path, $supercachedir, $blog_cache_dir
|
3031 |
|
3032 |
do_action( 'wp_cache_cleared' );
|
3033 |
|
3034 |
-
if ( $wp_cache_object_cache && function_exists( "reset_oc_version" ) )
|
3035 |
-
reset_oc_version();
|
3036 |
-
|
3037 |
if ( $all == true && wpsupercache_site_admin() && function_exists( 'prune_super_cache' ) ) {
|
3038 |
prune_super_cache( $cache_path, true );
|
3039 |
return true;
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 1.6.8
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
530 |
}
|
531 |
|
532 |
function wp_cache_manager_updates() {
|
533 |
+
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
|
534 |
global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
|
535 |
|
536 |
if ( !wpsupercache_site_admin() )
|
575 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
576 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
577 |
}
|
578 |
+
$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_clear_on_post_edit', 'wp_cache_make_known_anon', 'wp_cache_refresh_single_only', 'cache_compression' );
|
579 |
foreach( $advanced_settings as $setting ) {
|
580 |
if ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) {
|
581 |
$_POST[ $setting ] = 1;
|
582 |
}
|
583 |
}
|
584 |
+
$_POST['wp_cache_not_logged_in'] = 2;
|
585 |
}
|
586 |
|
587 |
if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
|
711 |
}
|
712 |
wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file);
|
713 |
|
714 |
+
if ( isset( $_POST['wp_cache_not_logged_in'] ) && $_POST['wp_cache_not_logged_in'] != 0 ) {
|
715 |
+
if ( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) ) {
|
716 |
+
prune_super_cache( $cache_path, true );
|
717 |
+
}
|
718 |
+
$wp_cache_not_logged_in = (int)$_POST['wp_cache_not_logged_in'];
|
719 |
} else {
|
720 |
$wp_cache_not_logged_in = 0;
|
721 |
}
|
730 |
}
|
731 |
wp_cache_replace_line('^ *\$wp_cache_make_known_anon', "\$wp_cache_make_known_anon = " . $wp_cache_make_known_anon . ";", $wp_cache_config_file);
|
732 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
if( isset( $_POST[ 'wp_cache_refresh_single_only' ] ) ) {
|
734 |
$wp_cache_refresh_single_only = 1;
|
735 |
} else {
|
767 |
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled;
|
768 |
global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get;
|
769 |
global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret;
|
770 |
+
global $wp_super_cache_front_page_check, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes;
|
771 |
global $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $wp_cache_disable_utf8, $wp_cache_mfunc_enabled;
|
772 |
global $wp_super_cache_comments, $wp_cache_home_path, $wpsc_save_headers, $is_nginx;
|
773 |
|
1085 |
<td>
|
1086 |
<fieldset>
|
1087 |
<legend class="hidden">Miscellaneous</legend>
|
1088 |
+
<strong><?php echo __( 'Cache Restrictions', 'wp-super-cache' ); ?></strong><br />
|
1089 |
+
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 0 ); ?> value='0'> <?php echo __( 'Enable caching for all visitors.', 'wp-super-cache' ); ?></label><br />
|
1090 |
+
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 1 ); ?> value='1'> <?php echo __( 'Disable caching for visitors who have a cookie set in their browser.', 'wp-super-cache' ); ?></label><br />
|
1091 |
+
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 2 ); ?> value='2'> <?php echo __( 'Disable caching for logged in visitors.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br /><br />
|
1092 |
<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php checked( $wp_cache_no_cache_for_get ); ?> value='1'> <?php _e( 'Don’t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
|
1093 |
<?php if ( ! defined( 'WPSC_DISABLE_COMPRESSION' ) ) : ?>
|
1094 |
<?php if ( ! function_exists( 'gzencode' ) ) : ?>
|
1140 |
<label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You do not need this as it will slow down your website.', 'wp-super-cache' ); ?></label><br />
|
1141 |
<?php } ?>
|
1142 |
<label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded.', 'wp-super-cache' ); ?></label><br />
|
|
|
|
|
|
|
1143 |
<?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
|
1144 |
</fieldset>
|
1145 |
</td>
|
2578 |
return false;
|
2579 |
}
|
2580 |
|
|
|
2581 |
if (
|
2582 |
+
! strpos( file_get_contents( $global_config_file ), "WPCACHEHOME" ) ||
|
2583 |
(
|
2584 |
+
defined( 'WPCACHEHOME' ) &&
|
2585 |
+
(
|
2586 |
+
constant( 'WPCACHEHOME' ) == '' ||
|
2587 |
+
(
|
2588 |
+
constant( 'WPCACHEHOME' ) != '' &&
|
2589 |
+
! file_exists( constant( 'WPCACHEHOME' ) . '/wp-cache.php' )
|
2590 |
+
)
|
2591 |
+
)
|
2592 |
)
|
2593 |
) {
|
2594 |
+
if (
|
2595 |
+
! is_writeable_ACLSafe( $global_config_file ) ||
|
2596 |
+
! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', $line, $global_config_file )
|
2597 |
+
) {
|
2598 |
+
echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
|
2599 |
+
return false;
|
2600 |
+
}
|
2601 |
}
|
2602 |
$ret = true;
|
2603 |
|
2749 |
|
2750 |
function wp_cache_files() {
|
2751 |
global $cache_path, $file_prefix, $cache_max_time, $valid_nonce, $supercachedir, $super_cache_enabled, $blog_cache_dir, $cache_compression;
|
2752 |
+
global $wp_cache_preload_on;
|
2753 |
|
2754 |
if ( '/' != substr($cache_path, -1)) {
|
2755 |
$cache_path .= '/';
|
2772 |
echo "<a name='listfiles'></a>";
|
2773 |
echo '<fieldset class="options" id="show-this-fieldset"><h4>' . __( 'Cache Contents', 'wp-super-cache' ) . '</h4>';
|
2774 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2775 |
$cache_stats = get_option( 'supercache_stats' );
|
2776 |
if ( !is_array( $cache_stats ) || ( isset( $_GET[ 'listfiles' ] ) ) || ( $valid_nonce && array_key_exists('action', $_GET) && $_GET[ 'action' ] == 'regenerate_cache_stats' ) ) {
|
2777 |
$count = 0;
|
3023 |
}
|
3024 |
|
3025 |
function wp_cache_clean_cache( $file_prefix, $all = false ) {
|
3026 |
+
global $cache_path, $supercachedir, $blog_cache_dir;
|
3027 |
|
3028 |
do_action( 'wp_cache_cleared' );
|
3029 |
|
|
|
|
|
|
|
3030 |
if ( $all == true && wpsupercache_site_admin() && function_exists( 'prune_super_cache' ) ) {
|
3031 |
prune_super_cache( $cache_path, true );
|
3032 |
return true;
|