Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 0.8.9 |
Comparing to | |
See all releases |
Code changes from version 0.8.8 to 0.8.9
- Changelog.txt +62 -0
- advanced-cache.php +8 -0
- readme.txt +4 -5
- wp-cache-config-sample.php +5 -0
- wp-cache-phase2.php +19 -13
- wp-cache.php +126 -129
Changelog.txt
CHANGED
@@ -1,3 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
2009-01-16 17:03 donncha
|
2 |
|
3 |
* wp-cache-config-sample.php, wp-cache-phase1.php,
|
1 |
+
2009-01-23 19:09 donncha
|
2 |
+
|
3 |
+
* readme.txt, wp-cache.php: Bump version number to 0.8.9 and update
|
4 |
+
documentation
|
5 |
+
|
6 |
+
2009-01-23 18:34 donncha
|
7 |
+
|
8 |
+
* wp-cache.php: Updated text
|
9 |
+
|
10 |
+
2009-01-23 12:43 donncha
|
11 |
+
|
12 |
+
* wp-cache-phase2.php, wp-cache.php: Set garbage collection to 10
|
13 |
+
seconds after expiry
|
14 |
+
|
15 |
+
2009-01-23 12:13 donncha
|
16 |
+
|
17 |
+
* wp-cache.php: mutext variable needs to be global
|
18 |
+
|
19 |
+
2009-01-23 12:06 donncha
|
20 |
+
|
21 |
+
* advanced-cache.php, wp-cache.php: Added "advanced-cache.php"
|
22 |
+
which will load wp-cache-phase1.php
|
23 |
+
Copy that file to wp-content/ instead of symlinking
|
24 |
+
Added checkboxes for "cache rebuild" and "disable file locking"
|
25 |
+
remove #list anchor tag
|
26 |
+
|
27 |
+
2009-01-22 11:26 donncha
|
28 |
+
|
29 |
+
* wp-cache-phase2.php: Delete lots more cache files in one go, for
|
30 |
+
busy sites
|
31 |
+
|
32 |
+
2009-01-21 13:42 donncha
|
33 |
+
|
34 |
+
* wp-cache-phase2.php: Removed "cron job called" debug message
|
35 |
+
|
36 |
+
2009-01-21 13:05 donncha
|
37 |
+
|
38 |
+
* wp-cache.php: Show all sections of the admin page by default.
|
39 |
+
Move cache contents up
|
40 |
+
|
41 |
+
2009-01-20 11:23 donncha
|
42 |
+
|
43 |
+
* wp-cache.php: Admin page UI update, props Robert Wolf
|
44 |
+
|
45 |
+
2009-01-19 18:29 donncha
|
46 |
+
|
47 |
+
* wp-cache-config-sample.php: Comment out $wp_cache_mutex_disabled
|
48 |
+
by default
|
49 |
+
|
50 |
+
2009-01-19 18:27 donncha
|
51 |
+
|
52 |
+
* wp-cache-config-sample.php, wp-cache-phase2.php: Allow mutex file
|
53 |
+
locking to be disabled
|
54 |
+
|
55 |
+
2009-01-19 18:18 donncha
|
56 |
+
|
57 |
+
* wp-cache.php: Fix the favourites if a non admin users logs in
|
58 |
+
|
59 |
+
2009-01-16 17:04 donncha
|
60 |
+
|
61 |
+
* Changelog.txt: Updated Changelog
|
62 |
+
|
63 |
2009-01-16 17:03 donncha
|
64 |
|
65 |
* wp-cache-config-sample.php, wp-cache-phase1.php,
|
advanced-cache.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# WP SUPER CACHE 0.8.9
|
3 |
+
if( defined( 'WP_PLUGIN_DIR' ) ) {
|
4 |
+
require_once( constant( 'WP_PLUGIN_DIR' ) . '/wp-super-cache/wp-cache-phase1.php' );
|
5 |
+
} else {
|
6 |
+
require_once( 'plugins/wp-super-cache/wp-cache-phase1.php' );
|
7 |
+
}
|
8 |
+
?>
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache
|
4 |
Tested up to: 2.7
|
5 |
-
Stable tag: 0.8.
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
@@ -114,10 +114,9 @@ If things don't work when you installed the plugin here are a few things to chec
|
|
114 |
|
115 |
1. Is wp-content writable by the web server?
|
116 |
2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
|
117 |
-
3. Is there a wp-content/advanced-cache.php ? If not, then you must
|
118 |
|
119 |
-
`
|
120 |
-
If you can't do that, then copy the file. That will work too.
|
121 |
4. If pages are not cached at all, remove wp-content/advanced-cache.php and recreate it, following the advice above.
|
122 |
5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
|
123 |
|
@@ -129,7 +128,7 @@ If you can't do that, then copy the file. That will work too.
|
|
129 |
10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
|
130 |
11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
|
131 |
12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
|
132 |
-
13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value.
|
133 |
14. Make sure cache/wp_cache_mutex.lock is writeable by the web server.
|
134 |
|
135 |
== Custom Caching ==
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache
|
4 |
Tested up to: 2.7
|
5 |
+
Stable tag: 0.8.9
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
114 |
|
115 |
1. Is wp-content writable by the web server?
|
116 |
2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
|
117 |
+
3. Is there a wp-content/advanced-cache.php ? If not, then you must copy wp-super-cache/advanced-cache.php to it with this command while in the wp-content folder. (WordPress MU users should replace "plugins" with "mu-plugins".)
|
118 |
|
119 |
+
`cp plugins/wp-super-cache/advanced-cache.php advanced-cache.php`
|
|
|
120 |
4. If pages are not cached at all, remove wp-content/advanced-cache.php and recreate it, following the advice above.
|
121 |
5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
|
122 |
|
128 |
10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
|
129 |
11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
|
130 |
12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
|
131 |
+
13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value. You can also disable file locking from the Admin screen as a last resort.
|
132 |
14. Make sure cache/wp_cache_mutex.lock is writeable by the web server.
|
133 |
|
134 |
== Custom Caching ==
|
wp-cache-config-sample.php
CHANGED
@@ -51,6 +51,11 @@ $cache_rebuild_files = 0;
|
|
51 |
// Remove comment (//) to enable and add back to disable.
|
52 |
//$wp_cache_debug = "you@example.com";
|
53 |
|
|
|
|
|
|
|
|
|
|
|
54 |
// Just modify it if you have conflicts with semaphores
|
55 |
$sem_id = 5419;
|
56 |
|
51 |
// Remove comment (//) to enable and add back to disable.
|
52 |
//$wp_cache_debug = "you@example.com";
|
53 |
|
54 |
+
// Disable the file locking system.
|
55 |
+
// If you are experiencing problems with clearing or creating cache files
|
56 |
+
// uncommenting this may help.
|
57 |
+
//$wp_cache_mutex_disabled = 1;
|
58 |
+
|
59 |
// Just modify it if you have conflicts with semaphores
|
60 |
$sem_id = 5419;
|
61 |
|
wp-cache-phase2.php
CHANGED
@@ -123,7 +123,10 @@ function wp_cache_mutex_init() {
|
|
123 |
}
|
124 |
|
125 |
function wp_cache_writers_entry() {
|
126 |
-
global $use_flock, $mutex, $cache_path, $mutex_filename;
|
|
|
|
|
|
|
127 |
|
128 |
if( !$mutex )
|
129 |
return false;
|
@@ -137,7 +140,10 @@ function wp_cache_writers_entry() {
|
|
137 |
}
|
138 |
|
139 |
function wp_cache_writers_exit() {
|
140 |
-
global $use_flock, $mutex, $cache_path, $mutex_filename;
|
|
|
|
|
|
|
141 |
|
142 |
if( !$mutex )
|
143 |
return false;
|
@@ -330,12 +336,12 @@ function wp_cache_phase2_clean_cache($file_prefix) {
|
|
330 |
function prune_super_cache( $directory, $force = false, $rename = false ) {
|
331 |
global $gc_file_counter;
|
332 |
$c = 0;
|
333 |
-
while( $c <
|
334 |
$gc_file_counter = 0;
|
335 |
sc_garbage_collection( $directory, $force, $rename );
|
336 |
$c++;
|
337 |
if( $gc_file_counter == 0 )
|
338 |
-
$c =
|
339 |
}
|
340 |
}
|
341 |
|
@@ -450,7 +456,7 @@ function wp_cache_phase2_clean_expired($file_prefix) {
|
|
450 |
}
|
451 |
|
452 |
function wp_cache_shutdown_callback() {
|
453 |
-
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $
|
454 |
|
455 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
456 |
$wp_cache_meta_object->blog_id=$blog_id;
|
@@ -533,8 +539,8 @@ function wp_cache_shutdown_callback() {
|
|
533 |
wp_cache_writers_exit();
|
534 |
}
|
535 |
|
536 |
-
if( !isset( $
|
537 |
-
$
|
538 |
$last_gc = get_option( "wpsupercache_gc_time" );
|
539 |
|
540 |
if( !$last_gc ) {
|
@@ -542,7 +548,7 @@ function wp_cache_shutdown_callback() {
|
|
542 |
return;
|
543 |
}
|
544 |
|
545 |
-
if( $last_gc > ( time() - $
|
546 |
return;
|
547 |
update_option( 'wpsupercache_gc_time', time() );
|
548 |
|
@@ -658,15 +664,15 @@ function wp_cache_post_id() {
|
|
658 |
}
|
659 |
|
660 |
function wp_cache_gc_cron() {
|
661 |
-
global $file_prefix, $
|
|
|
662 |
|
663 |
-
if( !isset( $
|
664 |
-
$
|
665 |
|
666 |
-
wp_cache_debug( 'Cache Expiry cron job called.' );
|
667 |
if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
|
668 |
wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.' );
|
669 |
-
update_option( 'wpsupercache_gc_time', time() - ( $
|
670 |
}
|
671 |
}
|
672 |
|
123 |
}
|
124 |
|
125 |
function wp_cache_writers_entry() {
|
126 |
+
global $use_flock, $mutex, $cache_path, $mutex_filename, $wp_cache_mutex_disabled;
|
127 |
+
|
128 |
+
if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
|
129 |
+
return true;
|
130 |
|
131 |
if( !$mutex )
|
132 |
return false;
|
140 |
}
|
141 |
|
142 |
function wp_cache_writers_exit() {
|
143 |
+
global $use_flock, $mutex, $cache_path, $mutex_filename, $wp_cache_mutex_disabled;
|
144 |
+
|
145 |
+
if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
|
146 |
+
return true;
|
147 |
|
148 |
if( !$mutex )
|
149 |
return false;
|
336 |
function prune_super_cache( $directory, $force = false, $rename = false ) {
|
337 |
global $gc_file_counter;
|
338 |
$c = 0;
|
339 |
+
while( $c < 200 ) {
|
340 |
$gc_file_counter = 0;
|
341 |
sc_garbage_collection( $directory, $force, $rename );
|
342 |
$c++;
|
343 |
if( $gc_file_counter == 0 )
|
344 |
+
$c = 200;
|
345 |
}
|
346 |
}
|
347 |
|
456 |
}
|
457 |
|
458 |
function wp_cache_shutdown_callback() {
|
459 |
+
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename;
|
460 |
|
461 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
462 |
$wp_cache_meta_object->blog_id=$blog_id;
|
539 |
wp_cache_writers_exit();
|
540 |
}
|
541 |
|
542 |
+
if( !isset( $cache_max_time ) )
|
543 |
+
$cache_max_time = 600;
|
544 |
$last_gc = get_option( "wpsupercache_gc_time" );
|
545 |
|
546 |
if( !$last_gc ) {
|
548 |
return;
|
549 |
}
|
550 |
|
551 |
+
if( $last_gc > ( time() - ( 10 + $cache_max_time ) ) )
|
552 |
return;
|
553 |
update_option( 'wpsupercache_gc_time', time() );
|
554 |
|
664 |
}
|
665 |
|
666 |
function wp_cache_gc_cron() {
|
667 |
+
global $file_prefix, $cache_max_time;
|
668 |
+
error_log( date( "H:i:s" ) . " wp_cache_gc_cron\n", 3, "/tmp/log.txt" );
|
669 |
|
670 |
+
if( !isset( $cache_max_time ) )
|
671 |
+
$cache_max_time = 600;
|
672 |
|
|
|
673 |
if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
|
674 |
wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.' );
|
675 |
+
update_option( 'wpsupercache_gc_time', time() - ( $cache_max_time - 10 ) ); // if GC failed then run it again in one minute
|
676 |
}
|
677 |
}
|
678 |
|
wp-cache.php
CHANGED
@@ -2,11 +2,12 @@
|
|
2 |
/*
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
-
Description: Very fast caching module for WordPress.
|
6 |
-
Version: 0.8.
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
|
|
10 |
/* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
|
11 |
Some code copyright 2007-2008 Donncha O Caoimh (http://ocaoimh.ie/)
|
12 |
|
@@ -43,7 +44,7 @@ if( !@include($wp_cache_config_file) ) {
|
|
43 |
|
44 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
45 |
$wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php';
|
46 |
-
$wp_cache_file = WPCACHEHOME . '
|
47 |
|
48 |
include(WPCACHEHOME . 'wp-cache-base.php');
|
49 |
|
@@ -109,7 +110,7 @@ function wp_cache_add_pages() {
|
|
109 |
add_action('admin_menu', 'wp_cache_add_pages');
|
110 |
|
111 |
function wp_cache_manager() {
|
112 |
-
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files;
|
113 |
|
114 |
if( function_exists( 'is_site_admin' ) )
|
115 |
if( !is_site_admin() )
|
@@ -141,16 +142,18 @@ function toggleLayer( whichLayer ) {
|
|
141 |
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
|
142 |
}
|
143 |
// -->
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
</script>
|
145 |
-
<style type="text/css">
|
146 |
-
/* Taken from http://sw-guide.de/wordpress/plugins/simple-trackback-validation/ */
|
147 |
-
.wrap h3 { color: black; background-color: #e5f3ff; padding: 4px 8px; }
|
148 |
-
</style>
|
149 |
<?php
|
150 |
echo '<div class="wrap">';
|
151 |
echo "<h2>WP Super Cache Manager</h2>\n";
|
152 |
if( ini_get( 'safe_mode' ) ) {
|
153 |
-
?><h3>Warning! PHP
|
154 |
<p>You may experience problems running this plugin because SAFE MODE is enabled. <?php
|
155 |
if( !ini_get( 'safe_mode_gid' ) ) {
|
156 |
?>Your server is set up to check the owner of PHP scripts before allowing them to read and write files.</p><p>You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the <?php echo WP_CONTENT_DIR; ?>/cache/ directory must also be changed. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details.</p><?php
|
@@ -166,7 +169,7 @@ function toggleLayer( whichLayer ) {
|
|
166 |
if ( !wp_cache_check_link() ||
|
167 |
!wp_cache_verify_config_file() ||
|
168 |
!wp_cache_verify_cache_dir() ) {
|
169 |
-
echo "
|
170 |
echo "</div>\n";
|
171 |
return;
|
172 |
}
|
@@ -185,9 +188,9 @@ function toggleLayer( whichLayer ) {
|
|
185 |
define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
|
186 |
?><h4 style='text-align:center; color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
|
187 |
<div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
|
188 |
-
<p>The WP Super Cache configuration file is <code><?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code> and cannot be modified. The file <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php must be writeable by the webserver to make any changes
|
189 |
-
A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine
|
190 |
-
Writeable: <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code
|
191 |
Readonly: <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
|
192 |
</div><?php
|
193 |
} else {
|
@@ -201,7 +204,7 @@ function toggleLayer( whichLayer ) {
|
|
201 |
$wp_content_mode = ($wp_content_stat['mode'] & 0777);
|
202 |
if( $wp_content_mode != 0755 ) {
|
203 |
?><h4 style='text-align:center; color: #a00'>Warning! <?php echo WP_CONTENT_DIR; ?> is writeable!</h4>
|
204 |
-
<p>You should change the permissions on <?php echo WP_CONTENT_DIR; ?> and make it more restrictive. Use your ftp client, or the following command to fix things:<
|
205 |
}
|
206 |
}
|
207 |
|
@@ -231,6 +234,18 @@ function toggleLayer( whichLayer ) {
|
|
231 |
$wp_cache_clear_on_post_edit = 0;
|
232 |
}
|
233 |
wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
if( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) {
|
236 |
$cache_compression_changed = true;
|
@@ -242,18 +257,21 @@ function toggleLayer( whichLayer ) {
|
|
242 |
}
|
243 |
}
|
244 |
|
245 |
-
?><fieldset class="options">
|
246 |
<h3>WP Super Cache Status</h3><?php
|
247 |
echo '<form name="wp_manager" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
248 |
?>
|
249 |
-
<label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong>ON</strong>
|
250 |
-
<label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>HALF ON</strong>
|
251 |
-
<label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong>
|
252 |
<p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
|
253 |
<p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
|
254 |
-
<
|
|
|
|
|
|
|
255 |
<?php
|
256 |
-
echo "<div><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
257 |
wp_nonce_field('wp-cache');
|
258 |
?>
|
259 |
</form>
|
@@ -280,19 +298,20 @@ function toggleLayer( whichLayer ) {
|
|
280 |
</fieldset>
|
281 |
<?php
|
282 |
|
|
|
|
|
283 |
wsc_mod_rewrite();
|
284 |
|
285 |
wp_cache_edit_max_time();
|
286 |
|
287 |
-
echo '<
|
288 |
wp_cache_edit_rejected();
|
289 |
-
echo "
|
290 |
wp_cache_edit_accepted();
|
291 |
echo '</fieldset>';
|
292 |
|
293 |
wp_cache_edit_rejected_ua();
|
294 |
|
295 |
-
wp_cache_files();
|
296 |
|
297 |
wp_lock_down();
|
298 |
|
@@ -320,7 +339,7 @@ function wsc_mod_rewrite() {
|
|
320 |
if( $super_cache_enabled == false )
|
321 |
return;
|
322 |
?>
|
323 |
-
<
|
324 |
<h3>Super Cache Compression</h3>
|
325 |
<form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
|
326 |
<label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> Enabled</label>
|
@@ -332,10 +351,10 @@ function wsc_mod_rewrite() {
|
|
332 |
} elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
|
333 |
?><p><strong>Super Cache compression is now enabled.</strong></p><?php
|
334 |
}
|
335 |
-
echo '<div><input ' . SUBMITDISABLED . 'type="submit" value="Update Compression »" /></div>';
|
336 |
wp_nonce_field('wp-cache');
|
337 |
echo "</form>\n";
|
338 |
-
?></fieldset
|
339 |
|
340 |
<a name="modrewrite"></a><fieldset class="options">
|
341 |
<h3>Mod Rewrite Rules</h3><?php
|
@@ -383,7 +402,7 @@ function wsc_mod_rewrite() {
|
|
383 |
} elseif( !$wprules || $wprules == '' ) {
|
384 |
echo "<h4 style='color: #a00'>Mod Rewrite rules cannot be updated!</h4>";
|
385 |
echo "<p>You must have <strong>BEGIN</strong> and <strong>END</strong> markers in {$home_path}.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:
|
386 |
-
<blockquote><code><em># BEGIN WordPress</em
|
387 |
Refresh this page when you have updated your .htaccess file.";
|
388 |
echo "</fieldset></div>";
|
389 |
return;
|
@@ -392,9 +411,9 @@ function wsc_mod_rewrite() {
|
|
392 |
echo "</fieldset></div>";
|
393 |
return;
|
394 |
} elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
|
395 |
-
echo "<div style='padding:
|
396 |
echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
|
397 |
-
echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]
|
398 |
echo "<p>You can see where the rules go and examine the complete rules by clicking the 'View mod_rewrite rules' link below.</p></div>";
|
399 |
$dohtaccess = false;
|
400 |
} elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
|
@@ -407,10 +426,10 @@ function wsc_mod_rewrite() {
|
|
407 |
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
|
408 |
if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
|
409 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
410 |
-
echo "<div style='padding:
|
411 |
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
|
412 |
} else {
|
413 |
-
echo "<div style='padding:
|
414 |
if( !function_exists( 'is_site_admin' ) ) {
|
415 |
echo "You must edit the file yourself add the following rules.";
|
416 |
} else {
|
@@ -423,14 +442,14 @@ function wsc_mod_rewrite() {
|
|
423 |
if( !function_exists( 'is_site_admin' ) ) {
|
424 |
echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
|
425 |
echo '<input type="hidden" name="updatehtaccess" value="1" />';
|
426 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update
|
427 |
wp_nonce_field('wp-cache');
|
428 |
echo "</form></div>\n";
|
429 |
}
|
430 |
}
|
431 |
} elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
|
432 |
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
|
433 |
-
echo "<div style='padding:
|
434 |
if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
|
435 |
echo "<h4>Mod Rewrite rules updated!</h4>";
|
436 |
echo "<p><strong>{$home_path}.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:</strong></p>\n";
|
@@ -441,7 +460,8 @@ function wsc_mod_rewrite() {
|
|
441 |
echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n</div>";
|
442 |
} else {
|
443 |
?>
|
444 |
-
<p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file
|
|
|
445 |
<div id='rewriterules' style='display: none;'>
|
446 |
<?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
|
447 |
echo "<p>Rules must be added to " . WP_CONTENT_DIR ."/cache/.htaccess too:</p>";
|
@@ -459,10 +479,10 @@ function wsc_mod_rewrite() {
|
|
459 |
}
|
460 |
|
461 |
function wp_cache_restore() {
|
462 |
-
echo '<
|
463 |
echo '<form name="wp_restore" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
464 |
echo '<input type="hidden" name="wp_restore_config" />';
|
465 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="Restore
|
466 |
wp_nonce_field('wp-cache');
|
467 |
echo "</form>\n";
|
468 |
echo '</fieldset>';
|
@@ -492,31 +512,31 @@ function wp_lock_down() {
|
|
492 |
$wp_lock_down = '0';
|
493 |
}
|
494 |
}
|
495 |
-
?><
|
496 |
-
<h3>Lock Down:
|
497 |
<p>Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.</p>
|
498 |
<p>Developers: Make your plugin lock down compatible by checking the 'WPLOCKDOWN' constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.
|
499 |
-
<blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
|
500 |
-
echo "Sorry. My blog is locked down. Updates will appear shortly"
|
501 |
}</code></blockquote>
|
502 |
<?php
|
503 |
if( $wp_lock_down == '1' ) {
|
504 |
-
?><
|
505 |
} else {
|
506 |
-
?><
|
507 |
}
|
508 |
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
|
509 |
$new_lockdown_desc = $wp_lock_down == '1' ? 'Disable' : 'Enable';
|
510 |
echo '<form name="wp_lock_down" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
511 |
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
|
512 |
-
echo "<div><input type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} Lock Down »' /></div>";
|
513 |
wp_nonce_field('wp-cache');
|
514 |
echo "</form>\n";
|
515 |
|
516 |
-
?></fieldset
|
517 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
518 |
?><fieldset class="options">
|
519 |
-
<h3>Directly Cached Files
|
520 |
|
521 |
$out = '';
|
522 |
if( $valid_nonce && is_array( $_POST[ 'direct_pages' ] ) && !empty( $_POST[ 'direct_pages' ] ) ) {
|
@@ -574,7 +594,7 @@ function wp_lock_down() {
|
|
574 |
@unlink( $pagefile );
|
575 |
@unlink( $pagefile . '.gz' );
|
576 |
RecursiveFolderDelete( $firstfolder );
|
577 |
-
echo "<strong>$pagefile removed!</strong
|
578 |
prune_super_cache( $cache_path, true );
|
579 |
}
|
580 |
}
|
@@ -582,9 +602,9 @@ function wp_lock_down() {
|
|
582 |
$readonly = '';
|
583 |
if( !is_writeable_ACLSafe( ABSPATH ) ) {
|
584 |
$readonly = 'READONLY';
|
585 |
-
?><p
|
586 |
} else {
|
587 |
-
?><p
|
588 |
}
|
589 |
echo '<form name="direct_page" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
590 |
if( is_array( $cached_direct_pages ) ) {
|
@@ -603,7 +623,7 @@ function wp_lock_down() {
|
|
603 |
}
|
604 |
}
|
605 |
if( $readonly != 'READONLY' )
|
606 |
-
echo "Add direct page: <input type='text' $readonly name='new_direct_page' size='30' value=''
|
607 |
|
608 |
echo "<p>Directly cached files are files created directly off " . ABSPATH . " where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.</p>";
|
609 |
if( $readonly != 'READONLY' ) {
|
@@ -613,7 +633,7 @@ function wp_lock_down() {
|
|
613 |
|
614 |
wp_nonce_field('wp-cache');
|
615 |
if( $readonly != 'READONLY' )
|
616 |
-
echo "<div><input type='submit' ' . SUBMITDISABLED . 'value='Update
|
617 |
echo "</form>\n";
|
618 |
?></fieldset><?php
|
619 |
} // if $super_cache_enabled
|
@@ -639,7 +659,7 @@ function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manu
|
|
639 |
}
|
640 |
|
641 |
function wp_cache_edit_max_time () {
|
642 |
-
global $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled
|
643 |
|
644 |
if( !isset( $cache_max_time ) )
|
645 |
$cache_max_time = 3600;
|
@@ -651,27 +671,14 @@ function wp_cache_edit_max_time () {
|
|
651 |
wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = $cache_max_time;", $wp_cache_config_file);
|
652 |
}
|
653 |
}
|
654 |
-
|
655 |
-
|
656 |
-
wp_cache_replace_line('^ *\$wp_cache_gc', "\$wp_cache_gc = $wp_cache_gc;", $wp_cache_config_file);
|
657 |
-
}
|
658 |
-
?><br /><fieldset class="options">
|
659 |
-
<h3>Expiry Time and Garbage Collection</h3><?php
|
660 |
echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
661 |
echo '<label for="wp_max_time">Expire time:</label> ';
|
662 |
-
echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
$wp_cache_gc = '600';
|
667 |
-
}
|
668 |
-
echo "<h4>Garbage Collection</h4><p>How often should expired files be deleted?</p>";
|
669 |
-
echo "<ul><li><input type='radio' name='wp_cache_gc' value='600'" . ( $wp_cache_gc == 600 ? ' checked=checked' : '' ) . " /> Once every 10 minutes.</li>\n";
|
670 |
-
echo "<li><input type='radio' name='wp_cache_gc' value='3600'" . ( $wp_cache_gc == 3600 ? ' checked=checked' : '' ) . " /> Once every hour.</li>\n";
|
671 |
-
echo "<li><input type='radio' name='wp_cache_gc' value='21600'" . ( $wp_cache_gc == 21600 ? ' checked=checked' : '' ) . " /> Once every 6 hours. </li>\n";
|
672 |
-
echo "<li><input type='radio' name='wp_cache_gc' value='86400'" . ( $wp_cache_gc == 86400 ? ' checked=checked' : '' ) . " /> Once every 24 hours.</li></ul>\n";
|
673 |
-
echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you should set this to <em>10 minutes</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day.</p>";
|
674 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="Change expiration »" /></div>';
|
675 |
wp_nonce_field('wp-cache');
|
676 |
echo "</form>\n";
|
677 |
?></fieldset><?php
|
@@ -710,19 +717,17 @@ function wp_cache_edit_rejected_ua() {
|
|
710 |
wp_cache_replace_line('^ *\$cache_rejected_user_agent', "\$cache_rejected_user_agent = $text;", $wp_cache_config_file);
|
711 |
}
|
712 |
|
713 |
-
|
714 |
-
echo '<br /><a name="user-agents"></a><fieldset class="options"><h3>Rejected User Agents</h3>';
|
715 |
echo "<p>Strings in the HTTP 'User Agent' header that prevent WP-Cache from
|
716 |
caching bot, spiders, and crawlers' requests.
|
717 |
Note that cached files are still sent to these request if they already exists.</p>\n";
|
718 |
echo '<form name="wp_edit_rejected_user_agent" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
719 |
-
echo '<label for="wp_rejected_user_agent"><h4>Rejected UA strings</h4></label>';
|
720 |
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
721 |
foreach ($cache_rejected_user_agent as $ua) {
|
722 |
echo wp_specialchars($ua) . "\n";
|
723 |
}
|
724 |
echo '</textarea> ';
|
725 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="Save UA
|
726 |
wp_nonce_field('wp-cache');
|
727 |
echo '</form>';
|
728 |
echo "</fieldset>\n";
|
@@ -739,14 +744,13 @@ function wp_cache_edit_rejected() {
|
|
739 |
|
740 |
|
741 |
echo '<form name="wp_edit_rejected" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
742 |
-
echo '<label for="wp_rejected_uri"><h4>Rejected URIs</h4></label>';
|
743 |
echo "<p>Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it's enough to specify the year, i.e. '/2004/'. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.</p>\n";
|
744 |
echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
745 |
foreach ($cache_rejected_uri as $file) {
|
746 |
echo wp_specialchars($file) . "\n";
|
747 |
}
|
748 |
echo '</textarea> ';
|
749 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="Save
|
750 |
wp_nonce_field('wp-cache');
|
751 |
echo "</form>\n";
|
752 |
}
|
@@ -760,15 +764,14 @@ function wp_cache_edit_accepted() {
|
|
760 |
}
|
761 |
|
762 |
|
763 |
-
echo '<
|
764 |
-
echo '<h4>Accepted files</h4>';
|
765 |
echo "<p>Add here those filenames that can be cached, even if they match one of the rejected substring specified above.</p>\n";
|
766 |
echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
|
767 |
foreach ($cache_acceptable_files as $file) {
|
768 |
echo wp_specialchars($file) . "\n";
|
769 |
}
|
770 |
echo '</textarea> ';
|
771 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="Save
|
772 |
wp_nonce_field('wp-cache');
|
773 |
echo "</form>\n";
|
774 |
}
|
@@ -777,7 +780,7 @@ function wp_cache_enable() {
|
|
777 |
global $wp_cache_config_file, $cache_enabled, $supercachedir;
|
778 |
|
779 |
if(get_option('gzipcompression')) {
|
780 |
-
echo "<
|
781 |
return false;
|
782 |
}
|
783 |
if( wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = true;', $wp_cache_config_file) ) {
|
@@ -820,7 +823,7 @@ function wp_cache_is_enabled() {
|
|
820 |
global $wp_cache_config_file;
|
821 |
|
822 |
if(get_option('gzipcompression')) {
|
823 |
-
echo "<
|
824 |
return false;
|
825 |
}
|
826 |
$lines = file($wp_cache_config_file);
|
@@ -834,7 +837,7 @@ function wp_cache_is_enabled() {
|
|
834 |
|
835 |
function wp_cache_replace_line($old, $new, $my_file) {
|
836 |
if (!is_writeable_ACLSafe($my_file)) {
|
837 |
-
echo "Error: file $my_file is not writable
|
838 |
return false;
|
839 |
}
|
840 |
$found = false;
|
@@ -882,12 +885,12 @@ function wp_cache_verify_cache_dir() {
|
|
882 |
$dir = dirname($cache_path);
|
883 |
if ( !file_exists($cache_path) ) {
|
884 |
if ( !is_writeable_ACLSafe( $dir ) || !($dir = mkdir( $cache_path ) ) ) {
|
885 |
-
echo "<
|
886 |
return false;
|
887 |
}
|
888 |
}
|
889 |
if ( !is_writeable_ACLSafe($cache_path)) {
|
890 |
-
echo "<
|
891 |
return false;
|
892 |
}
|
893 |
|
@@ -912,18 +915,18 @@ function wp_cache_verify_config_file() {
|
|
912 |
if( is_writeable_ACLSafe( $wp_cache_config_file ) ) {
|
913 |
@unlink( $wp_cache_config_file );
|
914 |
} else {
|
915 |
-
echo "<
|
916 |
return false;
|
917 |
}
|
918 |
}
|
919 |
} elseif( !is_writeable_ACLSafe($dir)) {
|
920 |
-
echo "<
|
921 |
return false;
|
922 |
}
|
923 |
|
924 |
if ( !file_exists($wp_cache_config_file) ) {
|
925 |
if ( !file_exists($wp_cache_config_file_sample) ) {
|
926 |
-
echo "<
|
927 |
return false;
|
928 |
}
|
929 |
copy($wp_cache_config_file_sample, $wp_cache_config_file);
|
@@ -946,32 +949,27 @@ function wp_cache_verify_config_file() {
|
|
946 |
function wp_cache_check_link() {
|
947 |
global $wp_cache_link, $wp_cache_file;
|
948 |
|
|
|
949 |
if( file_exists($wp_cache_link) ) {
|
950 |
-
|
951 |
-
|
952 |
return true;
|
953 |
} else {
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
}
|
958 |
-
|
959 |
-
$ret = true;
|
960 |
-
if ( basename(@readlink($wp_cache_link)) != basename($wp_cache_file)) {
|
961 |
-
@unlink($wp_cache_link);
|
962 |
-
if( function_exists( 'symlink' ) ) {
|
963 |
-
if( !@symlink ($wp_cache_file, $wp_cache_link) ) {
|
964 |
$ret = false;
|
965 |
}
|
966 |
-
} elseif( !@copy( $wp_cache_file, $wp_cache_link ) ) {
|
967 |
-
$ret = false;
|
968 |
-
}
|
969 |
-
if( !$ret ) {
|
970 |
-
echo "<code>advanced-cache.php</code> does not exist<br />";
|
971 |
-
echo "Create it by executing: <br /><code>ln -s $wp_cache_file $wp_cache_link</code><br /> in your server<br />";
|
972 |
-
echo "Or by copying $wp_cache_file to $wp_cache_link.<br />";
|
973 |
-
return false;
|
974 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
}
|
976 |
return true;
|
977 |
}
|
@@ -986,7 +984,7 @@ function wp_cache_check_global_config() {
|
|
986 |
$global = dirname(ABSPATH) . '/wp-config.php';
|
987 |
}
|
988 |
|
989 |
-
$howtoenable = "Edit <code>$global</code> and add the following line: <
|
990 |
$lines = file($global);
|
991 |
foreach($lines as $line) {
|
992 |
if (preg_match('/^\s*define\s*\(\s*\'WP_CACHE\'\s*,\s*(?i:TRUE|1)\s*\)\s*;/', $line)) {
|
@@ -996,7 +994,7 @@ function wp_cache_check_global_config() {
|
|
996 |
}
|
997 |
$line = 'define(\'WP_CACHE\', true);';
|
998 |
if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\( *\'WP_CACHE\'', $line, $global) ) {
|
999 |
-
echo "<
|
1000 |
echo $howtoenable;
|
1001 |
return false;
|
1002 |
}
|
@@ -1027,11 +1025,11 @@ function wp_cache_files() {
|
|
1027 |
} else
|
1028 |
$list_mess = "List files";
|
1029 |
|
1030 |
-
echo '<
|
1031 |
/*
|
1032 |
-
echo '<form name="wp_cache_content_list" action="'. $_SERVER["REQUEST_URI"] . '
|
1033 |
echo '<input type="hidden" name="wp_list_cache" />';
|
1034 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="'.$list_mess.' »" /></div>';
|
1035 |
echo "</form>\n";
|
1036 |
*/
|
1037 |
|
@@ -1065,10 +1063,10 @@ function wp_cache_files() {
|
|
1065 |
if ($this_expired) echo "<td><span style='color:red'>$age secs</span></td>";
|
1066 |
else echo "<td>$age secs</td>";
|
1067 |
echo "<td>$fsize KB</td>";
|
1068 |
-
echo '<td><form name="wp_delete_cache_file" action="'. $_SERVER["REQUEST_URI"] . '
|
1069 |
echo '<input type="hidden" name="wp_list_cache" />';
|
1070 |
echo '<input type="hidden" name="wp_delete_cache_file" value="'.preg_replace("/^(.*)\.meta$/", "$1", $file).'" />';
|
1071 |
-
echo '<div><input id="deletepost" ' . SUBMITDISABLED . 'type="submit" value="Remove" /></div>';
|
1072 |
wp_nonce_field('wp-cache');
|
1073 |
echo "</form></td></tr>\n";
|
1074 |
}
|
@@ -1097,26 +1095,25 @@ function wp_cache_files() {
|
|
1097 |
$sizes[ 'ts' ] = time();
|
1098 |
}
|
1099 |
|
1100 |
-
echo "<p><
|
1101 |
-
echo "<ul><li>$count
|
1102 |
-
echo "<li>$expired
|
1103 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
1104 |
-
echo "<p><
|
1105 |
-
echo "<ul><li>" . intval($sizes['cached']/2) . "
|
1106 |
$age = intval(($now - $sizes['ts'])/60);
|
1107 |
-
echo "<li>" . intval($sizes['expired']/2) . "
|
1108 |
}
|
1109 |
|
1110 |
-
echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '
|
1111 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
1112 |
-
echo '<div><input type="submit" ' . SUBMITDISABLED . 'value="Delete
|
1113 |
wp_nonce_field('wp-cache');
|
1114 |
echo "</form>\n";
|
1115 |
|
1116 |
-
|
1117 |
-
echo '<form name="wp_cache_content_delete" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
|
1118 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
1119 |
-
echo '<div><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="Delete
|
1120 |
wp_nonce_field('wp-cache');
|
1121 |
echo "</form>\n";
|
1122 |
|
@@ -1130,7 +1127,7 @@ function delete_cache_dashboard() {
|
|
1130 |
if( function_exists('current_user_can') && !current_user_can('manage_options') )
|
1131 |
return false;
|
1132 |
|
1133 |
-
echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1
|
1134 |
}
|
1135 |
add_action( 'dashmenu', 'delete_cache_dashboard' );
|
1136 |
|
@@ -1272,12 +1269,12 @@ add_action( 'template_redirect', 'wp_cache_catch_404' );
|
|
1272 |
|
1273 |
function wp_cache_favorite_action( $actions ) {
|
1274 |
if( function_exists( 'is_site_admin' ) && !is_site_admin() )
|
1275 |
-
return
|
1276 |
|
1277 |
if( function_exists('current_user_can') && !current_user_can('manage_options') )
|
1278 |
-
return
|
1279 |
|
1280 |
-
$actions[ wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1
|
1281 |
|
1282 |
return $actions;
|
1283 |
}
|
2 |
/*
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
+
Description: Very fast caching module for WordPress.
|
6 |
+
Version: 0.8.9
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
10 |
+
|
11 |
/* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
|
12 |
Some code copyright 2007-2008 Donncha O Caoimh (http://ocaoimh.ie/)
|
13 |
|
44 |
|
45 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
46 |
$wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php';
|
47 |
+
$wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
|
48 |
|
49 |
include(WPCACHEHOME . 'wp-cache-base.php');
|
50 |
|
110 |
add_action('admin_menu', 'wp_cache_add_pages');
|
111 |
|
112 |
function wp_cache_manager() {
|
113 |
+
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled;
|
114 |
|
115 |
if( function_exists( 'is_site_admin' ) )
|
116 |
if( !is_site_admin() )
|
142 |
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
|
143 |
}
|
144 |
// -->
|
145 |
+
//Clicking header opens fieldset options
|
146 |
+
jQuery(document).ready(function(){
|
147 |
+
jQuery("fieldset h3").css("cursor","pointer").click(function(){
|
148 |
+
jQuery(this).parent("fieldset").find("p,form,ul,blockquote").toggle("slow");
|
149 |
+
});
|
150 |
+
});
|
151 |
</script>
|
|
|
|
|
|
|
|
|
152 |
<?php
|
153 |
echo '<div class="wrap">';
|
154 |
echo "<h2>WP Super Cache Manager</h2>\n";
|
155 |
if( ini_get( 'safe_mode' ) ) {
|
156 |
+
?><h3>Warning! PHP Safe Mode Enabled!</h3>
|
157 |
<p>You may experience problems running this plugin because SAFE MODE is enabled. <?php
|
158 |
if( !ini_get( 'safe_mode_gid' ) ) {
|
159 |
?>Your server is set up to check the owner of PHP scripts before allowing them to read and write files.</p><p>You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the <?php echo WP_CONTENT_DIR; ?>/cache/ directory must also be changed. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details.</p><?php
|
169 |
if ( !wp_cache_check_link() ||
|
170 |
!wp_cache_verify_config_file() ||
|
171 |
!wp_cache_verify_cache_dir() ) {
|
172 |
+
echo "Cannot continue... fix previous problems and retry.";
|
173 |
echo "</div>\n";
|
174 |
return;
|
175 |
}
|
188 |
define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
|
189 |
?><h4 style='text-align:center; color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
|
190 |
<div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
|
191 |
+
<p>The WP Super Cache configuration file is <code><?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code> and cannot be modified. The file <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php must be writeable by the webserver to make any changes.
|
192 |
+
A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine.
|
193 |
+
Writeable: <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code>
|
194 |
Readonly: <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
|
195 |
</div><?php
|
196 |
} else {
|
204 |
$wp_content_mode = ($wp_content_stat['mode'] & 0777);
|
205 |
if( $wp_content_mode != 0755 ) {
|
206 |
?><h4 style='text-align:center; color: #a00'>Warning! <?php echo WP_CONTENT_DIR; ?> is writeable!</h4>
|
207 |
+
<p>You should change the permissions on <?php echo WP_CONTENT_DIR; ?> and make it more restrictive. Use your ftp client, or the following command to fix things:<code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php
|
208 |
}
|
209 |
}
|
210 |
|
234 |
$wp_cache_clear_on_post_edit = 0;
|
235 |
}
|
236 |
wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
|
237 |
+
if( isset( $_POST[ 'cache_rebuild_files' ] ) ) {
|
238 |
+
$cache_rebuild_files = 1;
|
239 |
+
} else {
|
240 |
+
$cache_rebuild_files = 0;
|
241 |
+
}
|
242 |
+
wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file);
|
243 |
+
if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) {
|
244 |
+
$wp_cache_mutex_disabled = 1;
|
245 |
+
} else {
|
246 |
+
$wp_cache_mutex_disabled = 0;
|
247 |
+
}
|
248 |
+
wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file);
|
249 |
}
|
250 |
if( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) {
|
251 |
$cache_compression_changed = true;
|
257 |
}
|
258 |
}
|
259 |
|
260 |
+
?><fieldset class="options" id="show-this-fieldset">
|
261 |
<h3>WP Super Cache Status</h3><?php
|
262 |
echo '<form name="wp_manager" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
263 |
?>
|
264 |
+
<label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong>ON</strong> <span class="setting-description">WP Cache and Super Cache enabled</span></label><br />
|
265 |
+
<label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>HALF ON</strong> <span class="setting-description">Super Cache Disabled, only legacy WP-Cache caching.</span></label><br />
|
266 |
+
<label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> <span class="setting-description">WP Cache and Super Cache disabled</span></label><br />
|
267 |
<p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
|
268 |
<p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
|
269 |
+
<h4>Experimental Features</h4>
|
270 |
+
<p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Enable experimental "cache rebuild" feature. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments.</label></p>
|
271 |
+
<p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( $wp_cache_mutex_disabled ) echo "checked"; ?> value='1'> Disable file locking. If you experience problems with mutex or file locks this may help but may cause increased server load.</label></p>
|
272 |
+
<p><strong>Note:</strong> If uninstalling this plugin, make sure the directory <em><?php echo WP_CONTENT_DIR; ?></em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)</p>
|
273 |
<?php
|
274 |
+
echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
275 |
wp_nonce_field('wp-cache');
|
276 |
?>
|
277 |
</form>
|
298 |
</fieldset>
|
299 |
<?php
|
300 |
|
301 |
+
wp_cache_files();
|
302 |
+
|
303 |
wsc_mod_rewrite();
|
304 |
|
305 |
wp_cache_edit_max_time();
|
306 |
|
307 |
+
echo '<a name="files"></a><fieldset class="options"><h3>Accepted Filenames & Rejected URIs</h3>';
|
308 |
wp_cache_edit_rejected();
|
309 |
+
echo "\n";
|
310 |
wp_cache_edit_accepted();
|
311 |
echo '</fieldset>';
|
312 |
|
313 |
wp_cache_edit_rejected_ua();
|
314 |
|
|
|
315 |
|
316 |
wp_lock_down();
|
317 |
|
339 |
if( $super_cache_enabled == false )
|
340 |
return;
|
341 |
?>
|
342 |
+
<fieldset class="options">
|
343 |
<h3>Super Cache Compression</h3>
|
344 |
<form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
|
345 |
<label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> Enabled</label>
|
351 |
} elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
|
352 |
?><p><strong>Super Cache compression is now enabled.</strong></p><?php
|
353 |
}
|
354 |
+
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="Update Compression »" /></div>';
|
355 |
wp_nonce_field('wp-cache');
|
356 |
echo "</form>\n";
|
357 |
+
?></fieldset>
|
358 |
|
359 |
<a name="modrewrite"></a><fieldset class="options">
|
360 |
<h3>Mod Rewrite Rules</h3><?php
|
402 |
} elseif( !$wprules || $wprules == '' ) {
|
403 |
echo "<h4 style='color: #a00'>Mod Rewrite rules cannot be updated!</h4>";
|
404 |
echo "<p>You must have <strong>BEGIN</strong> and <strong>END</strong> markers in {$home_path}.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:
|
405 |
+
<blockquote><code><em># BEGIN WordPress</em> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] <em># END WordPress</em></code></blockquote>
|
406 |
Refresh this page when you have updated your .htaccess file.";
|
407 |
echo "</fieldset></div>";
|
408 |
return;
|
411 |
echo "</fieldset></div>";
|
412 |
return;
|
413 |
} elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
|
414 |
+
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>Trailing slash check required.</h4><p>It looks like your blog has URLs that end with a '/'. Unfortunately since you installed this plugin a duplicate content bug has been found where URLs not ending in a '/' end serve the same content as those with the '/' and do not redirect to the proper URL.";
|
415 |
echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
|
416 |
+
echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]$RewriteCond %{REQUEST_URI} !^.*//.*$</code></blockquote>";
|
417 |
echo "<p>You can see where the rules go and examine the complete rules by clicking the 'View mod_rewrite rules' link below.</p></div>";
|
418 |
$dohtaccess = false;
|
419 |
} elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
|
426 |
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
|
427 |
if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
|
428 |
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
|
429 |
+
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>Cannot update .htaccess</h4><p>The file <code>{$home_path}.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.</p><p>Refresh this page when the file permissions have been modified.</p><p>Alternatively, you can edit your <code>{$home_path}.htaccess</code> file manually and add the following code (before any WordPress rules):</p>";
|
430 |
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
|
431 |
} else {
|
432 |
+
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><p>To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>{$home_path}.htaccess</code> ";
|
433 |
if( !function_exists( 'is_site_admin' ) ) {
|
434 |
echo "You must edit the file yourself add the following rules.";
|
435 |
} else {
|
442 |
if( !function_exists( 'is_site_admin' ) ) {
|
443 |
echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
|
444 |
echo '<input type="hidden" name="updatehtaccess" value="1" />';
|
445 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update Mod_Rewrite Rules »" /></div>';
|
446 |
wp_nonce_field('wp-cache');
|
447 |
echo "</form></div>\n";
|
448 |
}
|
449 |
}
|
450 |
} elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
|
451 |
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
|
452 |
+
echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
|
453 |
if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
|
454 |
echo "<h4>Mod Rewrite rules updated!</h4>";
|
455 |
echo "<p><strong>{$home_path}.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:</strong></p>\n";
|
460 |
echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n</div>";
|
461 |
} else {
|
462 |
?>
|
463 |
+
<p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match.<br /><br />
|
464 |
+
<a href="javascript:toggleLayer('rewriterules');" class="button">View Mod_Rewrite Rules</a>
|
465 |
<div id='rewriterules' style='display: none;'>
|
466 |
<?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
|
467 |
echo "<p>Rules must be added to " . WP_CONTENT_DIR ."/cache/.htaccess too:</p>";
|
479 |
}
|
480 |
|
481 |
function wp_cache_restore() {
|
482 |
+
echo '<fieldset class="options"><h3>Fix Configuration</h3>';
|
483 |
echo '<form name="wp_restore" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
484 |
echo '<input type="hidden" name="wp_restore_config" />';
|
485 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="Restore Default Configuration »" /></div>';
|
486 |
wp_nonce_field('wp-cache');
|
487 |
echo "</form>\n";
|
488 |
echo '</fieldset>';
|
512 |
$wp_lock_down = '0';
|
513 |
}
|
514 |
}
|
515 |
+
?><fieldset class="options">
|
516 |
+
<h3>Lock Down: <?php echo $wp_lock_down == '0' ? '<span style="color:red">Disabled</span>' : '<span style="color:green">Enabled</span>'; ?></h3>
|
517 |
<p>Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.</p>
|
518 |
<p>Developers: Make your plugin lock down compatible by checking the 'WPLOCKDOWN' constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.
|
519 |
+
<blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
|
520 |
+
echo "Sorry. My blog is locked down. Updates will appear shortly";
|
521 |
}</code></blockquote>
|
522 |
<?php
|
523 |
if( $wp_lock_down == '1' ) {
|
524 |
+
?><p>WordPress is locked down. Super Cache static files will not be deleted when new comments are made.</p><?php
|
525 |
} else {
|
526 |
+
?><p>WordPress is not locked down. New comments will refresh Super Cache static files as normal.</p><?php
|
527 |
}
|
528 |
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
|
529 |
$new_lockdown_desc = $wp_lock_down == '1' ? 'Disable' : 'Enable';
|
530 |
echo '<form name="wp_lock_down" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
531 |
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
|
532 |
+
echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} Lock Down »' /></div>";
|
533 |
wp_nonce_field('wp-cache');
|
534 |
echo "</form>\n";
|
535 |
|
536 |
+
?></fieldset><?php
|
537 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
538 |
?><fieldset class="options">
|
539 |
+
<h3>Directly Cached Files</h3><?php
|
540 |
|
541 |
$out = '';
|
542 |
if( $valid_nonce && is_array( $_POST[ 'direct_pages' ] ) && !empty( $_POST[ 'direct_pages' ] ) ) {
|
594 |
@unlink( $pagefile );
|
595 |
@unlink( $pagefile . '.gz' );
|
596 |
RecursiveFolderDelete( $firstfolder );
|
597 |
+
echo "<strong>$pagefile removed!</strong>";
|
598 |
prune_super_cache( $cache_path, true );
|
599 |
}
|
600 |
}
|
602 |
$readonly = '';
|
603 |
if( !is_writeable_ACLSafe( ABSPATH ) ) {
|
604 |
$readonly = 'READONLY';
|
605 |
+
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong>Warning!</strong> You must make <?php echo ABSPATH ?> writable to enable this feature. As this is a security risk please make it readonly after your page is generated.</p><?php
|
606 |
} else {
|
607 |
+
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong>Warning!</strong> <?php echo ABSPATH ?> is writable. Please make it readonly after your page is generated as this is a security risk.</p><?php
|
608 |
}
|
609 |
echo '<form name="direct_page" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
610 |
if( is_array( $cached_direct_pages ) ) {
|
623 |
}
|
624 |
}
|
625 |
if( $readonly != 'READONLY' )
|
626 |
+
echo "Add direct page: <input type='text' $readonly name='new_direct_page' size='30' value='' />";
|
627 |
|
628 |
echo "<p>Directly cached files are files created directly off " . ABSPATH . " where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.</p>";
|
629 |
if( $readonly != 'READONLY' ) {
|
633 |
|
634 |
wp_nonce_field('wp-cache');
|
635 |
if( $readonly != 'READONLY' )
|
636 |
+
echo "<div class='submit'><input type='submit' ' . SUBMITDISABLED . 'value='Update Direct Pages »' /></div>";
|
637 |
echo "</form>\n";
|
638 |
?></fieldset><?php
|
639 |
} // if $super_cache_enabled
|
659 |
}
|
660 |
|
661 |
function wp_cache_edit_max_time () {
|
662 |
+
global $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled;
|
663 |
|
664 |
if( !isset( $cache_max_time ) )
|
665 |
$cache_max_time = 3600;
|
671 |
wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = $cache_max_time;", $wp_cache_config_file);
|
672 |
}
|
673 |
}
|
674 |
+
?><fieldset class="options">
|
675 |
+
<h3>Expiry Time & Garbage Collection</h3><?php
|
|
|
|
|
|
|
|
|
676 |
echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
677 |
echo '<label for="wp_max_time">Expire time:</label> ';
|
678 |
+
echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds";
|
679 |
+
echo "<h4>Garbage Collection</h4><p>Garbage Collection will be done 10 seconds after the expiry time above.</p>";
|
680 |
+
echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you should set the expiry time to <em>300 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day.</p>";
|
681 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change Expiration »" /></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
682 |
wp_nonce_field('wp-cache');
|
683 |
echo "</form>\n";
|
684 |
?></fieldset><?php
|
717 |
wp_cache_replace_line('^ *\$cache_rejected_user_agent', "\$cache_rejected_user_agent = $text;", $wp_cache_config_file);
|
718 |
}
|
719 |
|
720 |
+
echo '<a name="user-agents"></a><fieldset class="options"><h3>Rejected User Agents</h3>';
|
|
|
721 |
echo "<p>Strings in the HTTP 'User Agent' header that prevent WP-Cache from
|
722 |
caching bot, spiders, and crawlers' requests.
|
723 |
Note that cached files are still sent to these request if they already exists.</p>\n";
|
724 |
echo '<form name="wp_edit_rejected_user_agent" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
|
|
725 |
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
726 |
foreach ($cache_rejected_user_agent as $ua) {
|
727 |
echo wp_specialchars($ua) . "\n";
|
728 |
}
|
729 |
echo '</textarea> ';
|
730 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save UA Strings »" /></div>';
|
731 |
wp_nonce_field('wp-cache');
|
732 |
echo '</form>';
|
733 |
echo "</fieldset>\n";
|
744 |
|
745 |
|
746 |
echo '<form name="wp_edit_rejected" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
|
|
747 |
echo "<p>Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it's enough to specify the year, i.e. '/2004/'. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.</p>\n";
|
748 |
echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
|
749 |
foreach ($cache_rejected_uri as $file) {
|
750 |
echo wp_specialchars($file) . "\n";
|
751 |
}
|
752 |
echo '</textarea> ';
|
753 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save Strings »" /></div>';
|
754 |
wp_nonce_field('wp-cache');
|
755 |
echo "</form>\n";
|
756 |
}
|
764 |
}
|
765 |
|
766 |
|
767 |
+
echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
|
|
768 |
echo "<p>Add here those filenames that can be cached, even if they match one of the rejected substring specified above.</p>\n";
|
769 |
echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
|
770 |
foreach ($cache_acceptable_files as $file) {
|
771 |
echo wp_specialchars($file) . "\n";
|
772 |
}
|
773 |
echo '</textarea> ';
|
774 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save Files »" /></div>';
|
775 |
wp_nonce_field('wp-cache');
|
776 |
echo "</form>\n";
|
777 |
}
|
780 |
global $wp_cache_config_file, $cache_enabled, $supercachedir;
|
781 |
|
782 |
if(get_option('gzipcompression')) {
|
783 |
+
echo "<strong>Error: GZIP compression is enabled, disable it if you want to enable wp-cache.</strong>";
|
784 |
return false;
|
785 |
}
|
786 |
if( wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = true;', $wp_cache_config_file) ) {
|
823 |
global $wp_cache_config_file;
|
824 |
|
825 |
if(get_option('gzipcompression')) {
|
826 |
+
echo "<strong>Warning</strong>: GZIP compression is enabled in Wordpress, wp-cache will be bypassed until you disable gzip compression.";
|
827 |
return false;
|
828 |
}
|
829 |
$lines = file($wp_cache_config_file);
|
837 |
|
838 |
function wp_cache_replace_line($old, $new, $my_file) {
|
839 |
if (!is_writeable_ACLSafe($my_file)) {
|
840 |
+
echo "Error: file $my_file is not writable.\n";
|
841 |
return false;
|
842 |
}
|
843 |
$found = false;
|
885 |
$dir = dirname($cache_path);
|
886 |
if ( !file_exists($cache_path) ) {
|
887 |
if ( !is_writeable_ACLSafe( $dir ) || !($dir = mkdir( $cache_path ) ) ) {
|
888 |
+
echo "<strong>Error:</strong> Your cache directory (<strong>$cache_path</strong>) did not exist and couldn't be created by the web server. Check $dir permissions.";
|
889 |
return false;
|
890 |
}
|
891 |
}
|
892 |
if ( !is_writeable_ACLSafe($cache_path)) {
|
893 |
+
echo "<strong>Error:</strong> Your cache directory (<strong>$cache_path</strong>) or <strong>$dir</strong> need to be writable for this plugin to work. Double-check it.";
|
894 |
return false;
|
895 |
}
|
896 |
|
915 |
if( is_writeable_ACLSafe( $wp_cache_config_file ) ) {
|
916 |
@unlink( $wp_cache_config_file );
|
917 |
} else {
|
918 |
+
echo "<strong>Error:</strong> Your WP-Cache config file (<strong>$wp_cache_config_file</strong>) is out of date and not writable by the Web server.Please delete it and refresh this page.";
|
919 |
return false;
|
920 |
}
|
921 |
}
|
922 |
} elseif( !is_writeable_ACLSafe($dir)) {
|
923 |
+
echo "<strong>Error:</strong> Configuration file missing and " . WP_CONTENT_DIR . " directory (<strong>$dir</strong>) is not writable by the Web server.Check its permissions.";
|
924 |
return false;
|
925 |
}
|
926 |
|
927 |
if ( !file_exists($wp_cache_config_file) ) {
|
928 |
if ( !file_exists($wp_cache_config_file_sample) ) {
|
929 |
+
echo "<strong>Error:</strong> Sample WP-Cache config file (<strong>$wp_cache_config_file_sample</strong>) does not exist.Verify you installation.";
|
930 |
return false;
|
931 |
}
|
932 |
copy($wp_cache_config_file_sample, $wp_cache_config_file);
|
949 |
function wp_cache_check_link() {
|
950 |
global $wp_cache_link, $wp_cache_file;
|
951 |
|
952 |
+
$ret = true;
|
953 |
if( file_exists($wp_cache_link) ) {
|
954 |
+
$file = file_get_contents( $wp_cache_link );
|
955 |
+
if( strpos( $file, "WP SUPER CACHE 0.8.9" ) ) {
|
956 |
return true;
|
957 |
} else {
|
958 |
+
if( !@unlink($wp_cache_link) ) {
|
959 |
+
$ret = false;
|
960 |
+
} elseif( !@copy( $wp_cache_file, $wp_cache_link ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
961 |
$ret = false;
|
962 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
}
|
964 |
+
} elseif( !@copy( $wp_cache_file, $wp_cache_link ) ) {
|
965 |
+
$ret = false;
|
966 |
+
}
|
967 |
+
|
968 |
+
if( false == $ret ) {
|
969 |
+
echo "<p><code>wp-content/advanced-cache.php</code> does not exist or cannot be updated.<br />";
|
970 |
+
echo "Create or update it by executing: <code>cp $wp_cache_file $wp_cache_link</code> on your server<br />";
|
971 |
+
echo "or by copying $wp_cache_file to $wp_cache_link some other way.</p>";
|
972 |
+
return false;
|
973 |
}
|
974 |
return true;
|
975 |
}
|
984 |
$global = dirname(ABSPATH) . '/wp-config.php';
|
985 |
}
|
986 |
|
987 |
+
$howtoenable = "Edit <code>$global</code> and add the following line: <code>define('WP_CACHE', true);</code>Otherwise, <strong>WP-Cache will not be executed</strong> by Wordpress core. ";
|
988 |
$lines = file($global);
|
989 |
foreach($lines as $line) {
|
990 |
if (preg_match('/^\s*define\s*\(\s*\'WP_CACHE\'\s*,\s*(?i:TRUE|1)\s*\)\s*;/', $line)) {
|
994 |
}
|
995 |
$line = 'define(\'WP_CACHE\', true);';
|
996 |
if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\( *\'WP_CACHE\'', $line, $global) ) {
|
997 |
+
echo "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn't modify it.";
|
998 |
echo $howtoenable;
|
999 |
return false;
|
1000 |
}
|
1025 |
} else
|
1026 |
$list_mess = "List files";
|
1027 |
|
1028 |
+
echo '<fieldset class="options" id="show-this-fieldset"><h3>Cache Contents</h3>';
|
1029 |
/*
|
1030 |
+
echo '<form name="wp_cache_content_list" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
1031 |
echo '<input type="hidden" name="wp_list_cache" />';
|
1032 |
+
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="'.$list_mess.' »" /></div>';
|
1033 |
echo "</form>\n";
|
1034 |
*/
|
1035 |
|
1063 |
if ($this_expired) echo "<td><span style='color:red'>$age secs</span></td>";
|
1064 |
else echo "<td>$age secs</td>";
|
1065 |
echo "<td>$fsize KB</td>";
|
1066 |
+
echo '<td><form name="wp_delete_cache_file" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
1067 |
echo '<input type="hidden" name="wp_list_cache" />';
|
1068 |
echo '<input type="hidden" name="wp_delete_cache_file" value="'.preg_replace("/^(.*)\.meta$/", "$1", $file).'" />';
|
1069 |
+
echo '<div class="submit"><input id="deletepost" ' . SUBMITDISABLED . 'type="submit" value="Remove" /></div>';
|
1070 |
wp_nonce_field('wp-cache');
|
1071 |
echo "</form></td></tr>\n";
|
1072 |
}
|
1095 |
$sizes[ 'ts' ] = time();
|
1096 |
}
|
1097 |
|
1098 |
+
echo "<p><strong>WP-Cache</strong></p>";
|
1099 |
+
echo "<ul><li>$count Cached Pages</li>";
|
1100 |
+
echo "<li>$expired Expired Pages</li></ul>";
|
1101 |
if( $cache_enabled == true && $super_cache_enabled == true ) {
|
1102 |
+
echo "<p><strong>WP-Super-Cache</strong></p>";
|
1103 |
+
echo "<ul><li>" . intval($sizes['cached']/2) . " Cached Pages</li>";
|
1104 |
$age = intval(($now - $sizes['ts'])/60);
|
1105 |
+
echo "<li>" . intval($sizes['expired']/2) . " Expired Pages</li></ul>";
|
1106 |
}
|
1107 |
|
1108 |
+
echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
1109 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
1110 |
+
echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="Delete Expired »" /></div>';
|
1111 |
wp_nonce_field('wp-cache');
|
1112 |
echo "</form>\n";
|
1113 |
|
1114 |
+
echo '<form name="wp_cache_content_delete" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
|
|
1115 |
echo '<input type="hidden" name="wp_delete_cache" />';
|
1116 |
+
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="Delete Cache »" /></div>';
|
1117 |
wp_nonce_field('wp-cache');
|
1118 |
echo "</form>\n";
|
1119 |
|
1127 |
if( function_exists('current_user_can') && !current_user_can('manage_options') )
|
1128 |
return false;
|
1129 |
|
1130 |
+
echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1', 'wp-cache' ) . "' target='_blank' title='Delete Super Cache cached files (opens in new window)'>Delete Cache</a></li>";
|
1131 |
}
|
1132 |
add_action( 'dashmenu', 'delete_cache_dashboard' );
|
1133 |
|
1269 |
|
1270 |
function wp_cache_favorite_action( $actions ) {
|
1271 |
if( function_exists( 'is_site_admin' ) && !is_site_admin() )
|
1272 |
+
return $actions;
|
1273 |
|
1274 |
if( function_exists('current_user_can') && !current_user_can('manage_options') )
|
1275 |
+
return $actions;
|
1276 |
|
1277 |
+
$actions[ wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1', 'wp-cache' ) ] = array( __( 'Delete Cache' ), 'manage_options' );
|
1278 |
|
1279 |
return $actions;
|
1280 |
}
|