WP Super Cache - Version 0.6.8

Version Description

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 0.6.8
Comparing to
See all releases

Code changes from version 0.6.7 to 0.6.8

Files changed (3) hide show
  1. Changelog.txt +18 -0
  2. readme.txt +1 -1
  3. wp-cache.php +30 -20
Changelog.txt CHANGED
@@ -1,3 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-08-20 10:49 donncha
2
 
3
  * readme.txt, wp-cache.php: Bump version number to 0.6.7
1
+ 2008-08-27 19:16 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump the version number to 0.6.8
4
+
5
+ 2008-08-27 18:59 donncha
6
+
7
+ * wp-cache.php: Added rules to redirect to urls ending with a "/",
8
+ props Andylav and definitelynot,
9
+ http://wordpress.org/support/topic/199542?replies=6
10
+
11
+ 2008-08-21 16:41 donncha
12
+
13
+ * wp-cache.php: Change menu options url
14
+
15
+ 2008-08-20 11:47 donncha
16
+
17
+ * Changelog.txt: Update Changelog
18
+
19
  2008-08-20 10:49 donncha
20
 
21
  * readme.txt, wp-cache.php: Bump version number to 0.6.7
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
  Tested up to: 2.6.1
5
- Stable tag: 0.6.7
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.1
5
+ Stable tag: 0.6.8
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
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 enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
- Version: 0.6.7
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -96,11 +96,11 @@ register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
96
  function wp_cache_add_pages() {
97
  if( function_exists( 'is_site_admin' ) ) {
98
  if( is_site_admin() ) {
99
- add_submenu_page('wpmu-admin.php', __('WP Super Cache'), __('WP Super Cache'), 'manage_options', __FILE__, 'wp_cache_manager');
100
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', __FILE__, 'wp_cache_manager');
101
  }
102
  } else {
103
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', __FILE__, 'wp_cache_manager');
104
  }
105
  }
106
  add_action('admin_menu', 'wp_cache_add_pages');
@@ -282,38 +282,48 @@ function toggleLayer( whichLayer ) {
282
  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:
283
  <blockquote><code><em># BEGIN WordPress</em><br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule . /index.php [L]<br /> <em># END WordPress</em></code></blockquote>
284
  Refresh this page when you have updated your .htaccess file.";
 
285
  } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
286
  echo "<p><strong>Thank you for upgrading.</strong> The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: <blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*\$</code></blockquote> so it looks like this: <blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*\$</code></blockquote> The only changes are 'HTTP_COOKIE' becomes 'HTTP:Cookie' and 'wordpressuser' becomes 'wordpress'. This is a WordPress 2.5 change but it's backwards compatible with older versions if you're brave enough to use them.</p>";
287
- echo "</fieldset>";
288
- echo "</div>\n";
289
- return;
 
 
 
 
290
  } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
291
  $dohtaccess = false;
292
  }
 
 
 
 
 
 
 
 
 
 
 
 
293
  $rules = "<IfModule mod_rewrite.c>\n";
294
  $rules .= "RewriteEngine On\n";
295
  $rules .= "RewriteBase $home_root\n"; // props Chris Messina
296
  $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
297
  $rules .= "AddDefaultCharset {$charset}\n";
298
- $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
299
- $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
300
- $rules .= "RewriteCond %{QUERY_STRING} !.*p=.*\n";
301
- $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
302
- $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
303
- $rules .= "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
304
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
305
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
306
  $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
307
 
308
- $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
309
- $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
310
- $rules .= "RewriteCond %{QUERY_STRING} !.*p=.*\n";
311
- $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
312
- $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
313
- $rules .= "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
314
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
315
  $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
316
  $rules .= "</IfModule>\n";
 
 
 
317
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
318
  echo "<p>In order to serve static html files your server must have the correct mod_rewrite rules added to a file called <code> {$home_path}.htaccess</code><br /> This can be done automatically by clicking the <em>'Update mod_rewrite rules &raquo;'</em> button or you can edit the file yourself and add the following rules. Make sure they appear before any existing WordPress rules.";
