WP Super Cache - Version 0.7.1

Version Description

Download this release

Release Info

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

Code changes from version 0.7 to 0.7.1

Files changed (3) hide show
  1. Changelog.txt +17 -0
  2. readme.txt +1 -1
  3. wp-cache.php +63 -52
Changelog.txt CHANGED
@@ -1,3 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-08-27 19:31 donncha
2
 
3
  * readme.txt, wp-cache.php: Bump to 0.7, fix activation link
1
+ 2008-08-28 11:29 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump the version number to 0.7.1
4
+
5
+ 2008-08-28 11:00 donncha
6
+
7
+ * wp-cache.php: Updated .htaccess code:
8
+ Check that file is writable (again?)
9
+ Fix warnings about upgrades.
10
+ Bright yellow backgrounds on items that need attention
11
+ Thanks Matt @ http://twitter.com/mattfreedman/statuses/901325274
12
+ for reporting.
13
+
14
+ 2008-08-27 19:32 donncha
15
+
16
+ * Changelog.txt: Updated changelog
17
+
18
  2008-08-27 19:31 donncha
19
 
20
  * readme.txt, wp-cache.php: Bump to 0.7, fix activation link
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.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.7.1
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 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.7
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -245,8 +245,48 @@ function toggleLayer( whichLayer ) {
245
  ?>
246
  </form>
247
  </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
- <?php if( $cache_enabled == true && $super_cache_enabled == true ) { ?>
 
 
 
 
250
  <br /><fieldset class="options">
251
  <h3>Super Cache Compression</h3>
252
  <form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
@@ -264,7 +304,7 @@ function toggleLayer( whichLayer ) {
264
  echo "</form>\n";
265
  ?></fieldset><br />
266
 
267
- <fieldset class="options">
268
  <h3>Mod Rewrite Rules</h3><?php
269
  $home_path = get_home_path();
270
  $home_root = parse_url(get_bloginfo('url'));
@@ -282,11 +322,13 @@ 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
- $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>";
@@ -325,15 +367,20 @@ function toggleLayer( whichLayer ) {
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>";
330
- echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
331
- echo '<input type="hidden" name="updatehtaccess" value="1" />';
332
- echo '<div><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update mod_rewrite rules &raquo;" /></div>';
333
- wp_nonce_field('wp-cache');
334
- echo "</form>\n";
 
 
 
 
335
  } elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
336
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
 
337
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
338
  echo "<h4>Mod Rewrite rules updated!</h4>";
339
  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";
@@ -341,12 +388,12 @@ function toggleLayer( whichLayer ) {
341
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
342
  echo "<p><strong> Your {$home_path}.htaccess is not writable by the webserver and must be updated with the necessary mod_rewrite rules. The new rules go above the regular WordPress rules as shown in the code below:</strong></p>\n";
343
  }
344
- echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n";
345
  } else {
346
  ?>
347
- <p>WP Super Cache has modified your <?php echo $home_path ?>.htaccess file. Click the following link to see the lines added. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
348
  <div id='rewriterules' style='display: none;'>
349
- <?php echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n"; ?>
350
  </div>
351
  <?php
352
  }
@@ -362,42 +409,6 @@ function toggleLayer( whichLayer ) {
362
  }
363
 
364
  ?></fieldset><?php
365
-
366
- } // if $super_cache_enabled
367
-
368
- wp_cache_edit_max_time();
369
-
370
- echo '<br /><a name="files"></a><fieldset class="options"><h3>Accepted filenames, rejected URIs</h3>';
371
- wp_cache_edit_rejected();
372
- echo "<br />\n";
373
- wp_cache_edit_accepted();
374
- echo '</fieldset>';
375
-
376
- wp_cache_edit_rejected_ua();
377
-
378
-
379
- wp_cache_files();
380
-
381
- wp_lock_down();
382
-
383
- wp_cache_restore();
384
-
385
- ob_start();
386
- if( defined( 'WP_CACHE' ) ) {
387
- if( function_exists( 'do_cacheaction' ) ) {
388
- do_cacheaction( 'cache_admin_page' );
389
- }
390
- }
391
- $out = ob_get_contents();
392
- ob_end_clean();
393
- if( SUBMITDISABLED == ' ' && $out != '' ) {
394
- echo '<fieldset class="options"><h3>Cache Plugins</h3>';
395
- echo $out;
396
- echo '</fieldset>';
397
- }
398
-
399
- echo "</div>\n";
400
-
401
  }
