Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.6.3
- plugins/searchengine.php +0 -128
- readme.txt +24 -4
- wp-cache-base.php +1 -1
- wp-cache-phase1.php +22 -0
- wp-cache-phase2.php +74 -23
- wp-cache.php +136 -36
plugins/searchengine.php
DELETED
@@ -1,128 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function wp_supercache_searchengine( $string ) {
|
4 |
-
global $passingthrough, $nevershowads, $cache_no_adverts_for_friends;
|
5 |
-
|
6 |
-
$cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
|
7 |
-
if ( ! $cache_no_adverts_for_friends || '' != $string ) {
|
8 |
-
return $string;
|
9 |
-
}
|
10 |
-
|
11 |
-
if ( isset( $_COOKIE['7a1254cba80da02d5478d91cfd0a873a'] ) && '1' === $_COOKIE['7a1254cba80da02d5478d91cfd0a873a'] ) {
|
12 |
-
$string = 'searchengine';
|
13 |
-
} elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
|
14 |
-
if ( is_array( $passingthrough ) === false ) {
|
15 |
-
return $string;
|
16 |
-
}
|
17 |
-
|
18 |
-
foreach ( $passingthrough as $url ) {
|
19 |
-
if ( strpos( $_SERVER['HTTP_REFERER'], $url ) ) {
|
20 |
-
reset( $nevershowads );
|
21 |
-
$se = false;
|
22 |
-
foreach ( $nevershowads as $whitesite ) {
|
23 |
-
if ( false === strpos( $_SERVER['HTTP_REFERER'], $whitesite ) ) {
|
24 |
-
$se = true;
|
25 |
-
}
|
26 |
-
}
|
27 |
-
if ( $se ) {
|
28 |
-
$string = 'searchengine';
|
29 |
-
@setcookie( '7a1254cba80da02d5478d91cfd0a873a', 1, time() + 3600, '/' );
|
30 |
-
}
|
31 |
-
}
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
return $string;
|
36 |
-
}
|
37 |
-
add_cacheaction( 'wp_cache_get_cookies_values', 'wp_supercache_searchengine' );
|
38 |
-
|
39 |
-
function searchenginesupercache( $user_info ) {
|
40 |
-
if ( 'searchengine' === $user_info && is_single() && is_old_post() ) {
|
41 |
-
return true;
|
42 |
-
} else {
|
43 |
-
return false;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
function wpsc_get_searchengine_setting() {
|
48 |
-
global $cache_no_adverts_for_friends;
|
49 |
-
|
50 |
-
if ( ! isset( $cache_no_adverts_for_friends ) ) {
|
51 |
-
return 0;
|
52 |
-
}
|
53 |
-
|
54 |
-
$changed = false;
|
55 |
-
if ( 'yes' === $cache_no_adverts_for_friends || '1' === $cache_no_adverts_for_friends ) {
|
56 |
-
$cache_no_adverts_for_friends = 1;
|
57 |
-
$changed = true;
|
58 |
-
} elseif ( 'no' === $cache_no_adverts_for_friends ) {
|
59 |
-
$cache_no_adverts_for_friends = 0;
|
60 |
-
$changed = true;
|
61 |
-
}
|
62 |
-
if ( $changed && function_exists( 'wp_cache_setting' ) ) {
|
63 |
-
wp_cache_setting( 'cache_no_adverts_for_friends', $cache_no_adverts_for_friends );
|
64 |
-
}
|
65 |
-
|
66 |
-
return $cache_no_adverts_for_friends;
|
67 |
-
}
|
68 |
-
|
69 |
-
function searchengine_phase2_actions() {
|
70 |
-
global $cache_no_adverts_for_friends;
|
71 |
-
|
72 |
-
$cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
|
73 |
-
if ( $cache_no_adverts_for_friends ) {
|
74 |
-
add_filter( 'do_createsupercache', 'searchenginesupercache' );
|
75 |
-
}
|
76 |
-
}
|
77 |
-
add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
|
78 |
-
|
79 |
-
function wp_supercache_searchengine_admin() {
|
80 |
-
global $cache_no_adverts_for_friends, $valid_nonce;
|
81 |
-
|
82 |
-
$cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
|
83 |
-
|
84 |
-
if ( isset( $_POST['cache_no_adverts_for_friends'] ) && $valid_nonce ) {
|
85 |
-
if ( $cache_no_adverts_for_friends !== (int) $_POST['cache_no_adverts_for_friends'] ) {
|
86 |
-
$changed = 1;
|
87 |
-
} else {
|
88 |
-
$changed = 0;
|
89 |
-
}
|
90 |
-
$cache_no_adverts_for_friends = (int) $_POST['cache_no_adverts_for_friends'];
|
91 |
-
wp_cache_setting( 'cache_no_adverts_for_friends', $cache_no_adverts_for_friends );
|
92 |
-
}
|
93 |
-
?>
|
94 |
-
<fieldset id="no_adverts_for_friends-section" class="options">
|
95 |
-
<h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
|
96 |
-
<form name="wp_manager" action="" method="post">
|
97 |
-
<label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if ( $cache_no_adverts_for_friends ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
|
98 |
-
<label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php if ( ! $cache_no_adverts_for_friends ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
|
99 |
-
<?php
|
100 |
-
echo '<p>' . __( 'Provides support for <a href="https://odd.blog/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache' ) . '</p>';
|
101 |
-
if ( isset( $changed ) && $changed ) {
|
102 |
-
if ( $cache_no_adverts_for_friends ) {
|
103 |
-
$status = __( 'enabled', 'wp-super-cache' );
|
104 |
-
} else {
|
105 |
-
$status = __( 'disabled', 'wp-super-cache' );
|
106 |
-
}
|
107 |
-
echo '<p><strong>' . sprintf( __( 'No Adverts for Friends support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
|
108 |
-
}
|
109 |
-
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
|
110 |
-
wp_nonce_field( 'wp-cache' );
|
111 |
-
?>
|
112 |
-
</form>
|
113 |
-
</fieldset>
|
114 |
-
<?php
|
115 |
-
|
116 |
-
}
|
117 |
-
add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
|
118 |
-
|
119 |
-
function wpsc_cache_no_adverts_for_friends_list( $list ) {
|
120 |
-
$list['no_adverts_for_friends'] = array(
|
121 |
-
'key' => 'no_adverts_for_friends',
|
122 |
-
'url' => 'https://odd.blog/no-adverts-for-friends/',
|
123 |
-
'title' => __( 'No Adverts for Friends', 'wp-super-cache' ),
|
124 |
-
'desc' => __( 'Provides support for No Adverts for Friends plugin.', 'wp-super-cache' ),
|
125 |
-
);
|
126 |
-
return $list;
|
127 |
-
}
|
128 |
-
add_cacheaction( 'wpsc_filter_list', 'wpsc_cache_no_adverts_for_friends_list' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 4.9.
|
5 |
-
* Stable tag: 1.6.
|
6 |
* Requires at least: 3.0
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -89,6 +89,11 @@ There is one regular WordPress filter too. Use the "do_createsupercache" filter
|
|
89 |
to customize the checks made before caching. The filter accepts one parameter.
|
90 |
The output of WP-Cache's wp_cache_get_cookies_values() function.
|
91 |
|
|
|
|
|
|
|
|
|
|
|
92 |
See [plugins/searchengine.php](https://github.com/Automattic/wp-super-cache/blob/4cda5c0f2218e40e118232b5bf22d227fb3206b7/plugins/searchengine.php) as an example I use for my [No Adverts for Friends](https://odd.blog/no-adverts-for-friends/) plugin.
|
93 |
|
94 |
### Troubleshooting ###
|
@@ -200,7 +205,7 @@ Cached files are served before almost all of WordPress is loaded. While that's g
|
|
200 |
This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the wpsc_cachedata filter described in the previous answer to update or display dynamic information.
|
201 |
|
202 |
### Why do my WP Super Cache plugins disappear when I upgrade the plugin? ###
|
203 |
-
WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins.
|
204 |
|
205 |
### What does the Cache Rebuild feature do? ###
|
206 |
When a visitor leaves a comment the cached file for that page is deleted and the next visitor recreates the cached page. A page takes time to load so what happens if it receives 100 visitors during this time? There won't be a cached page so WordPress will serve a fresh page for each user and the plugin will try to create a cached page for each of those 100 visitors causing a huge load on your server. This feature stops this happening. The cached page is not cleared when a comment is left. It is marked for rebuilding instead. The next visitor within the next 10 seconds will regenerate the cached page while the old page is served to the other 99 visitors. The page is eventually loaded by the first visitor and the cached page updated. See [this post](https://odd.blog/2009/01/23/wp-super-cache-089/) for more.
|
@@ -261,6 +266,21 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
261 |
|
262 |
## Changelog ##
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
### 1.6.2 ###
|
265 |
* Fixed serving expired supercache files (#562)
|
266 |
* Write directly to the config file to avoid permission problems with wp-content. (#563)
|
@@ -663,4 +683,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
663 |
|
664 |
|
665 |
## Upgrade Notice ##
|
666 |
-
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
+
* Tested up to: 4.9.8
|
5 |
+
* Stable tag: 1.6.3
|
6 |
* Requires at least: 3.0
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
89 |
to customize the checks made before caching. The filter accepts one parameter.
|
90 |
The output of WP-Cache's wp_cache_get_cookies_values() function.
|
91 |
|
92 |
+
WP Super Cache has it's own plugin system. This code is loaded when WP Super Cache loads and can be used to change how caching is done. This is before most of WordPress loads so some functionality will not be available. Plugins can be located anywhere that PHP can load them. Add your own plugin by calling wpsc_add_plugin( $name ) where $name is the full filename and path to the plugin. You only need to call that function once to add it. Use wpsc_delete_plugin( $name ) to remove it from the list of loaded plugins.
|
93 |
+
|
94 |
+
The cookies WP Super Cache uses to identify "known users" can be modified now by adding the names of those cookies to a list in the plugin configuration. Use wpsc_add_cookie( $name ) to add a new cookie, and wpsc_delete_cookie( $name ) to remove it. The cookie names also modify the mod_rewrite rules used by the plugin but I recommend using Simple mode caching to avoid complications with updating the .htaccess file.
|
95 |
+
The cookie name and value are used to differenciate users so you can have one cookie, but different values for each type of user on your site for example. They'll be served different cache files.
|
96 |
+
|
97 |
See [plugins/searchengine.php](https://github.com/Automattic/wp-super-cache/blob/4cda5c0f2218e40e118232b5bf22d227fb3206b7/plugins/searchengine.php) as an example I use for my [No Adverts for Friends](https://odd.blog/no-adverts-for-friends/) plugin.
|
98 |
|
99 |
### Troubleshooting ###
|
205 |
This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the wpsc_cachedata filter described in the previous answer to update or display dynamic information.
|
206 |
|
207 |
### Why do my WP Super Cache plugins disappear when I upgrade the plugin? ###
|
208 |
+
WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can put your custom plugins in a different directory in a number of ways. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins. Or if you distribute a plugin that needs to load early you can use the function `wpsc_add_plugin( $filename )` to add a new plugin wherever it may be. Use `wpsc_delete_plugin( $filename )` to remove the plugin file. See [#574](https://github.com/Automattic/wp-super-cache/pull/574/) or [this post](https://odd.blog/2017/10/25/writing-wp-super-cache-plugins/) on writing WP Super Cache plugins.
|
209 |
|
210 |
### What does the Cache Rebuild feature do? ###
|
211 |
When a visitor leaves a comment the cached file for that page is deleted and the next visitor recreates the cached page. A page takes time to load so what happens if it receives 100 visitors during this time? There won't be a cached page so WordPress will serve a fresh page for each user and the plugin will try to create a cached page for each of those 100 visitors causing a huge load on your server. This feature stops this happening. The cached page is not cleared when a comment is left. It is marked for rebuilding instead. The next visitor within the next 10 seconds will regenerate the cached page while the old page is served to the other 99 visitors. The page is eventually loaded by the first visitor and the cached page updated. See [this post](https://odd.blog/2009/01/23/wp-super-cache-089/) for more.
|
266 |
|
267 |
## Changelog ##
|
268 |
|
269 |
+
### 1.6.3 ###
|
270 |
+
* Changes between [1.6.2 and 1.6.3](https://github.com/Automattic/wp-super-cache/compare/1.6.2...1.6.3)
|
271 |
+
* Added cookie helper functions (#580)
|
272 |
+
* Added plugin helper functions (#574)
|
273 |
+
* Added actions to modify cookie and plugin lists. (#582)
|
274 |
+
* Really disable garbage collection when timeout = 0 (#571)
|
275 |
+
* Added warnings about DISABLE_WP_CRON (#575)
|
276 |
+
* Don't clean expired cache files after preload if garbage collection is disabled (#572)
|
277 |
+
* On preload, if deleting a post don't delete the sub directories if it's the homepage. (#573)
|
278 |
+
* Fix generation of semaphores when using WP CLI (#576)
|
279 |
+
* Fix deleting from the admin bar (#578)
|
280 |
+
* Avoid a strpos() warning. (#579)
|
281 |
+
* Improve deleting of cache in edit/delete/publish actions (#577)
|
282 |
+
* Fixes to headers code (#496)
|
283 |
+
|
284 |
### 1.6.2 ###
|
285 |
* Fixed serving expired supercache files (#562)
|
286 |
* Write directly to the config file to avoid permission problems with wp-content. (#563)
|
683 |
|
684 |
|
685 |
## Upgrade Notice ##
|
686 |
+
Bug fixes and new features
|
wp-cache-base.php
CHANGED
@@ -17,7 +17,7 @@ if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == tr
|
|
17 |
$base = '';
|
18 |
}
|
19 |
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
|
20 |
-
if ( strpos( $request_uri, '/', 1 ) ) {
|
21 |
if ( $base == '/' ) {
|
22 |
$blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 );
|
23 |
} else {
|
17 |
$base = '';
|
18 |
}
|
19 |
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
|
20 |
+
if ( strlen( $request_uri ) > 0 && strpos( $request_uri, '/', 1 ) ) {
|
21 |
if ( $base == '/' ) {
|
22 |
$blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 );
|
23 |
} else {
|
wp-cache-phase1.php
CHANGED
@@ -49,6 +49,28 @@ if ( is_array( $plugins ) ) {
|
|
49 |
}
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
$wp_start_time = microtime();
|
53 |
|
54 |
if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
if ( isset( $wpsc_plugins ) && is_array( $wpsc_plugins ) ) {
|
53 |
+
foreach( $wpsc_plugins as $plugin_file ) {
|
54 |
+
if ( file_exists( ABSPATH . $plugin_file ) ) {
|
55 |
+
include_once( ABSPATH . $plugin_file );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
if (
|
61 |
+
file_exists( WPCACHEHOME . '../wp-super-cache-plugins/' ) &&
|
62 |
+
is_dir( WPCACHEHOME . '../wp-super-cache-plugins/' )
|
63 |
+
) {
|
64 |
+
$plugins = glob( WPCACHEHOME . '../wp-super-cache-plugins/*.php' );
|
65 |
+
if ( is_array( $plugins ) ) {
|
66 |
+
foreach ( $plugins as $plugin ) {
|
67 |
+
if ( is_file( $plugin ) ) {
|
68 |
+
require_once $plugin;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
$wp_start_time = microtime();
|
75 |
|
76 |
if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
|
wp-cache-phase2.php
CHANGED
@@ -120,7 +120,7 @@ function wp_cache_serve_cache_file() {
|
|
120 |
} elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {
|
121 |
wp_cache_debug( 'Saving headers. Cannot serve a supercache file.' );
|
122 |
return false;
|
123 |
-
} elseif ( ( filemtime( $file ) + $cache_max_time ) < time() ) {
|
124 |
wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $cache_max_time ) );
|
125 |
return false;
|
126 |
}
|
@@ -196,17 +196,15 @@ function wp_cache_serve_cache_file() {
|
|
196 |
|
197 |
// don't try to match modified dates if using dynamic code.
|
198 |
if ( $wp_cache_mfunc_enabled == 0 && $wp_supercache_304 ) {
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$remote_mod_time = $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ];
|
205 |
-
else
|
206 |
-
$remote_mod_time = null;
|
207 |
}
|
|
|
208 |
$local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT';
|
209 |
-
if ( !is_null($remote_mod_time) && $remote_mod_time == $local_mod_time ) {
|
210 |
header( $_SERVER[ 'SERVER_PROTOCOL' ] . " 304 Not Modified" );
|
211 |
exit();
|
212 |
}
|
@@ -322,6 +320,7 @@ function wp_cache_late_loader() {
|
|
322 |
}
|
323 |
|
324 |
function wp_cache_get_cookies_values() {
|
|
|
325 |
static $string = '';
|
326 |
|
327 |
if ( $string != '' ) {
|
@@ -350,6 +349,20 @@ function wp_cache_get_cookies_values() {
|
|
350 |
|
351 |
// If you use this hook, make sure you update your .htaccess rules with the same conditions
|
352 |
$string = do_cacheaction( 'wp_cache_get_cookies_values', $string );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
if ( $string != '' )
|
354 |
$string = md5( $string );
|
355 |
|
@@ -1340,15 +1353,21 @@ function wpcache_logged_in_message() {
|
|
1340 |
function wp_cache_user_agent_is_rejected() {
|
1341 |
global $cache_rejected_user_agent;
|
1342 |
|
1343 |
-
if (!
|
|
|
|
|
|
|
1344 |
$headers = apache_request_headers();
|
1345 |
-
if (
|
1346 |
-
if ( false == is_array( $cache_rejected_user_agent ) )
|
1347 |
return false;
|
1348 |
-
|
1349 |
-
|
|
|
|
|
1350 |
return true;
|
|
|
1351 |
}
|
|
|
1352 |
return false;
|
1353 |
}
|
1354 |
|
@@ -2325,6 +2344,11 @@ function wp_cache_rebuild_or_delete( $file ) {
|
|
2325 |
function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
|
2326 |
global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on;
|
2327 |
|
|
|
|
|
|
|
|
|
|
|
2328 |
clearstatcache();
|
2329 |
if( !wp_cache_writers_entry() )
|
2330 |
return false;
|
@@ -2662,6 +2686,10 @@ function wpsc_delete_post_archives( $post ) {
|
|
2662 |
}
|
2663 |
|
2664 |
function wpsc_delete_cats_tags( $post ) {
|
|
|
|
|
|
|
|
|
2665 |
$post = get_post($post);
|
2666 |
$categories = get_the_category($post->ID);
|
2667 |
if ( $categories ) {
|
@@ -2688,14 +2716,17 @@ function wpsc_delete_cats_tags( $post ) {
|
|
2688 |
}
|
2689 |
|
2690 |
function wpsc_post_transition( $new_status, $old_status, $post ) {
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
|
|
|
|
|
|
|
|
2697 |
wpsc_delete_post_archives( $post );
|
2698 |
-
$post_url = get_permalink( $post->ID );
|
2699 |
wpsc_delete_url_cache( $post_url );
|
2700 |
wp_cache_debug( 'wpsc_post_transition: deleting cache of post: ' . $post_url );
|
2701 |
}
|
@@ -2735,6 +2766,7 @@ function wp_cache_post_edit($post_id) {
|
|
2735 |
} else {
|
2736 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on post edit.", 2 );
|
2737 |
wp_cache_post_change( $post_id );
|
|
|
2738 |
}
|
2739 |
}
|
2740 |
|
@@ -3029,4 +3061,23 @@ function wp_cache_gc_watcher() {
|
|
3029 |
}
|
3030 |
}
|
3031 |
|
3032 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
} elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {
|
121 |
wp_cache_debug( 'Saving headers. Cannot serve a supercache file.' );
|
122 |
return false;
|
123 |
+
} elseif ( $cache_max_time > 0 && ( filemtime( $file ) + $cache_max_time ) < time() ) {
|
124 |
wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $cache_max_time ) );
|
125 |
return false;
|
126 |
}
|
196 |
|
197 |
// don't try to match modified dates if using dynamic code.
|
198 |
if ( $wp_cache_mfunc_enabled == 0 && $wp_supercache_304 ) {
|
199 |
+
$headers = apache_request_headers();
|
200 |
+
$remote_mod_time = isset ( $headers['If-Modified-Since'] ) ? $headers['If-Modified-Since'] : null;
|
201 |
+
|
202 |
+
if ( is_null( $remote_mod_time ) && isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
|
203 |
+
$remote_mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
|
|
|
|
|
|
204 |
}
|
205 |
+
|
206 |
$local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT';
|
207 |
+
if ( ! is_null( $remote_mod_time ) && $remote_mod_time == $local_mod_time ) {
|
208 |
header( $_SERVER[ 'SERVER_PROTOCOL' ] . " 304 Not Modified" );
|
209 |
exit();
|
210 |
}
|
320 |
}
|
321 |
|
322 |
function wp_cache_get_cookies_values() {
|
323 |
+
global $wpsc_cookies;
|
324 |
static $string = '';
|
325 |
|
326 |
if ( $string != '' ) {
|
349 |
|
350 |
// If you use this hook, make sure you update your .htaccess rules with the same conditions
|
351 |
$string = do_cacheaction( 'wp_cache_get_cookies_values', $string );
|
352 |
+
|
353 |
+
if (
|
354 |
+
isset( $wpsc_cookies ) &&
|
355 |
+
is_array( $wpsc_cookies ) &&
|
356 |
+
! empty( $wpsc_cookies )
|
357 |
+
) {
|
358 |
+
foreach( $wpsc_cookies as $name ) {
|
359 |
+
if ( isset( $_COOKIE[ $name ] ) ) {
|
360 |
+
wp_cache_debug( "wp_cache_get_cookies_values - found extra cookie: $name" );
|
361 |
+
$string .= $name . "=" . $_COOKIE[ $name ] . ",";
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
if ( $string != '' )
|
367 |
$string = md5( $string );
|
368 |
|
1353 |
function wp_cache_user_agent_is_rejected() {
|
1354 |
global $cache_rejected_user_agent;
|
1355 |
|
1356 |
+
if ( empty( $cache_rejected_user_agent ) || ! is_array( $cache_rejected_user_agent ) ) {
|
1357 |
+
return false;
|
1358 |
+
}
|
1359 |
+
|
1360 |
$headers = apache_request_headers();
|
1361 |
+
if ( empty( $headers['User-Agent'] ) ) {
|
|
|
1362 |
return false;
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
foreach ( $cache_rejected_user_agent as $user_agent ) {
|
1366 |
+
if ( ! empty( $user_agent ) && stristr( $headers['User-Agent'], $user_agent ) ) {
|
1367 |
return true;
|
1368 |
+
}
|
1369 |
}
|
1370 |
+
|
1371 |
return false;
|
1372 |
}
|
1373 |
|
2344 |
function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
|
2345 |
global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on;
|
2346 |
|
2347 |
+
if ( $cache_max_time == 0 ) {
|
2348 |
+
wp_cache_debug( "wp_cache_phase2_clean_expired: disabled because GC disabled.", 2 );
|
2349 |
+
return false;
|
2350 |
+
}
|
2351 |
+
|
2352 |
clearstatcache();
|
2353 |
if( !wp_cache_writers_entry() )
|
2354 |
return false;
|
2686 |
}
|
2687 |
|
2688 |
function wpsc_delete_cats_tags( $post ) {
|
2689 |
+
if ( function_exists( '_deprecated_function' ) ) {
|
2690 |
+
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.3', 'wpsc_delete_post_archives' );
|
2691 |
+
}
|
2692 |
+
|
2693 |
$post = get_post($post);
|
2694 |
$categories = get_the_category($post->ID);
|
2695 |
if ( $categories ) {
|
2716 |
}
|
2717 |
|
2718 |
function wpsc_post_transition( $new_status, $old_status, $post ) {
|
2719 |
+
|
2720 |
+
if ( $old_status === 'publish' && $new_status !== 'publish' ) { // post unpublished
|
2721 |
+
list( $permalink, $post_name ) = get_sample_permalink( $post->ID );
|
2722 |
+
$post_url = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink );
|
2723 |
+
}
|
2724 |
+
elseif ( $new_status === 'publish' ) { // post published or updated
|
2725 |
+
$post_url = get_permalink( $post->ID );
|
2726 |
+
}
|
2727 |
+
|
2728 |
+
if ( ! empty( $post_url ) ) {
|
2729 |
wpsc_delete_post_archives( $post );
|
|
|
2730 |
wpsc_delete_url_cache( $post_url );
|
2731 |
wp_cache_debug( 'wpsc_post_transition: deleting cache of post: ' . $post_url );
|
2732 |
}
|
2766 |
} else {
|
2767 |
wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on post edit.", 2 );
|
2768 |
wp_cache_post_change( $post_id );
|
2769 |
+
wpsc_delete_post_archives( $post_id ); // delete related archive pages.
|
2770 |
}
|
2771 |
}
|
2772 |
|
3061 |
}
|
3062 |
}
|
3063 |
|
3064 |
+
if ( ! function_exists( 'apache_request_headers' ) ) {
|
3065 |
+
/**
|
3066 |
+
* A fallback for get request headers.
|
3067 |
+
* Based on comments from http://php.net/manual/en/function.apache-request-headers.php
|
3068 |
+
*
|
3069 |
+
* @return array List of request headers
|
3070 |
+
*/
|
3071 |
+
function apache_request_headers() {
|
3072 |
+
$headers = array();
|
3073 |
+
|
3074 |
+
foreach ( array_keys( $_SERVER ) as $skey ) {
|
3075 |
+
if ( 0 === strpos( $skey, 'HTTP_' ) ) {
|
3076 |
+
$header = implode( '-', array_map( 'ucfirst', array_slice( explode( '_', strtolower( $skey ) ) , 1 ) ) );
|
3077 |
+
$headers[ $header ] = $_SERVER[ $skey ];
|
3078 |
+
}
|
3079 |
+
}
|
3080 |
+
|
3081 |
+
return $headers;
|
3082 |
+
}
|
3083 |
+
}
|
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+
|
@@ -66,6 +66,7 @@ wpsc_init();
|
|
66 |
* It's minimal list of global variables.
|
67 |
*/
|
68 |
global $super_cache_enabled, $cache_enabled, $wp_cache_home_path, $cache_path;
|
|
|
69 |
global $wp_cache_config_file, $wp_cache_config_file_sample;
|
70 |
|
71 |
if( !@include($wp_cache_config_file) ) {
|
@@ -82,9 +83,11 @@ if ( class_exists( 'WP_REST_Controller' ) ) {
|
|
82 |
}
|
83 |
|
84 |
function wp_super_cache_init_action() {
|
|
|
85 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
86 |
|
87 |
wpsc_register_post_hooks();
|
|
|
88 |
}
|
89 |
add_action( 'init', 'wp_super_cache_init_action' );
|
90 |
|
@@ -242,8 +245,14 @@ function wp_cache_manager_error_checks() {
|
|
242 |
return false;
|
243 |
}
|
244 |
|
245 |
-
if( $wp_cache_debug ||
|
246 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
$hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
|
248 |
if( strpos( $hostname, '/' ) )
|
249 |
$hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
|
@@ -419,7 +428,7 @@ function wp_cache_manager_error_checks() {
|
|
419 |
}
|
420 |
if( isset( $missing_mods) && is_array( $missing_mods ) ) {
|
421 |
?><div class='notice notice-warning'><h3><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h3>
|
422 |
-
<p><?php __( 'The following Apache modules are missing. The plugin will work in simple mode without them but in
|
423 |
echo "<ul>";
|
424 |
foreach( $missing_mods as $req => $desc ) {
|
425 |
echo "<li> $req - $desc</li>";
|
@@ -455,26 +464,40 @@ function wp_cache_manager_error_checks() {
|
|
455 |
}
|
456 |
add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
|
457 |
|
|
|
|
|
|
|
458 |
function admin_bar_delete_page() {
|
459 |
-
|
460 |
-
if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') )
|
461 |
return false;
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( $supercachepath ) ) != $supercachepath ) {
|
469 |
-
|
470 |
}
|
|
|
471 |
wpsc_delete_files( $path );
|
472 |
-
|
473 |
-
|
|
|
|
|
|
|
474 |
}
|
475 |
}
|
476 |
-
if (
|
477 |
add_action( 'admin_init', 'admin_bar_delete_page' );
|
|
|
478 |
|
479 |
function wp_cache_manager_updates() {
|
480 |
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $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_object_cache, $_wp_using_ext_object_cache, $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;
|
@@ -1819,21 +1842,6 @@ function wp_cache_sanitize_value($text, & $array) {
|
|
1819 |
return $text;
|
1820 |
}
|
1821 |
|
1822 |
-
// from tehjosh at gamingg dot net http://uk2.php.net/manual/en/function.apache-request-headers.php#73964
|
1823 |
-
// fixed bug in second substr()
|
1824 |
-
if( !function_exists('apache_request_headers') ) {
|
1825 |
-
function apache_request_headers() {
|
1826 |
-
$headers = array();
|
1827 |
-
foreach(array_keys($_SERVER) as $skey) {
|
1828 |
-
if(substr($skey, 0, 5) == "HTTP_") {
|
1829 |
-
$headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 5)))));
|
1830 |
-
$headers[$headername] = $_SERVER[$skey];
|
1831 |
-
}
|
1832 |
-
}
|
1833 |
-
return $headers;
|
1834 |
-
}
|
1835 |
-
}
|
1836 |
-
|
1837 |
function wp_cache_update_rejected_ua() {
|
1838 |
global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce;
|
1839 |
|
@@ -3289,7 +3297,7 @@ function wpsc_get_htaccess_info() {
|
|
3289 |
}
|
3290 |
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
|
3291 |
$condition_rules[] = "RewriteCond %{QUERY_STRING} ^$";
|
3292 |
-
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . "|wp-postpass_).*$";
|
3293 |
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
|
3294 |
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
|
3295 |
if ( $wp_cache_mobile_enabled ) {
|
@@ -3371,8 +3379,13 @@ function clear_post_supercache( $post_id ) {
|
|
3371 |
if ( false == @is_dir( $dir ) )
|
3372 |
return false;
|
3373 |
|
3374 |
-
|
3375 |
-
|
|
|
|
|
|
|
|
|
|
|
3376 |
prune_super_cache( $dir, true );
|
3377 |
} else {
|
3378 |
wpsc_delete_files( $dir );
|
@@ -3545,6 +3558,7 @@ function wp_cron_preload_cache() {
|
|
3545 |
wp_cache_debug( 'wp_cron_preload_cache: scheduling the next preload in 30 seconds.', 5 );
|
3546 |
wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' );
|
3547 |
}
|
|
|
3548 |
} else {
|
3549 |
$msg = '';
|
3550 |
update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
|
@@ -3562,8 +3576,10 @@ function wp_cron_preload_cache() {
|
|
3562 |
}
|
3563 |
if ( $wp_cache_preload_email_me )
|
3564 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Cache Preload Completed', 'wp-super-cache' ), home_url() ), __( "Cleaning up old supercache files.", 'wp-super-cache' ) . "\n" . $msg );
|
3565 |
-
|
3566 |
-
|
|
|
|
|
3567 |
}
|
3568 |
@unlink( $mutex );
|
3569 |
}
|
@@ -4047,3 +4063,87 @@ function wpsc_update_plugin_list( $update ) {
|
|
4047 |
}
|
4048 |
}
|
4049 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.3
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
66 |
* It's minimal list of global variables.
|
67 |
*/
|
68 |
global $super_cache_enabled, $cache_enabled, $wp_cache_home_path, $cache_path;
|
69 |
+
global $wp_cache_mutex_disabled, $mutex_filename, $sem_id;
|
70 |
global $wp_cache_config_file, $wp_cache_config_file_sample;
|
71 |
|
72 |
if( !@include($wp_cache_config_file) ) {
|
83 |
}
|
84 |
|
85 |
function wp_super_cache_init_action() {
|
86 |
+
|
87 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
88 |
|
89 |
wpsc_register_post_hooks();
|
90 |
+
|
91 |
}
|
92 |
add_action( 'init', 'wp_super_cache_init_action' );
|
93 |
|
245 |
return false;
|
246 |
}
|
247 |
|
248 |
+
if ( $wp_cache_debug || ! $wp_cache_cron_check ) {
|
249 |
+
if ( defined( 'DISABLE_WP_CRON' ) && constant( 'DISABLE_WP_CRON' ) ) {
|
250 |
+
?>
|
251 |
+
<div class="notice notice-error"><h3><?php _e( 'CRON System Disabled', 'wp-super-cache' ); ?></h3>
|
252 |
+
<p><?php _e( 'The WordPress CRON jobs system is disabled. This means the garbage collection system will not work unless you run the CRON system manually.', 'wp-super-cache' ); ?></p>
|
253 |
+
</div>
|
254 |
+
<?php
|
255 |
+
} elseif ( function_exists( "wp_remote_get" ) == false ) {
|
256 |
$hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
|
257 |
if( strpos( $hostname, '/' ) )
|
258 |
$hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
|
428 |
}
|
429 |
if( isset( $missing_mods) && is_array( $missing_mods ) ) {
|
430 |
?><div class='notice notice-warning'><h3><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h3>
|
431 |
+
<p><?php __( 'The following Apache modules are missing. The plugin will work in simple mode without them but in expert mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ); ?></p><?php
|
432 |
echo "<ul>";
|
433 |
foreach( $missing_mods as $req => $desc ) {
|
434 |
echo "<li> $req - $desc</li>";
|
464 |
}
|
465 |
add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
|
466 |
|
467 |
+
/**
|
468 |
+
* Delete cache for a specific page.
|
469 |
+
*/
|
470 |
function admin_bar_delete_page() {
|
471 |
+
|
472 |
+
if ( function_exists( 'current_user_can' ) && false == current_user_can( 'delete_others_posts' ) ) {
|
473 |
return false;
|
474 |
+
}
|
475 |
+
|
476 |
+
$req_path = filter_input( INPUT_GET, 'path' );
|
477 |
+
$referer = wp_get_referer();
|
478 |
+
$valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
|
479 |
+
|
480 |
+
$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
|
481 |
+
|
482 |
+
if ( $path ) {
|
483 |
+
$path .= '/';
|
484 |
+
$supercachepath = realpath( get_supercache_dir() );
|
485 |
+
|
486 |
if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( $supercachepath ) ) != $supercachepath ) {
|
487 |
+
wp_die( 'Could not delete directory' );
|
488 |
}
|
489 |
+
|
490 |
wpsc_delete_files( $path );
|
491 |
+
}
|
492 |
+
|
493 |
+
if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
|
494 |
+
wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $req_path ) );
|
495 |
+
exit;
|
496 |
}
|
497 |
}
|
498 |
+
if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
|
499 |
add_action( 'admin_init', 'admin_bar_delete_page' );
|
500 |
+
}
|
501 |
|
502 |
function wp_cache_manager_updates() {
|
503 |
global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $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_object_cache, $_wp_using_ext_object_cache, $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;
|
1842 |
return $text;
|
1843 |
}
|
1844 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1845 |
function wp_cache_update_rejected_ua() {
|
1846 |
global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce;
|
1847 |
|
3297 |
}
|
3298 |
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
|
3299 |
$condition_rules[] = "RewriteCond %{QUERY_STRING} ^$";
|
3300 |
+
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . wpsc_get_extra_cookies() . "|wp-postpass_).*$";
|
3301 |
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
|
3302 |
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
|
3303 |
if ( $wp_cache_mobile_enabled ) {
|
3379 |
if ( false == @is_dir( $dir ) )
|
3380 |
return false;
|
3381 |
|
3382 |
+
if ( get_supercache_dir() == $dir ) {
|
3383 |
+
wp_cache_debug( "clear_post_supercache: not deleting post_id $post_id as it points at homepage: $dir" );
|
3384 |
+
return false;
|
3385 |
+
}
|
3386 |
+
|
3387 |
+
wp_cache_debug( "clear_post_supercache: post_id: $post_id. deleting files in $dir" );
|
3388 |
+
if ( get_post_type( $post_id ) != 'page') { // don't delete child pages if they exist
|
3389 |
prune_super_cache( $dir, true );
|
3390 |
} else {
|
3391 |
wpsc_delete_files( $dir );
|
3558 |
wp_cache_debug( 'wp_cron_preload_cache: scheduling the next preload in 30 seconds.', 5 );
|
3559 |
wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' );
|
3560 |
}
|
3561 |
+
wpsc_delete_files( get_supercache_dir() );
|
3562 |
} else {
|
3563 |
$msg = '';
|
3564 |
update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
|
3576 |
}
|
3577 |
if ( $wp_cache_preload_email_me )
|
3578 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Cache Preload Completed', 'wp-super-cache' ), home_url() ), __( "Cleaning up old supercache files.", 'wp-super-cache' ) . "\n" . $msg );
|
3579 |
+
if ( $cache_max_time > 0 ) { // GC is NOT disabled
|
3580 |
+
wp_cache_debug( "wp_cron_preload_cache: clean expired cache files older than $cache_max_time seconds.", 5 );
|
3581 |
+
wp_cache_phase2_clean_expired( $file_prefix, true ); // force cleanup of old files.
|
3582 |
+
}
|
3583 |
}
|
3584 |
@unlink( $mutex );
|
3585 |
}
|
4063 |
}
|
4064 |
}
|
4065 |
}
|
4066 |
+
|
4067 |
+
function wpsc_add_plugin( $file ) {
|
4068 |
+
global $wpsc_plugins;
|
4069 |
+
if ( substr( $file, 0, strlen( ABSPATH ) ) == ABSPATH ) {
|
4070 |
+
$file = substr( $file, strlen( ABSPATH ) ); // remove ABSPATH
|
4071 |
+
}
|
4072 |
+
if (
|
4073 |
+
! isset( $wpsc_plugins ) ||
|
4074 |
+
! is_array( $wpsc_plugins ) ||
|
4075 |
+
! in_array( $file, $wpsc_plugins )
|
4076 |
+
) {
|
4077 |
+
$wpsc_plugins[] = $file;
|
4078 |
+
wp_cache_setting( 'wpsc_plugins', $wpsc_plugins );
|
4079 |
+
}
|
4080 |
+
return $file;
|
4081 |
+
}
|
4082 |
+
add_action( 'wpsc_add_plugin', 'wpsc_add_plugin' );
|
4083 |
+
|
4084 |
+
function wpsc_delete_plugin( $file ) {
|
4085 |
+
global $wpsc_plugins;
|
4086 |
+
if ( substr( $file, 0, strlen( ABSPATH ) ) == ABSPATH ) {
|
4087 |
+
$file = substr( $file, strlen( ABSPATH ) ); // remove ABSPATH
|
4088 |
+
}
|
4089 |
+
if (
|
4090 |
+
isset( $wpsc_plugins ) &&
|
4091 |
+
is_array( $wpsc_plugins ) &&
|
4092 |
+
in_array( $file, $wpsc_plugins )
|
4093 |
+
) {
|
4094 |
+
unset( $wpsc_plugins[ array_search( $file, $wpsc_plugins ) ] );
|
4095 |
+
wp_cache_setting( 'wpsc_plugins', $wpsc_plugins );
|
4096 |
+
}
|
4097 |
+
return $file;
|
4098 |
+
}
|
4099 |
+
add_action( 'wpsc_delete_plugin', 'wpsc_delete_plugin' );
|
4100 |
+
|
4101 |
+
function wpsc_get_plugins() {
|
4102 |
+
global $wpsc_plugins;
|
4103 |
+
return $wpsc_plugins;
|
4104 |
+
}
|
4105 |
+
|
4106 |
+
function wpsc_add_cookie( $name ) {
|
4107 |
+
global $wpsc_cookies;
|
4108 |
+
if (
|
4109 |
+
! isset( $wpsc_cookies ) ||
|
4110 |
+
! is_array( $wpsc_cookies ) ||
|
4111 |
+
! in_array( $name, $wpsc_cookies )
|
4112 |
+
) {
|
4113 |
+
$wpsc_cookies[] = $name;
|
4114 |
+
wp_cache_setting( 'wpsc_cookies', $wpsc_cookies );
|
4115 |
+
}
|
4116 |
+
return $name;
|
4117 |
+
}
|
4118 |
+
add_action( 'wpsc_add_cookie', 'wpsc_add_cookie' );
|
4119 |
+
|
4120 |
+
function wpsc_delete_cookie( $name ) {
|
4121 |
+
global $wpsc_cookies;
|
4122 |
+
if (
|
4123 |
+
isset( $wpsc_cookies ) &&
|
4124 |
+
is_array( $wpsc_cookies ) &&
|
4125 |
+
in_array( $name, $wpsc_cookies )
|
4126 |
+
) {
|
4127 |
+
unset( $wpsc_cookies[ array_search( $name, $wpsc_cookies ) ] );
|
4128 |
+
wp_cache_setting( 'wpsc_cookies', $wpsc_cookies );
|
4129 |
+
}
|
4130 |
+
return $name;
|
4131 |
+
}
|
4132 |
+
add_action( 'wpsc_delete_cookie', 'wpsc_delete_cookie' );
|
4133 |
+
|
4134 |
+
function wpsc_get_cookies() {
|
4135 |
+
global $wpsc_cookies;
|
4136 |
+
return $wpsc_cookies;
|
4137 |
+
}
|
4138 |
+
|
4139 |
+
function wpsc_get_extra_cookies() {
|
4140 |
+
global $wpsc_cookies;
|
4141 |
+
if (
|
4142 |
+
is_array( $wpsc_cookies ) &&
|
4143 |
+
! empty( $wpsc_cookies )
|
4144 |
+
) {
|
4145 |
+
return '|' . implode( '|', $wpsc_cookies );
|
4146 |
+
} else {
|
4147 |
+
return '';
|
4148 |
+
}
|
4149 |
+
}
|