319
  echo "<pre>" . wp_specialchars( $rules ) . "</pre></p>";
@@ -545,7 +555,7 @@ function wp_lock_down() {
545
 
546
  wp_nonce_field('wp-cache');
547
  if( $readonly != 'READONLY' )
548
- echo "<div class='submit'><input type='submit' ' . SUBMITDISABLED . 'value='Update direct pages &raquo;' /></div>";
549
  echo "</form>\n";
550
  ?></fieldset><?php
551
  } // if $super_cache_enabled
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching module for WordPress. Once enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
+ Version: 0.6.8
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
96
  function wp_cache_add_pages() {
97
  if( function_exists( 'is_site_admin' ) ) {
98
  if( is_site_admin() ) {
99
+ add_submenu_page('wpmu-admin.php', __('WP Super Cache'), __('WP Super Cache'), 'manage_options', 'wpsupercache', 'wp_cache_manager');
100
+ add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
101
  }
102
  } else {
103
+ add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
104
  }
105
  }
106
  add_action('admin_menu', 'wp_cache_add_pages');
282
  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:
283
  <blockquote><code><em># BEGIN WordPress</em><br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule . /index.php [L]<br /> <em># END WordPress</em></code></blockquote>
284
  Refresh this page when you have updated your .htaccess file.";
285
+ $dohtaccess = false;
286
  } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
287
  echo "<p><strong>Thank you for upgrading.</strong> The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: <blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*\$</code></blockquote> so it looks like this: <blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*\$</code></blockquote> The only changes are 'HTTP_COOKIE' becomes 'HTTP:Cookie' and 'wordpressuser' becomes 'wordpress'. This is a WordPress 2.5 change but it's backwards compatible with older versions if you're brave enough to use them.</p>";
288
+ $dohtaccess = false;
289
+ } elseif( strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
290
+ echo "<div style='padding: 2px; background: #ff0'><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.<br />";
291
+ echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
292
+ echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]$<br />RewriteCond %{REQUEST_URI} !^.*//.*$<br /></code></blockquote>";
293
+ 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>";
294
+ $dohtaccess = false;
295
  } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
296
  $dohtaccess = false;
297
  }
298
+ if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
299
+ $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$";
300
+ $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
301
+ }
302
+ $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !=POST";
303
+ $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*s=.*";
304
+ $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*p=.*";
305
+ $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*attachment_id=.*";
306
+ $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*";
307
+ $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$";
308
+ $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
309
+
310
  $rules = "<IfModule mod_rewrite.c>\n";
311
  $rules .= "RewriteEngine On\n";
312
  $rules .= "RewriteBase $home_root\n"; // props Chris Messina
313
  $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
314
  $rules .= "AddDefaultCharset {$charset}\n";
315
+ $rules .= "CONDITION_RULES";
 
 
 
 
 
316
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
317
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
318
  $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
319
 
320
+ $rules .= "CONDITION_RULES";
 
 
 
 
 
321
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
322
  $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
323
  $rules .= "</IfModule>\n";
324
+ $rules = apply_filters( 'supercacherewriterules', $rules );
325
+
326
+ $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules );
327
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
328
  echo "<p>In order to serve static html files your server must have the correct mod_rewrite rules added to a file called <code> {$home_path}.htaccess</code><br /> This can be done automatically by clicking the <em>'Update mod_rewrite rules &raquo;'</em> button or you can edit the file yourself and add the following rules. Make sure they appear before any existing WordPress rules.";
329
  echo "<pre>" . wp_specialchars( $rules ) . "</pre></p>";
555
 
556
  wp_nonce_field('wp-cache');
557
  if( $readonly != 'READONLY' )
558
+ echo "<div><input type='submit' ' . SUBMITDISABLED . 'value='Update direct pages &raquo;' /></div>";
559
  echo "</form>\n";
560
  ?></fieldset><?php
561
  } // if $super_cache_enabled