Version Description
Download this release
Release Info
| Developer | donncha |
| Plugin | |
| Version | 0.8.2 |
| Comparing to | |
| See all releases | |
Code changes from version 0.8.1 to 0.8.2
- Changelog.txt +46 -0
- readme.txt +1 -1
- wp-cache-config-sample.php +5 -0
- wp-cache-phase2.php +66 -34
- wp-cache.php +17 -6
Changelog.txt
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
2008-09-24 13:03 donncha
|
| 2 |
|
| 3 |
* wp-cache-phase2.php: Added function to clear cache when a post is
|
| 1 |
+
2008-09-26 23:15 donncha
|
| 2 |
+
|
| 3 |
+
* readme.txt, wp-cache.php: Bump the version number to 0.8.2
|
| 4 |
+
|
| 5 |
+
2008-09-26 23:14 donncha
|
| 6 |
+
|
| 7 |
+
* wp-cache-config-sample.php, wp-cache-phase2.php, wp-cache.php:
|
| 8 |
+
Added $cache_rebuild_files setting to switch off "need rebuild"
|
| 9 |
+
functionality by default
|
| 10 |
+
|
| 11 |
+
2008-09-26 16:00 donncha
|
| 12 |
+
|
| 13 |
+
* wp-cache-phase2.php: On post change clear the front page
|
| 14 |
+
|
| 15 |
+
2008-09-26 12:04 donncha
|
| 16 |
+
|
| 17 |
+
* wp-cache-phase2.php: Move cache writers entry up above supercache
|
| 18 |
+
cleaning.
|
| 19 |
+
Only clean individual posts, don't clear cache when no post_id
|
| 20 |
+
|
| 21 |
+
2008-09-26 09:49 donncha
|
| 22 |
+
|
| 23 |
+
* wp-cache.php: Only show "Delete Cache" link to MU site admins or
|
| 24 |
+
admins on WP blogs
|
| 25 |
+
|
| 26 |
+
2008-09-25 12:47 donncha
|
| 27 |
+
|
| 28 |
+
* wp-cache.php: Save "wp_cache_clear_on_post_edit" properly, thanks
|
| 29 |
+
HarryRAR,
|
| 30 |
+
http://wordpress.org/support/topic/206371?replies=2#post-861998
|
| 31 |
+
|
| 32 |
+
2008-09-25 11:12 donncha
|
| 33 |
+
|
| 34 |
+
* wp-cache-phase2.php, wp-cache.php: Can't clear cache on edit_post
|
| 35 |
+
because leaving a comment calls edit_post unfortunately
|
| 36 |
+
Experimental code to preserve supercache version of a page while
|
| 37 |
+
it's being regenerated.
|
| 38 |
+
|
| 39 |
+
2008-09-24 14:21 donncha
|
| 40 |
+
|
| 41 |
+
* wp-cache.php: Added "Delete Cache" link at top of admin pages
|
| 42 |
+
|
| 43 |
+
2008-09-24 13:57 donncha
|
| 44 |
+
|
| 45 |
+
* Changelog.txt: Updated changelog, still release 0.8.1
|
| 46 |
+
|
| 47 |
2008-09-24 13:03 donncha
|
| 48 |
|
| 49 |
* wp-cache-phase2.php: Added function to clear cache when a post is
|
readme.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
Contributors: donncha
|
| 3 |
Tags: performance,caching,wp-cache
|
| 4 |
Tested up to: 2.6.2
|
| 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.
|
| 2 |
Contributors: donncha
|
| 3 |
Tags: performance,caching,wp-cache
|
| 4 |
Tested up to: 2.6.2
|
| 5 |
+
Stable tag: 0.8.2
|
| 6 |
Requires at least: 2.2
|
| 7 |
|
| 8 |
A very fast caching engine for WordPress that produces static html files.
|
wp-cache-config-sample.php
CHANGED
|
@@ -42,6 +42,11 @@ $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', '
|
|
| 42 |
$cache_rejected_uri = array('wp-.*.php', 'index.php');
|
| 43 |
$cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
// Just modify it if you have conflicts with semaphores
|
| 46 |
$sem_id = 5419;
|
| 47 |
|
| 42 |
$cache_rejected_uri = array('wp-.*.php', 'index.php');
|
| 43 |
$cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
|
| 44 |
|
| 45 |
+
// Change this to 1 to enable experimental code that tries to serve slightly
|
| 46 |
+
// out of date content to anon users while a new supercache file is being
|
| 47 |
+
// generated.
|
| 48 |
+
$cache_rebuild_files = 0;
|
| 49 |
+
|
| 50 |
// Just modify it if you have conflicts with semaphores
|
| 51 |
$sem_id = 5419;
|
| 52 |
|
wp-cache-phase2.php
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
function wp_cache_phase2() {
|
| 4 |
-
global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object;
|
| 5 |
-
global $wp_cache_gzip_encoding;
|
| 6 |
|
| 7 |
wp_cache_mutex_init();
|
| 8 |
if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
|
| 9 |
// Post ID is received
|
| 10 |
add_action('publish_post', 'wp_cache_post_edit', 0);
|
| 11 |
-
add_action('edit_post', '
|
| 12 |
add_action('delete_post', 'wp_cache_post_edit', 0);
|
| 13 |
add_action('publish_phone', 'wp_cache_post_edit', 0);
|
| 14 |
// Coment ID is received
|
|
@@ -38,6 +37,28 @@ function wp_cache_phase2() {
|
|
| 38 |
else
|
| 39 |
header('Vary: Cookie');
|
| 40 |
ob_start('wp_cache_ob_callback');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
register_shutdown_function('wp_cache_shutdown_callback');
|
| 42 |
}
|
| 43 |
|
|
@@ -126,6 +147,18 @@ function wp_cache_writers_exit() {
|
|
| 126 |
sem_release($mutex);
|
| 127 |
}
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
function wp_cache_ob_callback($buffer) {
|
| 130 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
| 131 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
|
@@ -165,12 +198,7 @@ function wp_cache_ob_callback($buffer) {
|
|
| 165 |
the file was expired and its mtime is less than 5 seconds
|
| 166 |
*/
|
| 167 |
if( !((!$file_expired && $mtime) || ($mtime && $file_expired && (time() - $mtime) < 5)) ) {
|
| 168 |
-
$
|
| 169 |
-
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
|
| 170 |
-
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
| 171 |
-
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
| 172 |
-
$dir = trailingslashit( ABSPATH . $uri );
|
| 173 |
-
}
|
| 174 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
|
| 175 |
if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) )
|
| 176 |
$super_cache_enabled = false;
|
|
@@ -181,7 +209,6 @@ function wp_cache_ob_callback($buffer) {
|
|
| 181 |
return $buffer;
|
| 182 |
}
|
| 183 |
if( $super_cache_enabled ) {
|
| 184 |
-
$dir = str_replace( '//', '/', $dir );
|
| 185 |
if( @is_dir( $dir ) == false )
|
| 186 |
@wp_mkdir_p( $dir );
|
| 187 |
|
|
@@ -236,15 +263,15 @@ function wp_cache_ob_callback($buffer) {
|
|
| 236 |
fclose($fr);
|
| 237 |
if( $fr2 ) {
|
| 238 |
fclose($fr2);
|
| 239 |
-
chmod( $tmp_cache_filename, 0666 & ~umask());
|
| 240 |
-
if(
|
| 241 |
unlink( $cache_fname );
|
| 242 |
rename( $tmp_cache_filename, $cache_fname );
|
| 243 |
}
|
| 244 |
}
|
| 245 |
if( $gz ) {
|
| 246 |
fclose($gz);
|
| 247 |
-
if(
|
| 248 |
unlink( $cache_fname . '.gz' );
|
| 249 |
rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
|
| 250 |
}
|
|
@@ -270,8 +297,8 @@ function wp_cache_phase2_clean_cache($file_prefix) {
|
|
| 270 |
wp_cache_writers_exit();
|
| 271 |
}
|
| 272 |
|
| 273 |
-
function prune_super_cache($directory, $force = false) {
|
| 274 |
-
global $cache_max_time, $cache_path, $super_cache_enabled;
|
| 275 |
|
| 276 |
if( !is_admin() && $super_cache_enabled == 0 )
|
| 277 |
return false;
|
|
@@ -289,23 +316,30 @@ function prune_super_cache($directory, $force = false) {
|
|
| 289 |
$entries = glob($directory. '*');
|
| 290 |
if( is_array( $entries ) && !empty( $entries ) ) foreach ($entries as $entry) {
|
| 291 |
if ($entry != '.' && $entry != '..') {
|
| 292 |
-
prune_super_cache($entry, $force);
|
| 293 |
if( is_dir( $entry ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
|
| 294 |
$oktodelete = true;
|
| 295 |
if( in_array( $entry, $protected_directories ) )
|
| 296 |
$oktodelete = false;
|
| 297 |
-
if( $oktodelete )
|
| 298 |
@rmdir( addslashes( $entry ) );
|
| 299 |
}
|
| 300 |
}
|
| 301 |
}
|
| 302 |
-
}
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
}
|
| 310 |
}
|
| 311 |
}
|
|
@@ -461,15 +495,19 @@ function wp_cache_post_change($post_id) {
|
|
| 461 |
|
| 462 |
if ($post_id == $last_processed) return $post_id;
|
| 463 |
$last_processed = $post_id;
|
|
|
|
|
|
|
|
|
|
| 464 |
$permalink = trailingslashit( str_replace( get_option( 'siteurl' ), '', post_permalink( $post_id ) ) );
|
| 465 |
if( $super_cache_enabled ) {
|
| 466 |
$siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
|
|
|
| 470 |
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
|
| 471 |
$dir = $cache_path . 'supercache/' . $siteurl;
|
| 472 |
-
prune_super_cache( $dir . $permalink, true );
|
| 473 |
@rmdir( $dir . $permalink );
|
| 474 |
prune_super_cache( $dir . 'page/', true );
|
| 475 |
}
|
|
@@ -477,8 +515,6 @@ function wp_cache_post_change($post_id) {
|
|
| 477 |
|
| 478 |
$meta = new CacheMeta;
|
| 479 |
$matches = array();
|
| 480 |
-
if( !wp_cache_writers_entry() )
|
| 481 |
-
return $post_id;
|
| 482 |
if ( ($handle = opendir( $cache_path . 'meta/' )) ) {
|
| 483 |
while ( false !== ($file = readdir($handle))) {
|
| 484 |
if ( preg_match("/^({$file_prefix}{$blogcacheid}.*)\.meta/", $file, $matches) ) {
|
|
@@ -489,10 +525,6 @@ function wp_cache_post_change($post_id) {
|
|
| 489 |
if ($meta->blog_id == $blog_id && (!$meta->post || $meta->post == $post_id) ) {
|
| 490 |
@unlink($meta_pathname);
|
| 491 |
@unlink($content_pathname);
|
| 492 |
-
if( $super_cache_enabled ) {
|
| 493 |
-
@unlink( $cache_path . 'supercache/' . trailingslashit( $meta->uri ) . 'index.html' );
|
| 494 |
-
@unlink( $cache_path . 'supercache/' . trailingslashit( $meta->uri ) . 'index.html.gz' );
|
| 495 |
-
}
|
| 496 |
}
|
| 497 |
} elseif ($meta->blog_id == $blog_id) {
|
| 498 |
@unlink($meta_pathname);
|
| 1 |
<?php
|
| 2 |
|
| 3 |
function wp_cache_phase2() {
|
| 4 |
+
global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files;
|
|
|
|
| 5 |
|
| 6 |
wp_cache_mutex_init();
|
| 7 |
if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
|
| 8 |
// Post ID is received
|
| 9 |
add_action('publish_post', 'wp_cache_post_edit', 0);
|
| 10 |
+
add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
|
| 11 |
add_action('delete_post', 'wp_cache_post_edit', 0);
|
| 12 |
add_action('publish_phone', 'wp_cache_post_edit', 0);
|
| 13 |
// Coment ID is received
|
| 37 |
else
|
| 38 |
header('Vary: Cookie');
|
| 39 |
ob_start('wp_cache_ob_callback');
|
| 40 |
+
|
| 41 |
+
// restore old supercache file temporarily
|
| 42 |
+
if( $super_cache_enabled && $cache_rebuild_files ) {
|
| 43 |
+
$user_info = wp_cache_get_cookies_values();
|
| 44 |
+
$do_cache = apply_filters( 'do_createsupercache', $user_info );
|
| 45 |
+
if( $user_info == '' || $do_cache === true ) {
|
| 46 |
+
$dir = get_current_url_supercache_dir();
|
| 47 |
+
$files_to_check = array( $dir . 'index.html', $dir . 'index.html.gz' );
|
| 48 |
+
foreach( $files_to_check as $cache_file ) {
|
| 49 |
+
if( !file_exists( $cache_file . '.needs-rebuild' ) )
|
| 50 |
+
continue;
|
| 51 |
+
$mtime = @filemtime($cache_file . '.needs-rebuild');
|
| 52 |
+
if( $mtime && (time() - $mtime) < 30 ) {
|
| 53 |
+
@rename( $cache_file . '.needs-rebuild', $cache_file );
|
| 54 |
+
}
|
| 55 |
+
// cleanup old files or if rename fails
|
| 56 |
+
if( @file_exists( $cache_file . '.needs-rebuild' ) ) {
|
| 57 |
+
@unlink( $cache_file . '.needs-rebuild' );
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
register_shutdown_function('wp_cache_shutdown_callback');
|
| 63 |
}
|
| 64 |
|
| 147 |
sem_release($mutex);
|
| 148 |
}
|
| 149 |
|
| 150 |
+
function get_current_url_supercache_dir() {
|
| 151 |
+
global $cached_direct_pages, $cache_path;
|
| 152 |
+
$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $_SERVER['REQUEST_URI'] ) ) ) );
|
| 153 |
+
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
|
| 154 |
+
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
| 155 |
+
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
| 156 |
+
$dir = trailingslashit( ABSPATH . $uri );
|
| 157 |
+
}
|
| 158 |
+
$dir = str_replace( '//', '/', $dir );
|
| 159 |
+
return $dir;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
function wp_cache_ob_callback($buffer) {
|
| 163 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
| 164 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
| 198 |
the file was expired and its mtime is less than 5 seconds
|
| 199 |
*/
|
| 200 |
if( !((!$file_expired && $mtime) || ($mtime && $file_expired && (time() - $mtime) < 5)) ) {
|
| 201 |
+
$dir = get_current_url_supercache_dir();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
|
| 203 |
if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) )
|
| 204 |
$super_cache_enabled = false;
|
| 209 |
return $buffer;
|
| 210 |
}
|
| 211 |
if( $super_cache_enabled ) {
|
|
|
|
| 212 |
if( @is_dir( $dir ) == false )
|
| 213 |
@wp_mkdir_p( $dir );
|
| 214 |
|
| 263 |
fclose($fr);
|
| 264 |
if( $fr2 ) {
|
| 265 |
fclose($fr2);
|
| 266 |
+
@chmod( $tmp_cache_filename, 0666 & ~umask());
|
| 267 |
+
if( !@rename( $tmp_cache_filename, $cache_fname ) ) {
|
| 268 |
unlink( $cache_fname );
|
| 269 |
rename( $tmp_cache_filename, $cache_fname );
|
| 270 |
}
|
| 271 |
}
|
| 272 |
if( $gz ) {
|
| 273 |
fclose($gz);
|
| 274 |
+
if( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
|
| 275 |
unlink( $cache_fname . '.gz' );
|
| 276 |
rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
|
| 277 |
}
|
| 297 |
wp_cache_writers_exit();
|
| 298 |
}
|
| 299 |
|
| 300 |
+
function prune_super_cache($directory, $force = false, $rename = false) {
|
| 301 |
+
global $cache_max_time, $cache_path, $super_cache_enabled, $cache_rebuild_files;
|
| 302 |
|
| 303 |
if( !is_admin() && $super_cache_enabled == 0 )
|
| 304 |
return false;
|
| 316 |
$entries = glob($directory. '*');
|
| 317 |
if( is_array( $entries ) && !empty( $entries ) ) foreach ($entries as $entry) {
|
| 318 |
if ($entry != '.' && $entry != '..') {
|
| 319 |
+
prune_super_cache( $entry, $force, $rename );
|
| 320 |
if( is_dir( $entry ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
|
| 321 |
$oktodelete = true;
|
| 322 |
if( in_array( $entry, $protected_directories ) )
|
| 323 |
$oktodelete = false;
|
| 324 |
+
if( $oktodelete && !$rename )
|
| 325 |
@rmdir( addslashes( $entry ) );
|
| 326 |
}
|
| 327 |
}
|
| 328 |
}
|
| 329 |
+
} elseif( is_file($directory) && ($force || filemtime( $directory ) + $cache_max_time <= $now ) ) {
|
| 330 |
+
$oktodelete = true;
|
| 331 |
+
if( in_array( $directory, $protected_directories ) )
|
| 332 |
+
$oktodelete = false;
|
| 333 |
+
if( $oktodelete && !$rename ) {
|
| 334 |
+
@unlink( addslashes( $directory ) );
|
| 335 |
+
} elseif( $oktodelete && $rename ) {
|
| 336 |
+
if( $cache_rebuild_files && substr( $directory, -14 ) != '.needs-rebuild' ) {
|
| 337 |
+
if( @rename($directory, $directory . '.needs-rebuild') )
|
| 338 |
+
@touch( $directory . '.needs-rebuild' );
|
| 339 |
+
} else {
|
| 340 |
+
@unlink( $directory );
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
}
|
| 344 |
}
|
| 345 |
}
|
| 495 |
|
| 496 |
if ($post_id == $last_processed) return $post_id;
|
| 497 |
$last_processed = $post_id;
|
| 498 |
+
if( !wp_cache_writers_entry() )
|
| 499 |
+
return $post_id;
|
| 500 |
+
|
| 501 |
$permalink = trailingslashit( str_replace( get_option( 'siteurl' ), '', post_permalink( $post_id ) ) );
|
| 502 |
if( $super_cache_enabled ) {
|
| 503 |
$siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
|
| 504 |
+
// make sure the front page has a rebuild file
|
| 505 |
+
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
|
| 506 |
+
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
|
| 507 |
+
if( $post_id != 0 ) {
|
| 508 |
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
|
| 509 |
$dir = $cache_path . 'supercache/' . $siteurl;
|
| 510 |
+
prune_super_cache( $dir . $permalink, true, true );
|
| 511 |
@rmdir( $dir . $permalink );
|
| 512 |
prune_super_cache( $dir . 'page/', true );
|
| 513 |
}
|
| 515 |
|
| 516 |
$meta = new CacheMeta;
|
| 517 |
$matches = array();
|
|
|
|
|
|
|
| 518 |
if ( ($handle = opendir( $cache_path . 'meta/' )) ) {
|
| 519 |
while ( false !== ($file = readdir($handle))) {
|
| 520 |
if ( preg_match("/^({$file_prefix}{$blogcacheid}.*)\.meta/", $file, $matches) ) {
|
| 525 |
if ($meta->blog_id == $blog_id && (!$meta->post || $meta->post == $post_id) ) {
|
| 526 |
@unlink($meta_pathname);
|
| 527 |
@unlink($content_pathname);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 528 |
}
|
| 529 |
} elseif ($meta->blog_id == $blog_id) {
|
| 530 |
@unlink($meta_pathname);
|
wp-cache.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: WP Super Cache
|
| 4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
| 5 |
Description: Very fast caching module for WordPress. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
|
| 6 |
-
Version: 0.8.
|
| 7 |
Author: Donncha O Caoimh
|
| 8 |
Author URI: http://ocaoimh.ie/
|
| 9 |
*/
|
|
@@ -109,7 +109,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;
|
| 113 |
|
| 114 |
if( function_exists( 'is_site_admin' ) )
|
| 115 |
if( !is_site_admin() )
|
|
@@ -118,6 +118,9 @@ function wp_cache_manager() {
|
|
| 118 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
|
| 119 |
if( get_option( 'gzipcompression' ) == 1 )
|
| 120 |
update_option( 'gzipcompression', 0 );
|
|
|
|
|
|
|
|
|
|
| 121 |
$valid_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache');
|
| 122 |
/* http://www.netlobo.com/div_hiding.html */
|
| 123 |
?>
|
|
@@ -231,10 +234,12 @@ function toggleLayer( whichLayer ) {
|
|
| 231 |
prune_super_cache ($cache_path, true);
|
| 232 |
delete_option( 'super_cache_meta' );
|
| 233 |
}
|
| 234 |
-
if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] )
|
| 235 |
-
$wp_cache_clear_on_post_edit =
|
| 236 |
-
|
|
|
|
| 237 |
}
|
|
|
|
| 238 |
}
|
| 239 |
|
| 240 |
?><fieldset class="options">
|
|
@@ -245,7 +250,7 @@ function toggleLayer( whichLayer ) {
|
|
| 245 |
<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> (Super Cache Disabled, only legacy WP-Cache caching.)</label><br />
|
| 246 |
<label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> (WP Cache and Super Cache disabled)</label><br />
|
| 247 |
<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>
|
| 248 |
-
<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
|
| 249 |
<p>Note: 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>
|
| 250 |
<?php
|
| 251 |
echo "<div><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
|
@@ -1074,6 +1079,12 @@ function wp_cache_files() {
|
|
| 1074 |
}
|
| 1075 |
|
| 1076 |
function delete_cache_dashboard() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1077 |
echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1#list', 'wp-cache' ) . "' target='_blank' title='Delete Super Cache cached files (opens in new window)'>Delete Cache</a></li>";
|
| 1078 |
}
|
| 1079 |
add_action( 'dashmenu', 'delete_cache_dashboard' );
|
| 3 |
Plugin Name: WP Super Cache
|
| 4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
| 5 |
Description: Very fast caching module for WordPress. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
|
| 6 |
+
Version: 0.8.2
|
| 7 |
Author: Donncha O Caoimh
|
| 8 |
Author URI: http://ocaoimh.ie/
|
| 9 |
*/
|
| 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() )
|
| 118 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
|
| 119 |
if( get_option( 'gzipcompression' ) == 1 )
|
| 120 |
update_option( 'gzipcompression', 0 );
|
| 121 |
+
if( !isset( $cache_rebuild_files ) )
|
| 122 |
+
$cache_rebuild_files = 0;
|
| 123 |
+
|
| 124 |
$valid_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache');
|
| 125 |
/* http://www.netlobo.com/div_hiding.html */
|
| 126 |
?>
|
| 234 |
prune_super_cache ($cache_path, true);
|
| 235 |
delete_option( 'super_cache_meta' );
|
| 236 |
}
|
| 237 |
+
if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
|
| 238 |
+
$wp_cache_clear_on_post_edit = 1;
|
| 239 |
+
} else {
|
| 240 |
+
$wp_cache_clear_on_post_edit = 0;
|
| 241 |
}
|
| 242 |
+
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);
|
| 243 |
}
|
| 244 |
|
| 245 |
?><fieldset class="options">
|
| 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> (Super Cache Disabled, only legacy WP-Cache caching.)</label><br />
|
| 251 |
<label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> (WP Cache and Super Cache disabled)</label><br />
|
| 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 |
<p>Note: 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>
|
| 255 |
<?php
|
| 256 |
echo "<div><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
| 1079 |
}
|
| 1080 |
|
| 1081 |
function delete_cache_dashboard() {
|
| 1082 |
+
if( function_exists( 'is_site_admin' ) && !is_site_admin() )
|
| 1083 |
+
return false;
|
| 1084 |
+
|
| 1085 |
+
if( function_exists('current_user_can') && !current_user_can('manage_options') )
|
| 1086 |
+
return false;
|
| 1087 |
+
|
| 1088 |
echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1#list', 'wp-cache' ) . "' target='_blank' title='Delete Super Cache cached files (opens in new window)'>Delete Cache</a></li>";
|
| 1089 |
}
|
| 1090 |
add_action( 'dashmenu', 'delete_cache_dashboard' );
|