402
 
403
  function wp_cache_restore() {
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.7.1
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
245
  ?>
246
  </form>
247
  </fieldset>
248
+ <?php
249
+
250
+ wsc_mod_rewrite();
251
+
252
+ wp_cache_edit_max_time();
253
+
254
+ echo '<br /><a name="files"></a><fieldset class="options"><h3>Accepted filenames, rejected URIs</h3>';
255
+ wp_cache_edit_rejected();
256
+ echo "<br />\n";
257
+ wp_cache_edit_accepted();
258
+ echo '</fieldset>';
259
+
260
+ wp_cache_edit_rejected_ua();
261
+
262
+ wp_cache_files();
263
+
264
+ wp_lock_down();
265
+
266
+ wp_cache_restore();
267
+
268
+ ob_start();
269
+ if( defined( 'WP_CACHE' ) ) {
270
+ if( function_exists( 'do_cacheaction' ) ) {
271
+ do_cacheaction( 'cache_admin_page' );
272
+ }
273
+ }
274
+ $out = ob_get_contents();
275
+ ob_end_clean();
276
+ if( SUBMITDISABLED == ' ' && $out != '' ) {
277
+ echo '<fieldset class="options"><h3>Cache Plugins</h3>';
278
+ echo $out;
279
+ echo '</fieldset>';
280
+ }
281
+
282
+ echo "</div>\n";
283
+ }
284
 
285
+ function wsc_mod_rewrite() {
286
+ global $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path;
287
+ if( $super_cache_enabled == false )
288
+ return;
289
+ ?>
290
  <br /><fieldset class="options">
291
  <h3>Super Cache Compression</h3>
292
  <form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
304
  echo "</form>\n";
305
  ?></fieldset><br />
306
 
307
+ <a name="modrewrite"></a><fieldset class="options">
308
  <h3>Mod Rewrite Rules</h3><?php
309
  $home_path = get_home_path();
310
  $home_root = parse_url(get_bloginfo('url'));
322
  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:
323
  <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>
324
  Refresh this page when you have updated your .htaccess file.";
325
+ echo "</fieldset></div>";
326
+ return;
327
  } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
328
  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>";
329
+ echo "</fieldset></div>";
330
+ return;
331
+ } elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
332
  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 />";
333
  echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
334
  echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]$<br />RewriteCond %{REQUEST_URI} !^.*//.*$<br /></code></blockquote>";
367
 
368
  $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules );
369
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
370
+ if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
371
+ echo "<div style='padding: 2px; background: #ff0'><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></div>";
372
+ } else {
373
+ echo "<div style='padding: 2px; background: #ff0'><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><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.";
374
+ echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
375
+ echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
376
+ echo '<input type="hidden" name="updatehtaccess" value="1" />';
377
+ echo '<div><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update mod_rewrite rules &raquo;" /></div>';
378
+ wp_nonce_field('wp-cache');
379
+ echo "</form></div>\n";
380
+ }
381
  } elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
382
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
383
+ echo "<div style='padding: 2px; background: #ff0'>";
384
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
385
  echo "<h4>Mod Rewrite rules updated!</h4>";
386
  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";
388
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
389
  echo "<p><strong> Your {$home_path}.htaccess is not writable by the webserver and must be updated with the necessary mod_rewrite rules. The new rules go above the regular WordPress rules as shown in the code below:</strong></p>\n";
390
  }
391
+ echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n</div>";
392
  } else {
393
  ?>
394
+ <p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file. Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
395
  <div id='rewriterules' style='display: none;'>
396
+ <?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n"; ?>
397
  </div>
398
  <?php
399
  }
409
  }
410
 
411
  ?></fieldset><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  }
413
 
414
  function wp_cache_restore() {