WP Super Cache - Version 1.4.1

Version Description

Fix for XSS in settings page.

=

Download this release

Release Info

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

Code changes from version 1.4 to 1.4.1

Changelog.txt CHANGED
@@ -1,3 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2013-10-23 10:49 donncha
2
 
3
  * wp-super-cache.pot: Updated translation file
1
+ 2014-08-07 12:45 donncha
2
+
3
+ * wp-cache.php: Removed author information
4
+
5
+ 2014-08-06 12:41 kraftbj
6
+
7
+ * plugins/awaitingmoderation.php, plugins/badbehaviour.php,
8
+ plugins/domain-mapping.php, plugins/jetpack.php,
9
+ plugins/searchengine.php, plugins/wptouch.php, wp-cache.php: PR
10
+ #13: Added .button-primary and .button-secondary classes to and
11
+ removed &raquo's from buttons throughout the admin for
12
+ consistency. Ref:
13
+ https://github.com/Automattic/wp-super-cache/pull/13 Props:
14
+ rcowles
15
+
16
+ 2014-08-05 20:00 kraftbj
17
+
18
+ * ossdl-cdn.php, readme.txt, wp-cache.php: Fix bad merge.
19
+
20
+ 2014-08-05 19:56 kraftbj
21
+
22
+ * readme.txt: Add Jetpack to mobile FAQ.
23
+
24
+ 2014-08-05 19:56 kraftbj
25
+
26
+ * wp-cache.php: Remove CDN Sync Tools. No longer in WP.org repo
27
+
28
+ 2014-08-05 19:55 kraftbj
29
+
30
+ * ossdl-cdn.php, readme.txt, wp-cache.php: Update
31
+ wordpress.org/extend URLs
32
+
33
+ 2014-08-05 12:42 donncha
34
+
35
+ * wp-cache.php: Fix to avoid an XSS in the settings page. Props
36
+ Simon Waters, Surevine Limited.
37
+
38
+ 2014-08-04 22:04 kraftbj
39
+
40
+ * ossdl-cdn.php: Remove reference to CDN Sync. Plugin no longer in
41
+ repo.
42
+
43
+ 2014-07-31 21:09 kraftbj
44
+
45
+ * readme.txt: Add Jetpack to mobile FAQ.
46
+
47
+ 2014-07-31 21:09 kraftbj
48
+
49
+ * wp-cache.php: Remove CDN Sync Tools. No longer in WP.org repo
50
+
51
+ 2014-07-31 21:08 kraftbj
52
+
53
+ * ossdl-cdn.php, readme.txt, wp-cache-phase1.php, wp-cache.php:
54
+ Update wordpress.org/extend URLs
55
+
56
+ 2014-07-31 21:08 kraftbj
57
+
58
+ * plugins/awaitingmoderation.php, plugins/badbehaviour.php,
59
+ plugins/domain-mapping.php, plugins/dynamic-cache-test.php,
60
+ plugins/jetpack.php, plugins/searchengine.php,
61
+ plugins/wptouch.php: Trim whitespace
62
+
63
+ 2014-07-31 21:07 kraftbj
64
+
65
+ * wp-cache-config-sample.php, wp-cache-phase1.php, wp-cache.php:
66
+ Trim whitespace
67
+
68
+ 2014-07-31 21:06 kraftbj
69
+
70
+ * wp-cache.php: Admin: Add clear to h3 to pretify Recommended Links
71
+ title
72
+
73
+ 2014-07-31 20:51 donncha
74
+
75
+ * wp-cache-phase2.php: Make sure these are global so the function
76
+ knows about them. Props JoHenton and richardmtl
77
+ http://wordpress.org/support/topic/notices-appearing-above-site-pages-how-do-i-get-rid-of-them?replies=2
78
  2013-10-23 10:49 donncha
79
 
80
  * wp-super-cache.pot: Updated translation file
advanced-cache.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
  # WP SUPER CACHE 1.2
3
  function wpcache_broken_message() {
 
 
 
 
4
  if ( false == strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) )
5
  echo "<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->";
6
  }
1
  <?php
2
  # WP SUPER CACHE 1.2
3
  function wpcache_broken_message() {
4
+ global $wp_cache_config_file;
5
+ if ( isset( $wp_cache_config_file ) == false )
6
+ return '';
7
+
8
  if ( false == strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) )
9
  echo "<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->";
10
  }
ossdl-cdn.php CHANGED
@@ -149,7 +149,6 @@ function scossdl_off_options() {
149
  $example_cdn_uri .= '/wp-includes/js/prototype.js';
150
  ?>
151
  <p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="http://knowledgelayer.softlayer.com/questions/365/How+does+Origin+Pull+work%3F" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
152
- <p><?php printf( __( 'The <a href="%1$s">CDN Sync Tool</a> plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the <a href="%2$s">plugin support forum</a> if you have any queries about this plugin.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10' ); ?></p>
153
  <p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . $example_cdn_uri . '</code>' ); ?></p>
154
  <p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
155
  <p><form method="post" action="">
@@ -196,7 +195,7 @@ function scossdl_off_options() {
196
  <input type="hidden" name="action" value="update_ossdl_off" />
197
  <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
198
  </form></p>
199
- <p><?php _e( 'CDN functionality provided by <a href="http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
200
  <?php
201
  }
202
  ?>
149
  $example_cdn_uri .= '/wp-includes/js/prototype.js';
150
  ?>
151
  <p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="http://knowledgelayer.softlayer.com/questions/365/How+does+Origin+Pull+work%3F" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
 
152
  <p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . $example_cdn_uri . '</code>' ); ?></p>
153
  <p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
154
  <p><form method="post" action="">
195
  <input type="hidden" name="action" value="update_ossdl_off" />
196
  <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
197
  </form></p>
198
+ <p><?php _e( 'CDN functionality provided by <a href="http://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
199
  <?php
200
  }
201
  ?>
plugins/awaitingmoderation.php CHANGED
@@ -16,7 +16,7 @@ add_cacheaction( 'add_cacheaction', 'awaitingmoderation_actions' );
16
  //Your comment is awaiting moderation.
17
  function wp_supercache_awaitingmoderation_admin() {
18
  global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
19
-
20
  $cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
21
 
22
  if(isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
@@ -28,7 +28,7 @@ function wp_supercache_awaitingmoderation_admin() {
28
  }
29
  $id = 'awaitingmoderation-section';
30
  ?>
31
- <fieldset id="<?php echo $id; ?>" class="options">
32
  <h4><?php _e( 'Awaiting Moderation', 'wp-super-cache' ); ?></h4>
33
  <form name="wp_manager" action="" method="post">
34
  <label><input type="radio" name="cache_awaitingmoderation" value="1" <?php if( $cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
@@ -42,7 +42,7 @@ function wp_supercache_awaitingmoderation_admin() {
42
  $status = __( "disabled" );
43
  echo "<p><strong>" . sprintf( __( "Awaiting Moderation is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
44
  }
45
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
46
  wp_nonce_field('wp-cache');
47
  ?>
48
  </form>
16
  //Your comment is awaiting moderation.
17
  function wp_supercache_awaitingmoderation_admin() {
18
  global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
19
+
20
  $cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
21
 
22
  if(isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
28
  }
29
  $id = 'awaitingmoderation-section';
30
  ?>
31
+ <fieldset id="<?php echo $id; ?>" class="options">
32
  <h4><?php _e( 'Awaiting Moderation', 'wp-super-cache' ); ?></h4>
33
  <form name="wp_manager" action="" method="post">
34
  <label><input type="radio" name="cache_awaitingmoderation" value="1" <?php if( $cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
42
  $status = __( "disabled" );
43
  echo "<p><strong>" . sprintf( __( "Awaiting Moderation is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
44
  }
45
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
46
  wp_nonce_field('wp-cache');
47
  ?>
48
  </form>
plugins/badbehaviour.php CHANGED
@@ -33,7 +33,7 @@ function get_bb_file_loc() {
33
 
34
  function wp_supercache_badbehaviour_admin() {
35
  global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
36
-
37
  $cache_badbehaviour = $cache_badbehaviour == '' ? 0 : $cache_badbehaviour;
38
  if ( $cache_badbehaviour == 'no' )
39
  $cache_badbehaviour = 0;
@@ -59,7 +59,7 @@ function wp_supercache_badbehaviour_admin() {
59
  }
60
  $id = 'badbehavior-section';
61
  ?>
62
- <fieldset id="<?php echo $id; ?>" class="options">
63
  <h4><?php _e( 'Bad Behavior', 'wp-super-cache' ); ?></h4>
64
  <form name="wp_manager" action="" method="post">
65
  <label><input type="radio" name="cache_badbehaviour" value="1" <?php if( $cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
@@ -73,7 +73,7 @@ function wp_supercache_badbehaviour_admin() {
73
  $status = __( "disabled" );
74
  echo "<p><strong>" . sprintf( __( "Bad Behavior support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
75
  }
76
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
77
  wp_nonce_field('wp-cache');
78
  ?>
79
  </form>
33
 
34
  function wp_supercache_badbehaviour_admin() {
35
  global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
36
+
37
  $cache_badbehaviour = $cache_badbehaviour == '' ? 0 : $cache_badbehaviour;
38
  if ( $cache_badbehaviour == 'no' )
39
  $cache_badbehaviour = 0;
59
  }
60
  $id = 'badbehavior-section';
61
  ?>
62
+ <fieldset id="<?php echo $id; ?>" class="options">
63
  <h4><?php _e( 'Bad Behavior', 'wp-super-cache' ); ?></h4>
64
  <form name="wp_manager" action="" method="post">
65
  <label><input type="radio" name="cache_badbehaviour" value="1" <?php if( $cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
73
  $status = __( "disabled" );
74
  echo "<p><strong>" . sprintf( __( "Bad Behavior support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
75
  }
76
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
77
  wp_nonce_field('wp-cache');
78
  ?>
79
  </form>
plugins/domain-mapping.php CHANGED
@@ -22,8 +22,8 @@ function domain_mapping_gc_cache( $function, $directory ) {
22
  @wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
23
  break;
24
  case "prune":
25
- prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true );
26
- prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
27
  break;
28
  }
29
 
@@ -55,7 +55,7 @@ add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
55
 
56
  function wp_supercache_domain_mapping_admin() {
57
  global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
58
-
59
  $cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
60
 
61
  if(isset($_POST['cache_domain_mapping']) && $valid_nonce) {
@@ -69,7 +69,7 @@ function wp_supercache_domain_mapping_admin() {
69
  }
70
  $id = 'domain_mapping-section';
71
  ?>
72
- <fieldset id="<?php echo $id; ?>" class="options">
73
  <h4><?php _e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
74
  <form name="wp_manager" action="" method="post">
75
  <label><input type="radio" name="cache_domain_mapping" value="1" <?php if( $cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
@@ -83,7 +83,7 @@ function wp_supercache_domain_mapping_admin() {
83
  $status = __( "disabled" );
84
  echo "<p><strong>" . sprintf( __( "Domain Mapping support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
85
  }
86
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
87
  wp_nonce_field('wp-cache');
88
  ?>
89
  </form>
22
  @wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
23
  break;
24
  case "prune":
25
+ prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true );
26
+ prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
27
  break;
28
  }
29
 
55
 
56
  function wp_supercache_domain_mapping_admin() {
57
  global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
58
+
59
  $cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
60
 
61
  if(isset($_POST['cache_domain_mapping']) && $valid_nonce) {
69
  }
70
  $id = 'domain_mapping-section';
71
  ?>
72
+ <fieldset id="<?php echo $id; ?>" class="options">
73
  <h4><?php _e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
74
  <form name="wp_manager" action="" method="post">
75
  <label><input type="radio" name="cache_domain_mapping" value="1" <?php if( $cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
83
  $status = __( "disabled" );
84
  echo "<p><strong>" . sprintf( __( "Domain Mapping support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
85
  }
86
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
87
  wp_nonce_field('wp-cache');
88
  ?>
89
  </form>
plugins/dynamic-cache-test.php CHANGED
@@ -1,113 +1,169 @@
1
  <?php
2
 
3
  /*
4
- * A function that uses the wpsc_cachedata filter to add a small message
5
- * and the current server time to every web page. The time increments
6
- * on every reload.
7
  *
8
- * On the Advanced Settings page enable "Enable dynamic caching".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  *
10
  * dynamic_cache_test_init()
11
- * This function is the first one to be called. This function hooks
12
  * dynamic_cache_test_template() to the WordPress action, wp_footer.
13
- * This script is loaded before WordPress is and the add_action()
14
- * function isn't defined at this time.
15
  * This init function hooks onto the cache action "add_cacheaction"
16
  * that fires after WordPress (and add_action) is loaded.
17
  *
18
  *
19
  * dynamic_cache_test_template_tag()
20
- * This function hooks on to wp_footer and displays the secret template
21
  * tag that will be replaced by our dynamic content on each page view.
22
  *
23
  *
24
  * dynamic_cache_test_filter()
25
  * This function hooks on to the filter through which all the cached data
26
  * sent to visitors is sent.
27
- * In this simple example the template tag is replaced by a html comment
28
- * containing the text "Hello world at " and the current server time.
29
- * If you want to use the output of a WordPress plugin or command you
30
- * must enable "late init" on the settings page. Each time you reload
31
- * the cached page this time will change. View the page source to examine
32
  * this text.
33
  *
34
- * Plugin authors: NEVER define the template tag for your users. Make them
35
- * choose one so it will be unique to their site.
36
- *
37
- * **** MAKE SURE YOU KEEP THE TEMPLATE TAG SECRET ****
38
- *
39
  */
 
 
 
 
 
 
40
 
41
 
42
- /*
43
- * Uncomment the code below, enable dynamic caching on the Advanced Settings
44
- * page and clear the cache.
45
- * Be sure to define DYNAMIC_CACHE_TEST_TAG too. Make it a random string
46
- * that will never appear on your website. In your own application this
47
- * tag can be whatever you like.
48
- */
49
-
50
- /*
51
- define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // CHANGE THIS!
52
- define( 'DYNAMIC_OUTPUT_BUFFER_TAG', '' ); // CHANGE THIS!
53
 
54
- if ( DYNAMIC_CACHE_TEST_TAG == '' )
55
- return false;
 
56
 
57
- // To use an output buffer when generating the dynamic section of your web page
58
- // you must generate the HTML/JS/CSS and store it before the page is completed.
59
- // That stored text is used by the wpsc_cachedata filter later when the same
60
- // function is called again.
61
- // You must also create a safety function. This function checks that your newly
62
- // cached page is ready to be processed by the wpsc_cachedata filter. It's not
63
- // required for already cached pages.
64
- // See dynamic_output_buffer_test_safety() for an example. You must add this
65
- // to avoid the following error:
66
- // "PHP Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in..."
67
- //
68
- // Steps to run example plugin:
69
- // 1. Add the DYNAMIC_OUTPUT_BUFFER_TAG text (as defined above) to your theme where the dynamic content should be.
70
- // 2. Call dynamic_output_buffer_test() from your theme or an action like wp_footer
71
- // 3. Clear all cached files.
72
 
73
- function dynamic_output_buffer_test( &$cachedata = 0 ) {
74
- if ( defined( 'DYNAMIC_OB_TEXT' ) )
75
- return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
- ob_start();
78
- // call the sidebar function, do something dynamic
79
- echo "<p>This is a test. The current time on the server is: " . date( 'H:i:s' ) . "</p>";
80
- $text = ob_get_contents();
81
- ob_end_clean();
82
 
83
- if ( $cachedata === 0 ) // called directly from the theme so store the output
84
- define( 'DYNAMIC_OB_TEXT', $text );
85
- else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php
86
- return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
87
 
88
- }
89
- add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' );
 
 
 
90
 
91
- function dynamic_output_buffer_test_safety( $safety ) {
92
- if ( defined( 'DYNAMIC_OB_TEXT' ) )
93
- return 1; // ready to replace tag with dynamic content.
94
- else
95
- return 0; // tag cannot be replaced.
96
- }
97
- add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
98
 
99
- function dynamic_cache_test_filter( &$cachedata) {
100
- return str_replace( DYNAMIC_CACHE_TEST_TAG, "<!-- Hello world at " . date( 'H:i:s' ) . " -->", $cachedata );
101
- }
102
- add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_test_filter' );
103
 
104
- function dynamic_cache_test_template_tag() {
105
- echo DYNAMIC_CACHE_TEST_TAG; // This is the template tag
106
- }
 
107
 
108
- function dynamic_cache_test_init() {
109
- add_action( 'wp_footer', 'dynamic_cache_test_template_tag' );
 
 
 
 
 
110
  }
111
- add_cacheaction( 'add_cacheaction', 'dynamic_cache_test_init' );
112
- */
113
  ?>
1
  <?php
2
 
3
  /*
4
+ * On the Advanced Settings page enable "Enable dynamic caching" and clear
5
+ * the cache.
 
6
  *
7
+ * Plugin authors: NEVER define the template tag for your users. Make them
8
+ * choose one so it will be unique to their site.
9
+ *
10
+ * There are two examples in this file. Both use template tags that must be
11
+ * kept secret.
12
+ *
13
+ * GLOSSARY:
14
+ *
15
+ * Dynamic content: the text or widget you want to show visitors to your site
16
+ * that changes every time it's viewed.
17
+ * Placeholder/template tag: the string of random characters placed in your
18
+ * theme file or printed in an action where the dynamic content will go.
19
+ * Output buffer (ob): any text that is printed by PHP to be sent to the browser
20
+ * but captured by PHP for further manipulation.
21
+ * OB Callback function: A function that is called when the output buffer is
22
+ * filled with a html page. The contents of the page are passed to the function
23
+ * for processing.
24
+ *
25
+ * **** MAKE SURE YOU KEEP THE TEMPLATE TAG SECRET ****
26
+ */
27
+
28
+ /*
29
+ * EXAMPLE 1
30
+ * http://ocaoimh.ie/2013/10/21/shiny-new-dynamic-content-wp-super-cache/
31
+ * Replace a string in your theme with the dynamic content.
32
  *
33
  * dynamic_cache_test_init()
34
+ * This function is the first one to be called. This function hooks
35
  * dynamic_cache_test_template() to the WordPress action, wp_footer.
36
+ * This script is loaded before WordPress is and the add_action()
37
+ * function isn't defined at this time.
38
  * This init function hooks onto the cache action "add_cacheaction"
39
  * that fires after WordPress (and add_action) is loaded.
40
  *
41
  *
42
  * dynamic_cache_test_template_tag()
43
+ * This function hooks on to wp_footer and displays the secret template
44
  * tag that will be replaced by our dynamic content on each page view.
45
  *
46
  *
47
  * dynamic_cache_test_filter()
48
  * This function hooks on to the filter through which all the cached data
49
  * sent to visitors is sent.
50
+ * In this simple example the template tag is replaced by a html comment
51
+ * containing the text "Hello world at " and the current server time.
52
+ * If you want to use the output of a WordPress plugin or command you
53
+ * must enable "late init" on the settings page. Each time you reload
54
+ * the cached page this time will change. View the page source to examine
55
  * this text.
56
  *
 
 
 
 
 
57
  */
58
+ define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // Change this to a secret placeholder tag
59
+ if ( DYNAMIC_CACHE_TEST_TAG != '' ) {
60
+ function dynamic_cache_test_safety( $safety ) {
61
+ return 1;
62
+ }
63
+ add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
64
 
65
 
66
+ function dynamic_cache_test_filter( &$cachedata) {
67
+ return str_replace( DYNAMIC_CACHE_TEST_TAG, "<!-- Hello world at " . date( 'H:i:s' ) . " -->", $cachedata );
68
+ }
69
+ add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_test_filter' );
 
 
 
 
 
 
 
70
 
71
+ function dynamic_cache_test_template_tag() {
72
+ echo DYNAMIC_CACHE_TEST_TAG; // This is the template tag
73
+ }
74
 
75
+ function dynamic_cache_test_init() {
76
+ add_action( 'wp_footer', 'dynamic_cache_test_template_tag' );
77
+ }
78
+ add_cacheaction( 'add_cacheaction', 'dynamic_cache_test_init' );
79
+ }
 
 
 
 
 
 
 
 
 
 
80
 
81
+ /*
82
+ * EXAMPLE 2
83
+ *
84
+ * This is going to be complicated. Hang on!
85
+ *
86
+ * When the cache file for a new page is generated the plugin uses an output
87
+ * buffer to capture the page. A callback function processes the buffer and
88
+ * writes to the cache file. The placeholder tag for any dynamic content has
89
+ * to be written to that cache file but also, it has to be replaced with
90
+ * dynamic content before the page is shown to the user.
91
+ * More on output buffers here: http://php.net/ob_start
92
+ *
93
+ * Unfortunately an extra output buffer is often required when capturing dynamic
94
+ * content such as sidebar widgets. Due to a quirk of the way PHP works it's
95
+ * not possible to have an output buffer run in an output buffer callback. That
96
+ * dynamic content has to be generated before the callback function is reached.
97
+ * The following error occurs when an output buffer is created in the
98
+ * callback function of another output buffer:
99
+ * "PHP Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in..."
100
+ *
101
+ * In this example the function add_action() isn't available when this file is
102
+ * loaded so dynamic_output_buffer_init() is hooked on to the "add_cacheaction"
103
+ * cacheaction. That function then hooks dynamic_output_buffer_test() on to the
104
+ * familiar wp_footer action.
105
+ *
106
+ * The first time dynamic_output_buffer_test() runs it generates the dynamic
107
+ * content and captures it with ob_start() in the DYNAMIC_OB_TEXT constant.
108
+ *
109
+ * When the main WP Super Cache output buffer is ready the callback is called.
110
+ * This fires the wpsc_cachedata_safety filter. If the DYNAMIC_OB_TEXT constant
111
+ * is set, which means dynamic content is ready, then it returns 1, a signal
112
+ * that everything is ok.
113
+ * Finally, the wpsc_cachedata filter is run. The function
114
+ * dynamic_output_buffer_test() is hooked on to it. Since DYNAMIC_OB_TEXT is
115
+ * set it replaces the placeholder text with that constant.
116
+ * The resulting html is then sent to the browser.
117
+ *
118
+ * Already cached pages call the safety filter, and then the wpsc_cachedata
119
+ * filter so any hooked function must be ready to generate dynamic content. The
120
+ * very last line of dynamic_output_buffer_test() replaces the placeholder tag
121
+ * with the dynamic content in the cache file.
122
+ *
123
+ *
124
+ * Use an output buffer to capture dynamic content while the page is generated
125
+ * and insert into the right place:
126
+ * Remember to add the DYNAMIC_OUTPUT_BUFFER_TAG text (as defined below) to
127
+ * your theme where the dynamic content should be.
128
+ *
129
+ * dynamic_output_buffer_test() is a function that uses the wpsc_cachedata
130
+ * filter to add a small message and the current server time to every web
131
+ * page. The time increments on every reload.
132
+ *
133
+ */
134
 
135
+ define( 'DYNAMIC_OUTPUT_BUFFER_TAG', '' ); // Change this to a secret placeholder tag
 
 
 
 
136
 
137
+ if ( DYNAMIC_OUTPUT_BUFFER_TAG != '' ) {
138
+ function dynamic_output_buffer_test( &$cachedata = 0 ) {
139
+ if ( defined( 'DYNAMIC_OB_TEXT' ) )
140
+ return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata );
141
 
142
+ ob_start();
143
+ // call the sidebar function, do something dynamic
144
+ echo "<p>This is a test. The current time on the server is: " . date( 'H:i:s' ) . "</p>";
145
+ $text = ob_get_contents();
146
+ ob_end_clean();
147
 
148
+ if ( $cachedata === 0 ) { // called directly from the theme so store the output
149
+ define( 'DYNAMIC_OB_TEXT', $text );
150
+ } else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php
151
+ return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
 
 
 
152
 
153
+ }
154
+ add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' );
 
 
155
 
156
+ function dynamic_output_buffer_init() {
157
+ add_action( 'wp_footer', 'dynamic_output_buffer_test' );
158
+ }
159
+ add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' );
160
 
161
+ function dynamic_output_buffer_test_safety( $safety ) {
162
+ if ( defined( 'DYNAMIC_OB_TEXT' ) ) // this is set when you call dynamic_output_buffer_test() from the theme
163
+ return 1; // ready to replace tag with dynamic content.
164
+ else
165
+ return 0; // tag cannot be replaced.
166
+ }
167
+ add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
168
  }
 
 
169
  ?>
plugins/jetpack.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  function wp_super_cache_jetpack_admin() {
4
  global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
5
-
6
  $cache_jetpack = $cache_jetpack == '' ? '0' : $cache_jetpack;
7
 
8
  if(isset($_POST['cache_jetpack']) && $valid_nonce) {
@@ -21,7 +21,7 @@ function wp_super_cache_jetpack_admin() {
21
  }
22
  $id = 'jetpack-section';
23
  ?>
24
- <fieldset id="<?php echo $id; ?>" class="options">
25
  <h4><?php _e( 'Jetpack Mobile Theme', 'wp-super-cache' ); ?></h4>
26
  <?php
27
  if ( false == file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
@@ -39,7 +39,7 @@ function wp_super_cache_jetpack_admin() {
39
  $status = __( "disabled" );
40
  echo "<p><strong>" . sprintf( __( "Jetpack Mobile Theme support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
41
  }
42
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
43
  wp_nonce_field('wp-cache');
44
  ?>
45
  </form>
2
 
3
  function wp_super_cache_jetpack_admin() {
4
  global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
5
+
6
  $cache_jetpack = $cache_jetpack == '' ? '0' : $cache_jetpack;
7
 
8
  if(isset($_POST['cache_jetpack']) && $valid_nonce) {
21
  }
22
  $id = 'jetpack-section';
23
  ?>
24
+ <fieldset id="<?php echo $id; ?>" class="options">
25
  <h4><?php _e( 'Jetpack Mobile Theme', 'wp-super-cache' ); ?></h4>
26
  <?php
27
  if ( false == file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
39
  $status = __( "disabled" );
40
  echo "<p><strong>" . sprintf( __( "Jetpack Mobile Theme support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
41
  }
42
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
43
  wp_nonce_field('wp-cache');
44
  ?>
45
  </form>
plugins/searchengine.php CHANGED
@@ -54,7 +54,7 @@ add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
54
 
55
  function wp_supercache_searchengine_admin() {
56
  global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
57
-
58
  $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
59
 
60
  if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
@@ -63,7 +63,7 @@ function wp_supercache_searchengine_admin() {
63
  }
64
  $id = 'no_adverts_for_friends-section';
65
  ?>
66
- <fieldset id="<?php echo $id; ?>" class="options">
67
  <h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
68
  <form name="wp_manager" action="" method="post">
69
  <label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if( $cache_no_adverts_for_friends == 'yes' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
@@ -77,7 +77,7 @@ function wp_supercache_searchengine_admin() {
77
  $status = __( "disabled" );
78
  echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
79
  }
80
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
81
  wp_nonce_field('wp-cache');
82
  ?>
83
  </form>
54
 
55
  function wp_supercache_searchengine_admin() {
56
  global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
57
+
58
  $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
59
 
60
  if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
63
  }
64
  $id = 'no_adverts_for_friends-section';
65
  ?>
66
+ <fieldset id="<?php echo $id; ?>" class="options">
67
  <h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
68
  <form name="wp_manager" action="" method="post">
69
  <label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if( $cache_no_adverts_for_friends == 'yes' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
77
  $status = __( "disabled" );
78
  echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
79
  }
80
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
81
  wp_nonce_field('wp-cache');
82
  ?>
83
  </form>
plugins/wptouch.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  function wp_super_cache_wptouch_admin() {
4
  global $cache_wptouch, $wp_cache_config_file, $valid_nonce;
5
-
6
  $cache_wptouch = $cache_wptouch == '' ? '0' : $cache_wptouch;
7
 
8
  if(isset($_POST['cache_wptouch']) && $valid_nonce) {
@@ -16,7 +16,7 @@ function wp_super_cache_wptouch_admin() {
16
  }
17
  $id = 'wptouch-section';
18
  ?>
19
- <fieldset id="<?php echo $id; ?>" class="options">
20
  <h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
21
  <form name="wp_manager" action="" method="post">
22
  <label><input type="radio" name="cache_wptouch" value="1" <?php if( $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
@@ -30,7 +30,7 @@ function wp_super_cache_wptouch_admin() {
30
  $status = __( "disabled" );
31
  echo "<p><strong>" . sprintf( __( "WPTouch support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
32
  }
33
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
34
  wp_nonce_field('wp-cache');
35
  ?>
36
  </form>
@@ -57,7 +57,7 @@ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
57
  add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
58
  }
59
 
60
- // disable mobile checking if
61
  function wp_super_cache_maybe_disable_wptouch( $t ) {
62
  global $cache_wptouch, $wptouch_exclude_ua;
63
  if ( $cache_wptouch != 1 )
@@ -96,7 +96,7 @@ function wp_super_cache_wptouch_browsers( $browsers ) {
96
 
97
  function wp_super_cache_wptouch_prefixes( $prefixes ) {
98
  return array(); // wptouch doesn't support UA prefixes
99
- }
100
 
101
  function wp_super_cache_wptouch_cookie_check( $cache_key ) {
102
  if ( false == isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) )
2
 
3
  function wp_super_cache_wptouch_admin() {
4
  global $cache_wptouch, $wp_cache_config_file, $valid_nonce;
5
+
6
  $cache_wptouch = $cache_wptouch == '' ? '0' : $cache_wptouch;
7
 
8
  if(isset($_POST['cache_wptouch']) && $valid_nonce) {
16
  }
17
  $id = 'wptouch-section';
18
  ?>
19
+ <fieldset id="<?php echo $id; ?>" class="options">
20
  <h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
21
  <form name="wp_manager" action="" method="post">
22
  <label><input type="radio" name="cache_wptouch" value="1" <?php if( $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
30
  $status = __( "disabled" );
31
  echo "<p><strong>" . sprintf( __( "WPTouch support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
32
  }
33
+ echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
34
  wp_nonce_field('wp-cache');
35
  ?>
36
  </form>
57
  add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
58
  }
59
 
60
+ // disable mobile checking if
61
  function wp_super_cache_maybe_disable_wptouch( $t ) {
62
  global $cache_wptouch, $wptouch_exclude_ua;
63
  if ( $cache_wptouch != 1 )
96
 
97
  function wp_super_cache_wptouch_prefixes( $prefixes ) {
98
  return array(); // wptouch doesn't support UA prefixes
99
+ }
100
 
101
  function wp_super_cache_wptouch_cookie_check( $cache_key ) {
102
  if ( false == isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) )
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 3.9
5
- Stable tag: 1.4
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -56,10 +56,15 @@ The cache directory, usually wp-content/cache/ is only for temporary files. Do n
56
 
57
  == Upgrade Notice ==
58
 
59
- = 1.4 =
60
- Dynamic cached content now disabled by default. mfunc replaced by wpsc_cachedata filter. Read http://ocaoimh.ie/y/6j before updating if you use mfunc/mclude/dynamic-cached-content.
61
 
62
  == Changelog ==
 
 
 
 
 
63
  = 1.4 =
64
  * Replace legacy mfunc/mnclude/dynamic-cached-content functionality with a "wpsc_cachedata" cacheaction filter.
65
  * Added dynamic-cache-test.php plugin example wpsc_cachedata filter plugin.
@@ -460,10 +465,11 @@ The only real limit are limits defined by your server. For example, EXT2 and EXT
460
  = How do I serve cached mobile pages to clients on small screens like phones and tablets? =
461
 
462
  You'll have to use a separate mobile plugin to render a page formatted for those visitors. The following plugins have been tested but YMMV depending on mobile client.
463
- * [WPTouch] (http://wordpress.org/extend/plugins/wptouch/)
464
- * [WordPress Mobile Edition] (http://wordpress.org/extend/plugins/wordpress-mobile-edition/)
465
- * [WordPress Mobile Pack] (http://wordpress.org/extend/plugins/wordpress-mobile-pack/) (can't have "Don't cache pages for known users." enabled)
466
 
 
 
 
 
467
 
468
  = Troubleshooting =
469
 
@@ -508,7 +514,7 @@ If that doesn't work, add this line to your wp-config.php:
508
  26. If certain characters do not appear correctly on your website your server may not be configured correctly. You need to tell visitors what character set is used. Go to Settings->Reading and copy the 'Encoding for pages and feeds' value. Edit the .htaccess file with all your Supercache and WordPress rewrite rules and add this at the top, replacing CHARSET with the copied value. (for example, 'UTF-8')
509
 
510
  `AddDefaultCharset CHARSET`
511
- 27. Use [Cron View](http://wordpress.org/extend/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
512
  18. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
513
 
514
 
@@ -516,7 +522,7 @@ If that doesn't work, add this line to your wp-config.php:
516
 
517
  A Content Delivery Network (CDN) is usually a network of computers situated around the world that will serve the content of your website faster by using servers close to you. Static files like images, Javascript and CSS files can be served through these networks to speed up how fast your site loads. You can also create a "poor man's CDN" by using a sub domain of your domain to serve static files too.
518
 
519
- [OSSDL CDN off-linker](http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/) has been integrated into WP Super Cache to provide basic CDN support. It works by rewriting the URLs of files (excluding .php files) in wp-content and wp-includes on your server so they point at a different hostname. Many CDNs support [origin pull](http://www.google.com/search?hl=en&q=%22origin+pull%22). This means the CDN will download the file automatically from your server when it's first requested, and will continue to serve it for a configurable length of time before downloading it again from your server.
520
 
521
  Configure this on the "CDN" tab of the plugin settings page. This is an advanced technique and requires a basic understanding of how your webserver or CDNs work. Please be sure to clear the file cache after you configure the CDN.
522
 
@@ -536,7 +542,7 @@ The output of WP-Cache's wp_cache_get_cookies_values() function.
536
  See plugins/searchengine.php as an example I use for my [No Adverts for Friends](http://ocaoimh.ie/no-adverts-for-friends/) plugin.
537
 
538
  == Links ==
539
- [WP Widget Cache](http://wordpress.org/extend/plugins/wp-widget-cache/) is another caching plugin for WordPress. This plugin caches the output of widgets and may significantly speed up dynamic page generation times.
540
 
541
  == Updates ==
542
  Updates to the plugin will be posted here, to [Holy Shmoly!](http://ocaoimh.ie/) and the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) will always link to the newest version.
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 3.9.2
5
+ Stable tag: 1.4.1
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
56
 
57
  == Upgrade Notice ==
58
 
59
+ = 1.4.1 =
60
+ Fix for XSS in settings page.
61
 
62
  == Changelog ==
63
+ = 1.4.1 =
64
+ * Fixed XSS in settings page. Props Simon Waters, Surevine Limited.
65
+ * Fix to object cache so entries may now be deleted when posts updated. (object cache still experimental)
66
+ * Documentation updates and cleanup of settings page.
67
+
68
  = 1.4 =
69
  * Replace legacy mfunc/mnclude/dynamic-cached-content functionality with a "wpsc_cachedata" cacheaction filter.
70
  * Added dynamic-cache-test.php plugin example wpsc_cachedata filter plugin.
465
  = How do I serve cached mobile pages to clients on small screens like phones and tablets? =
466
 
467
  You'll have to use a separate mobile plugin to render a page formatted for those visitors. The following plugins have been tested but YMMV depending on mobile client.
 
 
 
468
 
469
+ * [Jetpack's Mobile Theme Module](http://wordpress.org/plugins/jetpack)
470
+ * [WPTouch](http://wordpress.org/plugins/wptouch/)
471
+ * [WordPress Mobile Edition](http://wordpress.org/plugins/wordpress-mobile-edition/)
472
+ * [WordPress Mobile Pack](http://wordpress.org/plugins/wordpress-mobile-pack/) (can't have "Don't cache pages for known users." enabled)
473
 
474
  = Troubleshooting =
475
 
514
  26. If certain characters do not appear correctly on your website your server may not be configured correctly. You need to tell visitors what character set is used. Go to Settings->Reading and copy the 'Encoding for pages and feeds' value. Edit the .htaccess file with all your Supercache and WordPress rewrite rules and add this at the top, replacing CHARSET with the copied value. (for example, 'UTF-8')
515
 
516
  `AddDefaultCharset CHARSET`
517
+ 27. Use [Cron View](http://wordpress.org/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
518
  18. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
519
 
520
 
522
 
523
  A Content Delivery Network (CDN) is usually a network of computers situated around the world that will serve the content of your website faster by using servers close to you. Static files like images, Javascript and CSS files can be served through these networks to speed up how fast your site loads. You can also create a "poor man's CDN" by using a sub domain of your domain to serve static files too.
524
 
525
+ [OSSDL CDN off-linker](http://wordpress.org/plugins/ossdl-cdn-off-linker/) has been integrated into WP Super Cache to provide basic CDN support. It works by rewriting the URLs of files (excluding .php files) in wp-content and wp-includes on your server so they point at a different hostname. Many CDNs support [origin pull](http://www.google.com/search?hl=en&q=%22origin+pull%22). This means the CDN will download the file automatically from your server when it's first requested, and will continue to serve it for a configurable length of time before downloading it again from your server.
526
 
527
  Configure this on the "CDN" tab of the plugin settings page. This is an advanced technique and requires a basic understanding of how your webserver or CDNs work. Please be sure to clear the file cache after you configure the CDN.
528
 
542
  See plugins/searchengine.php as an example I use for my [No Adverts for Friends](http://ocaoimh.ie/no-adverts-for-friends/) plugin.
543
 
544
  == Links ==
545
+ [WP Widget Cache](http://wordpress.org/plugins/wp-widget-cache/) is another caching plugin for WordPress. This plugin caches the output of widgets and may significantly speed up dynamic page generation times.
546
 
547
  == Updates ==
548
  Updates to the plugin will be posted here, to [Holy Shmoly!](http://ocaoimh.ie/) and the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) will always link to the newest version.
wp-cache-base.php CHANGED
@@ -19,6 +19,8 @@ if ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_AL
19
  if( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
20
  $blogcacheid = $WPSC_HTTP_HOST;
21
  } else {
 
 
22
  $request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
23
  if( strpos( $request_uri, '/', 1 ) ) {
24
  if( $base == '/' ) {
19
  if( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
20
  $blogcacheid = $WPSC_HTTP_HOST;
21
  } else {
22
+ if ( isset( $base ) == false )
23
+ $base = '';
24
  $request_uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI'] ) );
25
  if( strpos( $request_uri, '/', 1 ) ) {
26
  if( $base == '/' ) {
wp-cache-config-sample.php CHANGED
@@ -17,7 +17,7 @@ $cache_path = WP_CONTENT_DIR . '/cache/';
17
  $file_prefix = 'wp-cache-';
18
  $ossdlcdn = 0;
19
 
20
- // Array of files that have 'wp-' but should still be cached
21
  $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
22
 
23
  $cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
@@ -44,7 +44,7 @@ $wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Bla
44
  // change to relocate the supercache plugins directory
45
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
46
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
47
- $wp_cache_shutdown_gc = 0;
48
  $wp_super_cache_late_init = 0;
49
 
50
  // uncomment the next line to enable advanced debugging features
17
  $file_prefix = 'wp-cache-';
18
  $ossdlcdn = 0;
19
 
20
+ // Array of files that have 'wp-' but should still be cached
21
  $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
22
 
23
  $cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
44
  // change to relocate the supercache plugins directory
45
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
46
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
47
+ $wp_cache_shutdown_gc = 0;
48
  $wp_super_cache_late_init = 0;
49
 
50
  // uncomment the next line to enable advanced debugging features
wp-cache-phase1.php CHANGED
@@ -47,7 +47,7 @@ if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon )
47
 
48
  do_cacheaction( 'cache_init' );
49
 
50
- if (!$cache_enabled || $_SERVER["REQUEST_METHOD"] == 'POST')
51
  return true;
52
 
53
  $file_expired = false;
@@ -77,9 +77,9 @@ $wp_cache_request_uri = $_SERVER[ 'REQUEST_URI' ]; // Cache this in case any plu
77
  if ( $wp_cache_object_cache ) {
78
  if ( ! include_once( WP_CONTENT_DIR . '/object-cache.php' ) )
79
  return;
80
-
81
  wp_cache_init(); // Note: wp-settings.php calls wp_cache_init() which clobbers the object made here.
82
-
83
  if ( ! is_object( $wp_object_cache ) )
84
  return;
85
  }
@@ -135,7 +135,7 @@ function wp_cache_serve_cache_file() {
135
  return false;
136
  }
137
 
138
- if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
139
  if ( !empty( $_GET ) ) {
140
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Not serving request from object cache. " . print_r( $_GET, 1 ), 1 );
141
  return false;
@@ -187,35 +187,35 @@ function wp_cache_serve_cache_file() {
187
  $wp_cache_home_path = '/';
188
 
189
  // make sure ending slashes are ok
190
- if ( $wp_cache_request_uri == $wp_cache_home_path || ( $wp_cache_slash_check && substr( $wp_cache_request_uri, -1 ) == '/' ) || ( $wp_cache_slash_check == 0 && substr( $wp_cache_request_uri, -1 ) != '/' ) ) {
191
 
192
  if ( $wp_cache_mfunc_enabled == 0 ) {
193
  // get data from file
194
  if ( $wp_cache_gzip_encoding ) {
195
  if ( file_exists( $file . '.gz' ) ) {
196
  $cachefiledata = file_get_contents( $file . '.gz' );
197
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched gzip static page data from supercache file using PHP. File: $file.gz" );
198
  } else {
199
  $cachefiledata = gzencode( file_get_contents( $file ), 6, FORCE_GZIP );
200
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP and gzipped it. File: $file" );
201
  }
202
  } else {
203
  $cachefiledata = file_get_contents( $file );
204
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP. File: $file" );
205
  }
206
  } else {
207
  // get dynamic data from filtered file
208
- $cachefiledata = do_cacheaction( 'wpsc_cachedata', file_get_contents( $file ) );
209
  if ( $wp_cache_gzip_encoding ) {
210
  $cachefiledata = gzencode( $cachefiledata, 6, FORCE_GZIP );
211
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP and gzipped it. File: $file" );
212
  } else {
213
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP. File: $file" );
214
  }
215
  }
216
 
217
  if ( isset( $wp_cache_disable_utf8 ) == false || $wp_cache_disable_utf8 == 0 )
218
- header( "Content-type: text/html; charset=UTF-8" );
219
 
220
  header( "Vary: Accept-Encoding, Cookie" );
221
  header( "Cache-Control: max-age=3, must-revalidate" );
@@ -234,7 +234,10 @@ function wp_cache_serve_cache_file() {
234
  $request = apache_request_headers();
235
  $remote_mod_time = $request[ 'If-Modified-Since' ];
236
  } else {
237
- $remote_mod_time = $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ];
 
 
 
238
  }
239
  $local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT';
240
  if ( $remote_mod_time == $local_mod_time ) {
@@ -261,11 +264,11 @@ function wp_cache_serve_cache_file() {
261
  }
262
  foreach ($meta[ 'headers' ] as $t => $header) {
263
  // godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
264
- if( strpos( $header, 'Last-Modified:' ) === false )
265
  header($header);
266
  }
267
  header( 'WP-Super-Cache: Served legacy cache file' );
268
- if ( $wp_cache_object_cache ) {
269
  if ( $cache ) {
270
  if ( $ungzip ) {
271
  // attempt to uncompress the cached file just in case it's gzipped
@@ -278,7 +281,7 @@ function wp_cache_serve_cache_file() {
278
  }
279
  if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
280
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file from object cache", 5 );
281
- echo do_cacheaction( 'wpsc_cachedata', $cache );
282
  } else {
283
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file from object cache", 5 );
284
  echo $cache;
@@ -296,12 +299,12 @@ function wp_cache_serve_cache_file() {
296
  if ( $uncompressed ) {
297
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
298
  unset( $cache );
299
- echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
300
  } else {
301
- echo do_cacheaction( 'wpsc_cachedata', $cache );
302
  }
303
  } else {
304
- echo do_cacheaction( 'wpsc_cachedata', file_get_contents( $cache_file ) );
305
  }
306
  } else {
307
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file", 5 );
@@ -335,7 +338,7 @@ if ( !isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init )
335
  function wp_cache_postload() {
336
  global $cache_enabled, $wp_super_cache_late_init, $wp_super_cache_debug;
337
 
338
- if ( !$cache_enabled || isset( $_GET[ 'preview' ] ) )
339
  return true;
340
 
341
  if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
@@ -393,7 +396,7 @@ function do_cacheaction( $action, $value = '' ) {
393
  if ( is_array( $func ) ) {
394
  $value = $func[0]->{$func[1]}( $value );
395
  } else {
396
- $value = $func( $value );
397
  }
398
  }
399
  }
@@ -414,7 +417,7 @@ function wp_cache_mobile_group( $user_agent ) {
414
  return "mobile";
415
  }
416
 
417
- // From http://wordpress.org/extend/plugins/wordpress-mobile-edition/ by Alex King
418
  function wp_cache_check_mobile( $cache_key ) {
419
  global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
420
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
@@ -451,7 +454,7 @@ function wp_cache_check_mobile( $cache_key ) {
451
  return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
452
  }
453
  }
454
- if (isset($_SERVER['HTTP_X_WAP_PROFILE']) )
455
  return $cache_key . '-' . $_SERVER['HTTP_X_WAP_PROFILE'];
456
  if (isset($_SERVER['HTTP_PROFILE']) )
457
  return $cache_key . '-' . $_SERVER['HTTP_PROFILE'];
@@ -589,7 +592,7 @@ function get_all_supercache_filenames( $dir = '' ) {
589
 
590
  if ( $dir != '' && isset( $wp_cache_mobile_enabled ) && $wp_cache_mobile_enabled ) {
591
  // open directory and look for index-*.html files
592
- if ( is_dir( $dir ) && $dh = opendir( $dir ) ) {
593
  while ( ( $file = readdir( $dh ) ) !== false ) {
594
  if ( substr( $file, 0, 6 ) == 'index-' && strpos( $file, '.html' ) )
595
  $filenames[] = $file;
@@ -657,7 +660,7 @@ function get_oc_key( $url = false ) {
657
 
658
  function wp_supercache_cache_for_admins() {
659
  if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() )
660
- return $cookies;
661
 
662
  if ( false == do_cacheaction( 'wp_supercache_remove_cookies', true ) )
663
  return true;
47
 
48
  do_cacheaction( 'cache_init' );
49
 
50
+ if (!$cache_enabled || $_SERVER["REQUEST_METHOD"] == 'POST')
51
  return true;
52
 
53
  $file_expired = false;
77
  if ( $wp_cache_object_cache ) {
78
  if ( ! include_once( WP_CONTENT_DIR . '/object-cache.php' ) )
79
  return;
80
+
81
  wp_cache_init(); // Note: wp-settings.php calls wp_cache_init() which clobbers the object made here.
82
+
83
  if ( ! is_object( $wp_object_cache ) )
84
  return;
85
  }
135
  return false;
136
  }
137
 
138
+ if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
139
  if ( !empty( $_GET ) ) {
140
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Not serving request from object cache. " . print_r( $_GET, 1 ), 1 );
141
  return false;
187
  $wp_cache_home_path = '/';
188
 
189
  // make sure ending slashes are ok
190
+ if ( $wp_cache_request_uri == $wp_cache_home_path || ( $wp_cache_slash_check && substr( $wp_cache_request_uri, -1 ) == '/' ) || ( $wp_cache_slash_check == 0 && substr( $wp_cache_request_uri, -1 ) != '/' ) ) {
191
 
192
  if ( $wp_cache_mfunc_enabled == 0 ) {
193
  // get data from file
194
  if ( $wp_cache_gzip_encoding ) {
195
  if ( file_exists( $file . '.gz' ) ) {
196
  $cachefiledata = file_get_contents( $file . '.gz' );
197
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched gzip static page data from supercache file using PHP. File: $file.gz" );
198
  } else {
199
  $cachefiledata = gzencode( file_get_contents( $file ), 6, FORCE_GZIP );
200
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP and gzipped it. File: $file" );
201
  }
202
  } else {
203
  $cachefiledata = file_get_contents( $file );
204
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP. File: $file" );
205
  }
206
  } else {
207
  // get dynamic data from filtered file
208
+ $cachefiledata = do_cacheaction( 'wpsc_cachedata', file_get_contents( $file ) );
209
  if ( $wp_cache_gzip_encoding ) {
210
  $cachefiledata = gzencode( $cachefiledata, 6, FORCE_GZIP );
211
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP and gzipped it. File: $file" );
212
  } else {
213
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP. File: $file" );
214
  }
215
  }
216
 
217
  if ( isset( $wp_cache_disable_utf8 ) == false || $wp_cache_disable_utf8 == 0 )
218
+ header( "Content-type: text/html; charset=UTF-8" );
219
 
220
  header( "Vary: Accept-Encoding, Cookie" );
221
  header( "Cache-Control: max-age=3, must-revalidate" );
234
  $request = apache_request_headers();
235
  $remote_mod_time = $request[ 'If-Modified-Since' ];
236
  } else {
237
+ if ( isset( $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ] ) )
238
+ $remote_mod_time = $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ];
239
+ else
240
+ $remote_mod_time = 0;
241
  }
242
  $local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT';
243
  if ( $remote_mod_time == $local_mod_time ) {
264
  }
265
  foreach ($meta[ 'headers' ] as $t => $header) {
266
  // godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
267
+ if( strpos( $header, 'Last-Modified:' ) === false )
268
  header($header);
269
  }
270
  header( 'WP-Super-Cache: Served legacy cache file' );
271
+ if ( $wp_cache_object_cache ) {
272
  if ( $cache ) {
273
  if ( $ungzip ) {
274
  // attempt to uncompress the cached file just in case it's gzipped
281
  }
282
  if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
283
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file from object cache", 5 );
284
+ echo do_cacheaction( 'wpsc_cachedata', $cache );
285
  } else {
286
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file from object cache", 5 );
287
  echo $cache;
299
  if ( $uncompressed ) {
300
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
301
  unset( $cache );
302
+ echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
303
  } else {
304
+ echo do_cacheaction( 'wpsc_cachedata', $cache );
305
  }
306
  } else {
307
+ echo do_cacheaction( 'wpsc_cachedata', file_get_contents( $cache_file ) );
308
  }
309
  } else {
310
  if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file", 5 );
338
  function wp_cache_postload() {
339
  global $cache_enabled, $wp_super_cache_late_init, $wp_super_cache_debug;
340
 
341
+ if ( !$cache_enabled )
342
  return true;
343
 
344
  if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
396
  if ( is_array( $func ) ) {
397
  $value = $func[0]->{$func[1]}( $value );
398
  } else {
399
+ $value = $func( $value );
400
  }
401
  }
402
  }
417
  return "mobile";
418
  }
419
 
420
+ // From http://wordpress.org/plugins/wordpress-mobile-edition/ by Alex King
421
  function wp_cache_check_mobile( $cache_key ) {
422
  global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
423
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
454
  return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
455
  }
456
  }
457
+ if (isset($_SERVER['HTTP_X_WAP_PROFILE']) )
458
  return $cache_key . '-' . $_SERVER['HTTP_X_WAP_PROFILE'];
459
  if (isset($_SERVER['HTTP_PROFILE']) )
460
  return $cache_key . '-' . $_SERVER['HTTP_PROFILE'];
592
 
593
  if ( $dir != '' && isset( $wp_cache_mobile_enabled ) && $wp_cache_mobile_enabled ) {
594
  // open directory and look for index-*.html files
595
+ if ( is_dir( $dir ) && $dh = @opendir( $dir ) ) {
596
  while ( ( $file = readdir( $dh ) ) !== false ) {
597
  if ( substr( $file, 0, 6 ) == 'index-' && strpos( $file, '.html' ) )
598
  $filenames[] = $file;
660
 
661
  function wp_supercache_cache_for_admins() {
662
  if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() )
663
+ return true;
664
 
665
  if ( false == do_cacheaction( 'wp_supercache_remove_cookies', true ) )
666
  return true;
wp-cache-phase2.php CHANGED
@@ -46,45 +46,16 @@ function wp_cache_phase2() {
46
  do_cacheaction( 'add_cacheaction' );
47
  }
48
 
49
- if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
50
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
51
- return false;
52
- }
53
-
54
  if ( is_admin() ) {
55
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
56
  return false;
57
  }
58
 
59
- if ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
60
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching POST request.', 5 );
61
- return false;
62
- }
63
-
64
- if ( $wp_cache_object_cache && !empty( $_GET ) ) {
65
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
66
- return false;
67
- }
68
-
69
- if ( isset( $_GET[ 'preview' ] ) ) {
70
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching preview post.', 2 );
71
- return false;
72
- }
73
-
74
  if ( !empty( $_GET ) ) {
75
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . print_r( $_GET, 1 ), 5 );
76
  $super_cache_enabled = false;
77
  }
78
 
79
- $script = basename($_SERVER['PHP_SELF']);
80
- if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
81
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
82
- return false;
83
- }
84
- if (wp_cache_user_agent_is_rejected()) {
85
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
86
- return;
87
- }
88
  if($wp_cache_gzip_encoding)
89
  header('Vary: Accept-Encoding, Cookie');
90
  else
@@ -268,53 +239,79 @@ function wp_super_cache_query_vars() {
268
  }
269
 
270
  function wp_cache_ob_callback( $buffer ) {
271
- global $wp_cache_pages, $wp_query, $wp_super_cache_query;
272
  $buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
273
- if( defined( 'DONOTCACHEPAGE' ) ) {
274
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
275
- return $buffer;
276
- }
277
 
278
- if ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && isset( $wp_super_cache_query[ 'is_single' ] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single post.', 2 );
280
- return $buffer;
281
  } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && isset( $wp_super_cache_query[ 'is_page' ] ) ) {
282
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single page.', 2 );
283
- return $buffer;
284
  } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && isset( $wp_super_cache_query[ 'is_archive' ] ) ) {
285
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching archive page.', 2 );
286
- return $buffer;
287
  } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && isset( $wp_super_cache_query[ 'is_tag' ] ) ) {
288
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching tag page.', 2 );
289
- return $buffer;
290
  } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && isset( $wp_super_cache_query[ 'is_category' ] ) ) {
291
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching category page.', 2 );
292
- return $buffer;
293
  } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && isset( $wp_super_cache_query[ 'is_front_page' ] ) ) {
294
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching front page.', 2 );
295
- return $buffer;
296
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && isset( $wp_super_cache_query[ 'is_home' ] ) ) {
297
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching home page.', 2 );
298
- return $buffer;
299
  } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && isset( $wp_super_cache_query[ 'is_search' ] ) ) {
300
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching search page.', 2 );
301
- return $buffer;
302
  } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && isset( $wp_super_cache_query[ 'is_author' ] ) ) {
303
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching author page.', 2 );
304
- return $buffer;
305
  } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
306
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching feed.', 2 );
307
- return $buffer;
308
  }
309
 
310
  if ( !isset( $wp_query ) )
311
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
312
 
313
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
314
 
315
- $buffer = wp_cache_get_ob( $buffer );
316
- wp_cache_shutdown_callback();
317
- return $buffer;
 
 
 
 
 
318
  }
319
 
320
  function wp_cache_append_tag( &$buffer ) {
@@ -347,6 +344,21 @@ function wp_cache_add_to_buffer( &$buffer, $text ) {
347
  $buffer .= "\n<!-- $text -->";
348
  }
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  function wp_cache_get_ob(&$buffer) {
351
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
352
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
@@ -393,7 +405,7 @@ function wp_cache_get_ob(&$buffer) {
393
  }
394
 
395
  if( !$new_cache )
396
- return $buffer;
397
 
398
  $duration = wp_cache_microtime_diff($wp_start_time, microtime());
399
  $duration = sprintf("%0.3f", $duration);
@@ -402,7 +414,7 @@ function wp_cache_get_ob(&$buffer) {
402
  if( !wp_cache_writers_entry() ) {
403
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
404
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Could not get mutex lock. Not caching.", 1 );
405
- return $buffer;
406
  }
407
 
408
  if ( $wp_cache_not_logged_in && is_feed() ) {
@@ -455,11 +467,9 @@ function wp_cache_get_ob(&$buffer) {
455
  global $wp_super_cache_late_init;
456
  if ( false == isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init == 0 ) )
457
  wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details.' );
458
- if ( do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 )
459
- return do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
460
  }
461
 
462
- return $buffer;
463
  }
464
 
465
  if( @is_dir( $dir ) == false )
@@ -474,7 +484,7 @@ function wp_cache_get_ob(&$buffer) {
474
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
475
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
476
  wp_cache_writers_exit();
477
- return $buffer;
478
  }
479
  } else {
480
  $user_info = wp_cache_get_cookies_values();
@@ -490,7 +500,7 @@ function wp_cache_get_ob(&$buffer) {
490
  @fclose( $fr );
491
  @unlink( $tmp_wpcache_filename );
492
  wp_cache_writers_exit();
493
- return $buffer;
494
  } elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
495
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
496
  if (!$gz) {
@@ -501,7 +511,7 @@ function wp_cache_get_ob(&$buffer) {
501
  @fclose( $fr2 );
502
  @unlink( $tmp_cache_filename );
503
  wp_cache_writers_exit();
504
- return $buffer;
505
  }
506
  }
507
  }
@@ -1021,7 +1031,7 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
1021
 
1022
  /* check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change() */
1023
  function wp_cache_post_edit($post_id) {
1024
- global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
1025
  static $last_post_edited = -1;
1026
 
1027
  if ( $post_id == $last_post_edited ) {
@@ -1097,7 +1107,7 @@ function wp_cache_post_change( $post_id ) {
1097
  $post = get_post( $post_id );
1098
  // Some users are inexplicibly seeing this error on scheduled posts.
1099
  // define this constant to disable the post status check.
1100
- if ( false == defined( 'WPSCFORCEUPDATE' ) && $post->post_status != 'publish' ) {
1101
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
1102
  return $post_id;
1103
  }
46
  do_cacheaction( 'add_cacheaction' );
47
  }
48
 
 
 
 
 
 
49
  if ( is_admin() ) {
50
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
51
  return false;
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  if ( !empty( $_GET ) ) {
55
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . print_r( $_GET, 1 ), 5 );
56
  $super_cache_enabled = false;
57
  }
58
 
 
 
 
 
 
 
 
 
 
59
  if($wp_cache_gzip_encoding)
60
  header('Vary: Accept-Encoding, Cookie');
61
  else
239
  }
240
 
241
  function wp_cache_ob_callback( $buffer ) {
242
+ global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files;
243
  $buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
 
 
 
 
244
 
245
+ $script = basename($_SERVER['PHP_SELF']);
246
+
247
+ // All the things that can stop a page being cached
248
+ $cache_this_page = true;
249
+ if ( defined( 'DONOTCACHEPAGE' ) ) {
250
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
251
+ $cache_this_page = false;
252
+ } elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
253
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
254
+ $cache_this_page = false;
255
+ } elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
256
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching POST request.', 5 );
257
+ $cache_this_page = false;
258
+ } elseif ( $wp_cache_object_cache && !empty( $_GET ) ) {
259
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
260
+ $cache_this_page = false;
261
+ } elseif ( isset( $_GET[ 'preview' ] ) ) {
262
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching preview post.', 2 );
263
+ $cache_this_page = false;
264
+ } elseif ( !in_array($script, $cache_acceptable_files) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
265
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
266
+ $cache_this_page = false;
267
+ } elseif ( wp_cache_user_agent_is_rejected() ) {
268
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
269
+ $cache_this_page = false;
270
+ } elseif ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && isset( $wp_super_cache_query[ 'is_single' ] ) ) {
271
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single post.', 2 );
272
+ $cache_this_page = false;
273
  } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && isset( $wp_super_cache_query[ 'is_page' ] ) ) {
274
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single page.', 2 );
275
+ $cache_this_page = false;
276
  } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && isset( $wp_super_cache_query[ 'is_archive' ] ) ) {
277
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching archive page.', 2 );
278
+ $cache_this_page = false;
279
  } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && isset( $wp_super_cache_query[ 'is_tag' ] ) ) {
280
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching tag page.', 2 );
281
+ $cache_this_page = false;
282
  } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && isset( $wp_super_cache_query[ 'is_category' ] ) ) {
283
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching category page.', 2 );
284
+ $cache_this_page = false;
285
  } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && isset( $wp_super_cache_query[ 'is_front_page' ] ) ) {
286
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching front page.', 2 );
287
+ $cache_this_page = false;
288
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && isset( $wp_super_cache_query[ 'is_home' ] ) ) {
289
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching home page.', 2 );
290
+ $cache_this_page = false;
291
  } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && isset( $wp_super_cache_query[ 'is_search' ] ) ) {
292
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching search page.', 2 );
293
+ $cache_this_page = false;
294
  } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && isset( $wp_super_cache_query[ 'is_author' ] ) ) {
295
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching author page.', 2 );
296
+ $cache_this_page = false;
297
  } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
298
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching feed.', 2 );
299
+ $cache_this_page = false;
300
  }
301
 
302
  if ( !isset( $wp_query ) )
303
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
304
 
305
+ if ( $cache_this_page ) {
306
 
307
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
308
+
309
+ $buffer = wp_cache_get_ob( $buffer );
310
+ wp_cache_shutdown_callback();
311
+ return $buffer;
312
+ } else {
313
+ return wp_cache_maybe_dynamic( $buffer );
314
+ }
315
  }
316
 
317
  function wp_cache_append_tag( &$buffer ) {
344
  $buffer .= "\n<!-- $text -->";
345
  }
346
 
347
+ /*
348
+ * If dynamic caching is enabled then run buffer through wpsc_cachedata filter before returning it.
349
+ * or we'll return template tags to visitors.
350
+ */
351
+ function wp_cache_maybe_dynamic( &$buffer ) {
352
+ global $wp_cache_mfunc_enabled;
353
+ if ( $wp_cache_mfunc_enabled == 1 && do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 ) {
354
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_maybe_dynamic: filtered $buffer through wpsc_cachedata', 4 );
355
+ return do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
356
+ } else {
357
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_maybe_dynamic: returned $buffer', 4 );
358
+ return $buffer;
359
+ }
360
+ }
361
+
362
  function wp_cache_get_ob(&$buffer) {
363
  global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
364
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
405
  }
406
 
407
  if( !$new_cache )
408
+ return wp_cache_maybe_dynamic( $buffer );
409
 
410
  $duration = wp_cache_microtime_diff($wp_start_time, microtime());
411
  $duration = sprintf("%0.3f", $duration);
414
  if( !wp_cache_writers_entry() ) {
415
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
416
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Could not get mutex lock. Not caching.", 1 );
417
+ return wp_cache_maybe_dynamic( $buffer );
418
  }
419
 
420
  if ( $wp_cache_not_logged_in && is_feed() ) {
467
  global $wp_super_cache_late_init;
468
  if ( false == isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init == 0 ) )
469
  wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details.' );
 
 
470
  }
471
 
472
+ return wp_cache_maybe_dynamic( $buffer );
473
  }
474
 
475
  if( @is_dir( $dir ) == false )
484
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
485
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
486
  wp_cache_writers_exit();
487
+ return wp_cache_maybe_dynamic( $buffer );
488
  }
489
  } else {
490
  $user_info = wp_cache_get_cookies_values();
500
  @fclose( $fr );
501
  @unlink( $tmp_wpcache_filename );
502
  wp_cache_writers_exit();
503
+ return wp_cache_maybe_dynamic( $buffer );
504
  } elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
505
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
506
  if (!$gz) {
511
  @fclose( $fr2 );
512
  @unlink( $tmp_cache_filename );
513
  wp_cache_writers_exit();
514
+ return wp_cache_maybe_dynamic( $buffer );
515
  }
516
  }
517
  }
1031
 
1032
  /* check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change() */
1033
  function wp_cache_post_edit($post_id) {
1034
+ global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir, $wp_cache_object_cache;
1035
  static $last_post_edited = -1;
1036
 
1037
  if ( $post_id == $last_post_edited ) {
1107
  $post = get_post( $post_id );
1108
  // Some users are inexplicibly seeing this error on scheduled posts.
1109
  // define this constant to disable the post status check.
1110
+ if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && $post->post_status != 'publish' ) {
1111
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
1112
  return $post_id;
1113
  }
wp-cache.php CHANGED
@@ -1,15 +1,17 @@
1
  <?php
2
  /*
3
  Plugin Name: WP Super Cache
4
- Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
- Version: 1.4
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
- Copyright 2007-2013 Donncha Ó Caoimh (http://ocaoimh.ie/) and many others.
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
@@ -76,14 +78,14 @@ function wp_cache_set_home() {
76
  add_action( 'template_redirect', 'wp_cache_set_home' );
77
 
78
 
79
- // OSSDL CDN plugin (http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/)
80
  include_once( WPCACHEHOME . 'ossdl-cdn.php' );
81
 
82
  // from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
83
  function is_writeable_ACLSafe($path) {
84
 
85
  // PHP's is_writable does not work with Win32 NTFS
86
-
87
  if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
88
  return is_writeable_ACLSafe($path.uniqid(mt_rand()).'.tmp');
89
  else if (is_dir($path))
@@ -170,12 +172,12 @@ function wp_cache_manager_error_checks() {
170
 
171
  if ( !wpsupercache_site_admin() )
172
  return false;
173
-
174
  if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) ) {
175
  echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h3><p>' .
176
  __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . ' ';
177
-
178
-
179
  if( !ini_get( 'safe_mode_gid' ) ) {
180
  _e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . " ";
181
  printf( __( '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 %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), WP_CONTENT_DIR );
@@ -201,7 +203,7 @@ function wp_cache_manager_error_checks() {
201
  if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
202
  ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3>
203
  <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p>
204
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
205
  </div>
206
  <?php
207
  return false;
@@ -215,7 +217,7 @@ function wp_cache_manager_error_checks() {
215
  if( $cron[ 'response' ][ 'code' ] == '404' ) {
216
  ?><div id="message" class="updated fade"><h3>Warning! wp-cron.php not found!</h3>
217
  <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p>
218
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
219
  </div>
220
  <?php
221
  } else {
@@ -236,7 +238,7 @@ function wp_cache_manager_error_checks() {
236
  return false;
237
  }
238
 
239
- if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
240
  ?><div id="message" class="updated fade"><h3><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h3>
241
  <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p></div><?php
242
  }
@@ -278,7 +280,7 @@ function wp_cache_manager_error_checks() {
278
  <input type="hidden" name="action" value="dismiss_gc_warning" />
279
  <input type="hidden" name="page" value="wpsupercache" />
280
  <?php wp_nonce_field( 'wp-cache' ); ?>
281
- <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
282
  </form>
283
  <br />
284
  </div>
@@ -306,7 +308,7 @@ function wp_cache_manager_error_checks() {
306
  <input type="hidden" name="action" value="dismiss_readable_warning" />
307
  <input type="hidden" name="page" value="wpsupercache" />
308
  <?php wp_nonce_field( 'wp-cache' ); ?>
309
- <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
310
  </form>
311
  <br />
312
  </div>
@@ -320,7 +322,7 @@ function wp_cache_manager_error_checks() {
320
  if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
321
  echo '<div id="message" class="updated fade"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>";
322
  echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "2.0\ MMP|240x320" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></div>";
323
- } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && (
324
  ( false == empty( $wp_cache_mobile_prefixes ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) ) ) ||
325
  ( false == empty( $wp_cache_mobile_browsers ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) )
326
  ) {
@@ -332,7 +334,7 @@ function wp_cache_manager_error_checks() {
332
  <li> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></li>
333
  <li> <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li>
334
  <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%%{HTTP:Cookie} !^.*(comment_author_|%s|wp-postpass_).*$</code> add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path, wpsc_get_logged_in_cookie() ); ?></p>
335
- <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre><?php echo "RewriteCond %{HTTP_user_agent} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").*\nRewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").*"; ?></pre></div></li></ol></div><?php
336
  }
337
 
338
  if ( $cache_enabled && $super_cache_enabled && $wp_cache_mod_rewrite && $scrules == '' ) {
@@ -368,6 +370,8 @@ function wp_cache_manager_error_checks() {
368
  } elseif ( !isset( $dismiss_htaccess_warning ) ) {
369
  $dismiss_htaccess_warning = 0;
370
  }
 
 
371
  if ( $dismiss_htaccess_warning == 0 && $wp_cache_mod_rewrite && $super_cache_enabled && $disable_supercache_htaccess_warning == false && get_option( 'siteurl' ) != get_option( 'home' ) ) {
372
  $home_dir = str_replace( get_option( 'home' ), '', get_option( 'siteurl' ) );
373
  ?><div id="message" class="updated fade"><h3><?php _e( '.htaccess file may need to be moved', 'wp-super-cache' ); ?></h3>
@@ -376,9 +380,9 @@ function wp_cache_manager_error_checks() {
376
  <input type="hidden" name="action" value="dismiss_htaccess_warning" />
377
  <input type="hidden" name="page" value="wpsupercache" />
378
  <?php wp_nonce_field( 'wp-cache' ); ?>
379
- <input type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
380
  </form>
381
- <br />
382
  </div><?php
383
  }
384
 
@@ -392,10 +396,10 @@ function admin_bar_delete_page() {
392
  if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') )
393
  return false;
394
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) {
395
- $path = get_supercache_dir() . preg_replace( '/:.*$/', '', $_GET[ 'path' ] );
396
  $files = get_all_supercache_filenames( $path );
397
  foreach( $files as $cache_file )
398
- prune_super_cache( $path . $cache_file, true );
399
 
400
  wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) );
401
  die();
@@ -593,7 +597,7 @@ function wp_cache_manager_updates() {
593
  $wp_cache_refresh_single_only = 0;
594
  }
595
  wp_cache_replace_line('^ *\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file);
596
-
597
  if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
598
  $cache_compression = 0;
599
  wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
@@ -603,7 +607,7 @@ function wp_cache_manager_updates() {
603
  } else {
604
  $new_cache_compression = 0;
605
  }
606
- if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
607
  echo '<div id="message" class="updated fade">' . __( "<strong>Warning!</strong> You attempted to enable compression but <code>zlib.output_compression</code> is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ) . '</div>';
608
  } else {
609
  if ( $new_cache_compression != $cache_compression ) {
@@ -648,7 +652,7 @@ function wp_cache_manager() {
648
  $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list
649
  if ( function_exists( 'do_cacheaction' ) ) {
650
  $wp_cache_mobile_browsers = do_cacheaction( 'wp_super_cache_mobile_browsers', $wp_cache_mobile_browsers );
651
- $wp_cache_mobile_prefixes = do_cacheaction( 'wp_super_cache_mobile_prefixes', $wp_cache_mobile_prefixes );
652
  }
653
  $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default
654
  // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) );
@@ -736,10 +740,10 @@ jQuery(document).ready(function(){
736
  $home_path = parse_url( site_url() );
737
  $home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path[ 'path' ] : '' );
738
  if (! isset( $wp_cache_home_path ) )
739
- $wp_cache_home_path = '/';
740
  if ( "$home_path" != "$wp_cache_home_path" )
741
  wp_cache_replace_line('^ *\$wp_cache_home_path', "\$wp_cache_home_path = '$home_path';", $wp_cache_config_file);
742
-
743
 
744
  if( $wp_cache_mobile_enabled == 1 ) {
745
  update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
@@ -795,7 +799,7 @@ jQuery(document).ready(function(){
795
  wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' );
796
  if ( $wp_cache_preload_interval == 0 ) {
797
  echo "<p><strong>" . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "</strong></p>";
798
- }
799
  }
800
  if ( $_POST[ 'custom_preload_interval' ] != 0 )
801
  wp_schedule_single_event( time() + ( $_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' );
@@ -913,9 +917,9 @@ jQuery(document).ready(function(){
913
  echo "<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
914
  }
915
  }
916
- echo '<div class="submit"><input type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" />&nbsp;<input type="submit" name="preload" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />';
917
  if ( $currently_preloading ) {
918
- echo '&nbsp;<input type="submit" name="preload" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
919
  }
920
  echo '</div>';
921
  wp_nonce_field('wp-cache');
@@ -933,7 +937,7 @@ jQuery(document).ready(function(){
933
  case 'settings':
934
  if ( isset( $wp_cache_front_page_checks ) == false )
935
  $wp_cache_front_page_checks = true;
936
- echo '<form name="wp_manager" action="' . add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'settings' ) ) . '" method="post">';
937
  wp_nonce_field('wp-cache');
938
  echo '<input type="hidden" name="action" value="scupdates" />';
939
  ?><table class="form-table">
@@ -943,8 +947,8 @@ jQuery(document).ready(function(){
943
  <fieldset>
944
  <legend class="hidden">Caching</legend>
945
  <label><input type='checkbox' name='wp_cache_status' value='all' <?php if ( $cache_enabled == true ) { echo 'checked=checked'; } ?>> <?php _e( 'Cache hits to this website for quick access.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /><br />
946
- <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled ) echo "checked"; ?> value='1'> <?php printf( __( 'Use mod_rewrite to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wordpress-mobile-edition/' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
947
- <label><input type='radio' name='super_cache_enabled' <?php if( $wp_cache_mod_rewrite == 0 ) echo "checked"; ?> value='2'> <?php printf( __( 'Use PHP to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wordpress-mobile-edition/' ); ?></label><br />
948
  <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled == false ) echo "checked"; ?> value='0'> <?php _e( 'Legacy page caching.', 'wp-super-cache' ); ?></label><br />
949
  <em><?php _e( 'Mod_rewrite is fastest, PHP is almost as fast and easier to get working, while legacy caching is slower again, but more flexible and also easy to get working. New users should use PHP caching.', 'wp-super-cache' ); ?></em><br />
950
  </legend>
@@ -990,8 +994,8 @@ jQuery(document).ready(function(){
990
  <td>
991
  <fieldset>
992
  <legend class="hidden">Advanced</legend>
993
- <label><input type='checkbox' name='wp_cache_mfunc_enabled' <?php if( $wp_cache_mfunc_enabled ) echo "checked"; ?> value='1' <?php if ( $wp_cache_mod_rewrite ) { echo "disabled='disabled'"; } ?>> <?php _e( 'Enable dynamic caching. Requires PHP or legacy caching. (See <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">FAQ</a> or wp-super-cache/plugins/dynamic-cache-test.php for example code.)', 'wp-super-cache' ); ?></label><br />
994
- <label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php _e( 'Mobile device support. (External plugin or theme required. See the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">FAQ</a> for further details.)', 'wp-super-cache' ); ?></label><br />
995
  <?php if ( $wp_cache_mobile_enabled ) {
996
  echo '<blockquote><h4>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h4>' . implode( ', ', $wp_cache_mobile_browsers ) . "<br /><h4>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h4>" . implode( ', ', $wp_cache_mobile_prefixes ) . "<br /></blockquote>";
997
  } ?>
@@ -1004,8 +1008,8 @@ jQuery(document).ready(function(){
1004
  <label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You probably don&#8217;t need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em>', 'wp-super-cache' ); ?></label><br />
1005
  <?php } ?>
1006
  <label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded. Most useful in legacy mode.', 'wp-super-cache' ); ?></label><br />
1007
- <?php if ( $_wp_using_ext_object_cache ) {
1008
- ?><label><input type='checkbox' name='wp_cache_object_cache' <?php if( $wp_cache_object_cache ) echo "checked"; ?> value='1'> <?php echo __( 'Use object cache to store cached files.', 'wp-super-cache' ) . ' ' . __( '(Experimental)', 'wp-super-cache' ); ?></label><?php
1009
  }?>
1010
  <?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
1011
  </legend>
@@ -1018,10 +1022,10 @@ jQuery(document).ready(function(){
1018
  <li><?php _e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required then simple instructions are provided.', 'wp-super-cache' ); ?></li>
1019
  <li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</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!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></li>
1020
  <li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), WP_PLUGIN_URL ); ?></li><?php
1021
- echo "<li><em>" . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/', 'http://wordpress.org/tags/wp-super-cache?forum_id=10' ) . "</em></li>";
1022
  echo "</ol>";
1023
-
1024
- echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " &raquo;' /></div>";
1025
  wp_nonce_field('wp-cache');
1026
  ?> </form> <?php
1027
  wsc_mod_rewrite();
@@ -1068,7 +1072,7 @@ jQuery(document).ready(function(){
1068
  echo "<p><strong>" . __( 'Notice: PHP caching enabled but Supercache mod_rewrite rules detected. Cached files will be served using those rules. If your site is working ok please ignore this message or you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
1069
  }
1070
  }
1071
- echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " &raquo;' /></div></form>";
1072
  if ( $cache_enabled ) {
1073
  echo "<h3>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h3>";
1074
  echo '<p>' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
@@ -1149,7 +1153,7 @@ jQuery(document).ready(function(){
1149
  echo '<input type="hidden" name="action" value="test" />';
1150
  if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) )
1151
  echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
1152
- echo '<div class="submit"><input type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1153
  wp_nonce_field('wp-cache');
1154
  echo '</form>';
1155
  }
@@ -1157,29 +1161,27 @@ jQuery(document).ready(function(){
1157
  echo "<p>" . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them use the button below.", 'wp-super-cache' ) . "</p>";
1158
  echo '<form name="wp_cache_content_delete" action="?page=wpsupercache&tab=contents" method="post">';
1159
  echo '<input type="hidden" name="wp_delete_cache" />';
1160
- echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . ' &raquo;" /></div>';
1161
  wp_nonce_field('wp-cache');
1162
  echo "</form>\n";
1163
 
1164
  if ( ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
1165
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
1166
  echo '<input type="hidden" name="wp_delete_all_cache" />';
1167
- echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . ' &raquo;" />';
1168
  wp_nonce_field('wp-cache');
1169
  echo "</form><br />\n";
1170
  }
1171
  ?>
1172
- <h3><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h3>
1173
  <p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
1174
- <ol><li><?php printf( __( '<a href="%s">WPSCMin</a>, a Supercache plugin that minifies cached pages by removing whitespaces and extra characters ', 'wp-super-cache' ), 'http://lyncd.com/wpscmin/' ); ?></li>
1175
  <li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> is an extension for the Firefox add-on Firebug. It analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://developer.yahoo.com/yslow/', 'http://gtmetrix.com/' ); ?></li>
1176
- <li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically it may reduce your Yslow score.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/use-google-libraries/' ); ?></li>
1177
- <li><?php printf( __( 'The <a href="%1$s">CDN Sync Tool</a> plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the <a href="%2$s">plugin support forum</a> if you have any queries about this plugin.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10' ); ?></li>
1178
  <li><?php printf( __( '<strong>Advanced users only:</strong> <a href="%s">Speed up your site with Caching and cache-control</a> explains how to make your site more cacheable with .htaccess rules.', 'wp-super-cache' ), 'http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html' ); ?></li>
1179
- <li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/memcached/', 'http://neosmart.net/dl.php?id=12', 'http://neosmart.net/dl.php?id=13' ); ?></li>
1180
- <li><?php printf( __( '<a href="%s">Cron View</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cron-view/' ); ?></li>
1181
  </ol>
1182
-
1183
  <?php
1184
  break;
1185
  }
@@ -1188,23 +1190,19 @@ jQuery(document).ready(function(){
1188
  </fieldset>
1189
  </td><td valign='top' style='width: 300px'>
1190
  <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
1191
- <h3 align='center'><?php _e( 'Make WordPress Faster', 'wp-super-cache' ); ?></h3>
1192
- <p><?php printf( __( '%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/y/34">WP Super Cache</a>', '<a href="http://ocaoimh.ie/y/35">Donncha O Caoimh</a>' ); ?></p>
1193
- <p><?php printf( __( 'He blogs at %1$s and posts photos at %2$s.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/y/35">Holy Shmoly</a>', '<a href="http://ocaoimh.ie/y/2m">In Photos.org</a>' ); ?></p>
1194
- <p><?php printf( __( 'Please say hi to him on %s too!', 'wp-super-cache' ), '<a href="http://twitter.com/donncha/">Twitter</a>' ); ?></p>
1195
  <h3 align='center'><?php _e( 'Need Help?', 'wp-super-cache' ); ?></h3>
1196
  <ol>
1197
  <li><?php _e( 'Use the debug system in the Debug tab above. It will tell you what the plugin is doing.', 'wp-super-cache' ); ?></li>
1198
- <li><?php printf( __( '<a href="%1$s">Installation Help</a>', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/installation/' ); ?></li>
1199
- <li><?php printf( __( '<a href="%1$s">Frequently Asked Questions</a>', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></li>
1200
  <li><?php printf( __( '<a href="%1$s">Support Forum</a>', 'wp-super-cache' ), 'http://wordpress.org/tags/wp-super-cache' ); ?></li>
1201
  <li><?php printf( __( '<a href="%1$s">Development Version</a>', 'wp-super-cache' ), 'http://ocaoimh.ie/y/2o' ); ?></li>
1202
  </ol>
1203
  <h3 align='center'><?php _e( 'Rate This Plugin!', 'wp-super-cache' ); ?></h3>
1204
- <p><?php printf( __( 'Please <a href="%s">rate</a> this plugin and tell me if it works for you or not. It really helps development.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/' ); ?></p>
1205
 
1206
- <?php
1207
- if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
1208
  $start_date = get_option( 'wpsupercache_start' );
1209
  if ( !$start_date ) {
1210
  $start_date = time();
@@ -1219,7 +1217,7 @@ jQuery(document).ready(function(){
1219
  }
1220
  ?></ol>
1221
  <small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
1222
- </p><?php
1223
  } elseif ( false == get_option( 'wpsupercache_start' ) ) {
1224
  update_option( 'wpsupercache_start', time() );
1225
  update_option( 'wpsupercache_count', 0 );
@@ -1309,7 +1307,7 @@ function wsc_mod_rewrite() {
1309
  if ( function_exists( "is_main_site" ) && false == is_main_site() )
1310
  return true;
1311
  ?>
1312
- <a name="modrewrite"></a><fieldset class="options">
1313
  <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3><?php
1314
 
1315
  extract( wpsc_get_htaccess_info() );
@@ -1336,13 +1334,13 @@ function wsc_mod_rewrite() {
1336
  } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
1337
  $dohtaccess = false;
1338
  }
1339
- if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
1340
  if ( $scrules == '' ) {
1341
  wpsc_update_htaccess_form( 0 ); // don't hide the update htaccess form
1342
  } else {
1343
  wpsc_update_htaccess_form();
1344
  }
1345
- } elseif( $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
1346
  echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
1347
  if( wpsc_update_htaccess() ) {
1348
  echo "<h4>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h4>";
@@ -1364,7 +1362,7 @@ function wsc_mod_rewrite() {
1364
  echo "<div id='rewriterules' style='display: none;'>";
1365
  if ( $rules != $scrules )
1366
  echo '<div style="background: #fff; border: 1px solid #333; margin: 2px;">' . wp_text_diff( $scrules, $rules, array( 'title' => 'Rewrite Rules', 'title_left' => 'Current Rules', 'title_right' => 'New Rules' ) ) . "</div>";
1367
- echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>\n";
1368
  echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>";
1369
  echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>";
1370
  echo '</div>';
@@ -1382,7 +1380,7 @@ function wp_cache_restore() {
1382
  echo '<fieldset class="options"><h3>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h3>';
1383
  echo '<form name="wp_restore" action="#top" method="post">';
1384
  echo '<input type="hidden" name="wp_restore_config" />';
1385
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . ' &raquo;" /></div>';
1386
  wp_nonce_field('wp-cache');
1387
  echo "</form>\n";
1388
  echo '</fieldset>';
@@ -1414,11 +1412,11 @@ function wp_lock_down() {
1414
  }
1415
  }
1416
  ?><a name='lockdown'></a>
1417
- <fieldset class="options">
1418
  <h3><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h3>
1419
  <p><?php _e( '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.', 'wp-super-cache' ); ?></p>
1420
  <p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?>
1421
- <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
1422
  &nbsp;&nbsp;&nbsp;&nbsp;echo "<?php _e( 'Sorry. My blog is locked down. Updates will appear shortly', 'wp-super-cache' ); ?>";
1423
  }</code></blockquote>
1424
  <?php
@@ -1431,14 +1429,14 @@ function wp_lock_down() {
1431
  $new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
1432
  echo '<form name="wp_lock_down" action="#lockdown" method="post">';
1433
  echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
1434
- echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} " . __( 'Lock Down', 'wp-super-cache' ) . " &raquo;' /></div>";
1435
  wp_nonce_field('wp-cache');
1436
  echo "</form>\n";
1437
 
1438
  ?></fieldset><?php
1439
  if( $cache_enabled == true && $super_cache_enabled == true ) {
1440
  ?><a name='direct'></a>
1441
- <fieldset class="options">
1442
  <h3><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h3><?php
1443
 
1444
  $out = '';
@@ -1521,7 +1519,7 @@ function wp_lock_down() {
1521
  continue;
1522
  $generated = '';
1523
  if( is_file( ABSPATH . $page . '/index.html' ) )
1524
- $generated = '<input type="Submit" name="deletepage" value="' . $page . '">';
1525
  $out .= "<tr><td><input type='text' $readonly name='direct_pages[]' size='30' value='$page' /></td><td>$generated</td></tr>";
1526
  }
1527
  if( $out != '' ) {
@@ -1540,7 +1538,7 @@ function wp_lock_down() {
1540
 
1541
  wp_nonce_field('wp-cache');
1542
  if( $readonly != 'READONLY' )
1543
- echo "<div class='submit'><input type='submit' ' . SUBMITDISABLED . 'value='" . __( 'Update Direct Pages', 'wp-super-cache' ) . " &raquo;' /></div>";
1544
  echo "</form>\n";
1545
  ?></fieldset><?php
1546
  } // if $super_cache_enabled
@@ -1553,7 +1551,7 @@ function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manu
1553
  $dh = @opendir($folderPath);
1554
  while (false !== ($value = @readdir($dh))) {
1555
  if ( $value != "." && $value != ".." ) {
1556
- $value = $folderPath . "/" . $value;
1557
  if ( @is_dir ( $value ) ) {
1558
  RecursiveFolderDelete ( $value );
1559
  }
@@ -1600,10 +1598,10 @@ function wp_cache_edit_max_time () {
1600
 
1601
  if ( isset( $_POST[ 'cache_gc_email_me' ] ) && $valid_nonce ) {
1602
  $cache_gc_email_me = 1;
1603
- wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file);
1604
  } elseif ( $valid_nonce ) {
1605
  $cache_gc_email_me = 0;
1606
- wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file);
1607
  }
1608
  if ( isset( $_POST[ 'cache_schedule_type' ] ) && $_POST[ 'cache_schedule_type' ] == 'interval' && isset( $_POST['cache_time_interval'] ) && $valid_nonce ) {
1609
  wp_clear_scheduled_hook( 'wp_cache_gc' );
@@ -1617,10 +1615,12 @@ function wp_cache_edit_max_time () {
1617
  } elseif ( $valid_nonce ) { // clock
1618
  wp_clear_scheduled_hook( 'wp_cache_gc' );
1619
  $cache_schedule_type = 'time';
1620
- if ( $_POST[ 'cache_scheduled_time' ] == '' )
1621
  $_POST[ 'cache_scheduled_time' ] = '00:00';
1622
  $cache_scheduled_time = $_POST[ 'cache_scheduled_time' ];
1623
  $schedules = wp_get_schedules();
 
 
1624
  if ( isset( $schedules[ $_POST[ 'cache_schedule_interval' ] ] ) )
1625
  $cache_schedule_interval = $_POST[ 'cache_schedule_interval' ];
1626
  wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file);
@@ -1628,7 +1628,7 @@ function wp_cache_edit_max_time () {
1628
  wp_cache_replace_line('^ *\$cache_scheduled_time', "\$cache_scheduled_time = '$cache_scheduled_time';", $wp_cache_config_file);
1629
  wp_schedule_event( strtotime( $cache_scheduled_time ), $cache_schedule_interval, 'wp_cache_gc' );
1630
  }
1631
- ?><fieldset class="options">
1632
  <a name='expirytime'></a>
1633
  <h3><?php _e( 'Expiry Time &amp; Garbage Collection', 'wp-super-cache' ); ?></h3><?php
1634
 
@@ -1694,7 +1694,7 @@ function wp_cache_edit_max_time () {
1694
  echo "</ol>";
1695
  echo "<p>" . __( 'Checking for and deleting expired files is expensive, but it&#8217;s expensive leaving them there too. On a very busy site you should set the expiry time to <em>600 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. If you are using legacy caching aim to have less than 500 cached files if possible. You can have many times more cached files when using mod_rewrite or PHP caching.', 'wp-super-cache' ) . "</p>";
1696
  echo "<p>" . __( 'Set the expiry time to 0 seconds to disable garbage collection.', 'wp-super-cache' ) . "</p>";
1697
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Change Expiration', 'wp-super-cache' ) . ' &raquo;" /></div>';
1698
  wp_nonce_field('wp-cache');
1699
  echo "</form>\n";
1700
  ?></fieldset><?php
@@ -1746,7 +1746,7 @@ function wp_cache_edit_rejected_ua() {
1746
  echo esc_html( $ua ) . "\n";
1747
  }
1748
  echo '</textarea> ';
1749
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save UA Strings', 'wp-super-cache' ) . ' &raquo;" /></div>';
1750
  wp_nonce_field('wp-cache');
1751
  echo '</form>';
1752
  echo "</fieldset>\n";
@@ -1783,7 +1783,7 @@ function wp_cache_edit_rejected_pages() {
1783
  echo '<label><input type="checkbox" value="1" name="wp_cache_pages[search]" ' . checked( 1, $wp_cache_pages[ 'search' ], false ) . ' /> ' . __( 'Search Pages', 'wp-super-cache' ) . ' (is_search)</label><br />';
1784
  echo '<label><input type="checkbox" value="1" name="wp_cache_pages[author]" ' . checked( 1, $wp_cache_pages[ 'author' ], false ) . ' /> ' . __( 'Author Pages', 'wp-super-cache' ) . ' (is_author)</label><br />';
1785
 
1786
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save' ) . ' &raquo;" /></div>';
1787
  wp_nonce_field('wp-cache');
1788
  echo "</form>\n";
1789
 
@@ -1806,7 +1806,7 @@ function wp_cache_edit_rejected() {
1806
  echo esc_html( $file ) . "\n";
1807
  }
1808
  echo '</textarea> ';
1809
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Strings', 'wp-super-cache' ) . ' &raquo;" /></div>';
1810
  wp_nonce_field('wp-cache');
1811
  echo "</form>\n";
1812
  }
@@ -1828,7 +1828,7 @@ function wp_cache_edit_accepted() {
1828
  echo esc_html($file) . "\n";
1829
  }
1830
  echo '</textarea> ';
1831
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Files', 'wp-super-cache' ) . ' &raquo;" /></div>';
1832
  wp_nonce_field('wp-cache');
1833
  echo "</form>\n";
1834
  }
@@ -1840,6 +1840,8 @@ function wp_cache_debug_settings() {
1840
  if ( false == isset( $wp_super_cache_comments ) )
1841
  $wp_super_cache_comments = 1;
1842
  if ( isset( $_POST[ 'wp_cache_debug' ] ) && $valid_nonce ) {
 
 
1843
  $wp_super_cache_debug = intval( $_POST[ 'wp_super_cache_debug' ] );
1844
  wp_cache_replace_line('^ *\$wp_super_cache_debug', "\$wp_super_cache_debug = '$wp_super_cache_debug';", $wp_cache_config_file);
1845
  if ( $wp_super_cache_debug && ( ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log == '' ) || !isset( $wp_cache_debug_log ) ) ) {
@@ -1848,19 +1850,19 @@ function wp_cache_debug_settings() {
1848
  $wp_cache_debug_log = "";
1849
  }
1850
  wp_cache_replace_line('^ *\$wp_cache_debug_log', "\$wp_cache_debug_log = '$wp_cache_debug_log';", $wp_cache_config_file);
1851
- $wp_super_cache_comments = (int)$_POST[ 'wp_super_cache_comments' ];
1852
  wp_cache_replace_line('^ *\$wp_super_cache_comments', "\$wp_super_cache_comments = '$wp_super_cache_comments';", $wp_cache_config_file);
1853
  $wp_cache_debug_ip = esc_html( $_POST[ 'wp_cache_debug_ip' ] );
1854
  wp_cache_replace_line('^ *\$wp_cache_debug_ip', "\$wp_cache_debug_ip = '$wp_cache_debug_ip';", $wp_cache_config_file);
1855
- $wp_super_cache_front_page_check = (int)$_POST[ 'wp_super_cache_front_page_check' ];
1856
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_check', "\$wp_super_cache_front_page_check = '$wp_super_cache_front_page_check';", $wp_cache_config_file);
1857
- $wp_super_cache_front_page_clear = (int)$_POST[ 'wp_super_cache_front_page_clear' ];
1858
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_clear', "\$wp_super_cache_front_page_clear = '$wp_super_cache_front_page_clear';", $wp_cache_config_file);
1859
  $wp_super_cache_front_page_text = esc_html( $_POST[ 'wp_super_cache_front_page_text' ] );
1860
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_text', "\$wp_super_cache_front_page_text = '$wp_super_cache_front_page_text';", $wp_cache_config_file);
1861
- $wp_super_cache_front_page_notification = (int)$_POST[ 'wp_super_cache_front_page_notification' ];
1862
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_notification', "\$wp_super_cache_front_page_notification = '$wp_super_cache_front_page_notification';", $wp_cache_config_file);
1863
- if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
1864
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
1865
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
1866
  }
@@ -1892,10 +1894,10 @@ function wp_cache_debug_settings() {
1892
  echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
1893
  echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
1894
  echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
1895
-
1896
  echo "</table>\n";
1897
  }
1898
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . ' &raquo;" /></div>';
1899
  wp_nonce_field('wp-cache');
1900
  echo "</form>\n";
1901
  echo '</fieldset>';
@@ -2114,7 +2116,7 @@ function wp_cache_create_advanced_cache() {
2114
 
2115
  function wp_cache_check_link() {
2116
  global $wp_cache_link, $wp_cache_file;
2117
-
2118
  $ret = true;
2119
  if( file_exists($wp_cache_link) ) {
2120
  $file = file_get_contents( $wp_cache_link );
@@ -2167,7 +2169,7 @@ function wp_cache_check_global_config() {
2167
  }
2168
  return false;
2169
  } else {
2170
- echo "<div style='border: 1px solid #333; background: #ffffaa; padding: 2px;'>" . __( '<h3>WP_CACHE constant added to wp-config.php</h3><p>If you continue to see this warning message please see point 5 of the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>";
2171
  }
2172
  return true;
2173
  }
@@ -2210,7 +2212,7 @@ function wp_cache_files() {
2210
  $count = 0;
2211
  $expired = 0;
2212
  $now = time();
2213
- if ( ($handle = @opendir( $blog_cache_dir . 'meta/' )) ) {
2214
  $wp_cache_fsize = 0;
2215
  if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletewpcache' ) {
2216
  $deleteuri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) ) );
@@ -2232,11 +2234,11 @@ function wp_cache_files() {
2232
  if ( preg_match("/^$file_prefix.*\.meta/", $file) ) {
2233
  $content_file = preg_replace("/meta$/", "html", $file);
2234
  $mtime = filemtime( $blog_cache_dir . 'meta/' . $file );
2235
- if ( ! ( $fsize = @filesize( $blog_cache_dir . $content_file ) ) )
2236
  continue; // .meta does not exists
2237
 
2238
  $age = $now - $mtime;
2239
- if ( $valid_nonce && $_GET[ 'listfiles' ] ) {
2240
  $meta = unserialize( file_get_contents( $blog_cache_dir . 'meta/' . $file ) );
2241
  if ( $deleteuri != '' && $meta[ 'uri' ] == $deleteuri ) {
2242
  printf( __( "Deleting wp-cache file: <strong>%s</strong><br />", 'wp-super-cache' ), $deleteuri );
@@ -2299,7 +2301,7 @@ function wp_cache_files() {
2299
  if ( $valid_nonce && $_GET[ 'listfiles' ] && $filem )
2300
  $sizes[ 'cached_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem;
2301
  }
2302
- }
2303
  $sizes[ 'ts' ] = time();
2304
  $cache_stats = array( 'generated' => time(), 'supercache' => $sizes, 'wpcache' => array( 'cached' => $count, 'expired' => $expired, 'fsize' => $wp_cache_fsize ) );
2305
  update_option( 'supercache_stats', $cache_stats );
@@ -2337,7 +2339,7 @@ function wp_cache_files() {
2337
  echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'expired' ] / $divisor ) ) . "</li></ul>";
2338
  if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) {
2339
  echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>";
2340
- if ( is_array( $cached_list ) && !empty( $cached_list ) ) {
2341
  echo "<h4>" . __( 'Fresh WP-Cached Files', 'wp-super-cache' ) . "</h4>";
2342
  echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>";
2343
  $c = 1;
@@ -2353,7 +2355,7 @@ function wp_cache_files() {
2353
  }
2354
  echo "</table>";
2355
  }
2356
- if ( is_array( $expired_list ) && !empty( $expired_list ) ) {
2357
  echo "<h4>" . __( 'Stale WP-Cached Files', 'wp-super-cache' ) . "</h4>";
2358
  echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>";
2359
  $c = 1;
@@ -2420,19 +2422,19 @@ function wp_cache_delete_buttons() {
2420
 
2421
  echo '<form name="wp_cache_content_expired" action="#listfiles" method="post">';
2422
  echo '<input type="hidden" name="wp_delete_expired" />';
2423
- echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . ' &raquo;" /></div>';
2424
  wp_nonce_field('wp-cache');
2425
  echo "</form>\n";
2426
 
2427
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
2428
  echo '<input type="hidden" name="wp_delete_cache" />';
2429
- echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . ' &raquo;" /></div>';
2430
  wp_nonce_field('wp-cache');
2431
  echo "</form>\n";
2432
  if ( ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
2433
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
2434
  echo '<input type="hidden" name="wp_delete_all_cache" />';
2435
- echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . ' &raquo;" />';
2436
  wp_nonce_field('wp-cache');
2437
  echo "</form>\n";
2438
  }
@@ -2510,7 +2512,7 @@ function wp_cache_clean_cache( $file_prefix, $all = false ) {
2510
 
2511
  function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
2512
  global $wpdb;
2513
- if ( $handle = @opendir( $dir . 'meta/' ) ) {
2514
  while ( false !== ($file = readdir($handle))) {
2515
  if ( preg_match( "/^$file_prefix/", $file ) ) {
2516
  $meta = unserialize( file_get_contents( $dir . 'meta/' . $file ) );
@@ -2547,7 +2549,7 @@ function wp_cache_clean_expired($file_prefix) {
2547
 
2548
  $expr = "/^$file_prefix/";
2549
  $now = time();
2550
- if ( ($handle = @opendir( $blog_cache_dir )) ) {
2551
  while ( false !== ($file = readdir($handle))) {
2552
  if ( preg_match( $expr, $file ) &&
2553
  ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) {
@@ -2643,7 +2645,7 @@ function wp_cache_admin_notice() {
2643
  if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( "admin_url" ) )
2644
  echo '<div class="error"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
2645
 
2646
- if ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) {
2647
  echo '<div class="error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
2648
  wp_cache_create_advanced_cache();
2649
  }
@@ -2667,7 +2669,7 @@ function wp_cache_check_site() {
2667
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
2668
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) );
2669
  } else {
2670
- wp_cache_clear_cache();
2671
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( "The cache on your blog has been cleared because the front page of your site is now downloading. Please visit %s to verify the cache has been cleared.", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) );
2672
  }
2673
  }
@@ -2677,7 +2679,7 @@ function wp_cache_check_site() {
2677
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
2678
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( 'Please visit %1$s to clear the cache as the front page of your site is not correct and missing the text, "%2$s"!', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) );
2679
  } else {
2680
- wp_cache_clear_cache();
2681
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( 'The cache on your blog has been cleared because the front page of your site is missing the text "%2$s". Please visit %1$s to verify the cache has been cleared.', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) );
2682
  }
2683
  }
@@ -2707,7 +2709,7 @@ function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $
2707
  $wp_cache_mobile_groups = $mobile_groups;
2708
  wp_cache_replace_line('^ *\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode( ', ', $mobile_groups ) . "';", $wp_cache_config_file);
2709
  }
2710
-
2711
  return true;
2712
  }
2713
 
@@ -2740,20 +2742,20 @@ function wpsc_update_htaccess_form( $short_form = true ) {
2740
  if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
2741
  echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
2742
  echo '<input type="hidden" name="updatehtaccess" value="1" />';
2743
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . ' &raquo;" /></div>';
2744
  wp_nonce_field('wp-cache');
2745
  echo "</form></div>\n";
2746
  }
2747
  }
2748
  }
2749
 
2750
- /*
2751
  * Return LOGGED_IN_COOKIE if it doesn't begin with wordpress_logged_in
2752
  * to avoid having people update their .htaccess file
2753
  */
2754
  function wpsc_get_logged_in_cookie() {
2755
  $logged_in_cookie = 'wordpress_logged_in';
2756
- if ( defined( 'LOGGED_IN_COOKIE' ) && substr( constant( 'LOGGED_IN_COOKIE' ), 0, 19 ) != 'wordpress_logged_in' )
2757
  $logged_in_cookie = constant( 'LOGGED_IN_COOKIE' );
2758
  return $logged_in_cookie;
2759
  }
@@ -2805,9 +2807,9 @@ function wpsc_get_htaccess_info() {
2805
  $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
2806
  $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
2807
  if ( $wp_cache_mobile_enabled ) {
2808
- if ( false == empty( $wp_cache_mobile_browsers ) )
2809
  $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]";
2810
- if ( false == empty( $wp_cache_mobile_prefixes ) )
2811
  $condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]";
2812
  }
2813
  $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
@@ -2865,7 +2867,7 @@ function clear_post_supercache( $post_id ) {
2865
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "clear_post_supercache: deleting $dir/index*.html files", 2 );
2866
  $files_to_check = get_all_supercache_filenames( $dir );
2867
  foreach( $files_to_check as $cache_file ) {
2868
- prune_super_cache( $dir . $cache_file, true );
2869
  }
2870
  }
2871
 
@@ -3109,7 +3111,7 @@ function wp_cache_disable_plugin() {
3109
  $code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n";
3110
  }
3111
  $code .= "</ul>\n";
3112
-
3113
  $msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forgot to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is use <a href='http://www.google.ie/search?hl=en&q=ftp+chmod+777'>this Google search</a> to find out all about it.</p><p>Please refresh this page when the permissions have been modified.</p>";
3114
  wp_die( $msg );
3115
  }
@@ -3117,7 +3119,7 @@ function wp_cache_disable_plugin() {
3117
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
3118
  $wp_rewrite->flush_rules();
3119
  } elseif( $scrules != '' ) {
3120
- wp_mail( get_option( 'admin_email' ), __( 'Supercache Uninstall Problems', 'wp-super-cache' ), sprintf( __( "Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/extend/plugins/wp-super-cache/", 'wp-super-cache' ), ABSPATH . '/.htaccess' ) );
3121
  }
3122
  }
3123
 
@@ -3128,7 +3130,7 @@ function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual
3128
  $dh = @opendir($folderPath);
3129
  while( false !== ( $value = @readdir( $dh ) ) ) {
3130
  if ( $value != "." && $value != ".." ) {
3131
- $value = $folderPath . "/" . $value;
3132
  if ( @is_dir ( $value ) ) {
3133
  uninstall_supercache( $value );
3134
  } else {
@@ -3144,7 +3146,7 @@ function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual
3144
 
3145
  function supercache_admin_bar_render() {
3146
  global $wp_admin_bar, $wp_cache_not_logged_in;
3147
- if ( !is_user_logged_in() || !$wp_cache_not_logged_in )
3148
  return false;
3149
 
3150
  if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') )
1
  <?php
2
  /*
3
  Plugin Name: WP Super Cache
4
+ Plugin URI: http://wordpress.org/plugins/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
+ Version: 1.4.1
7
+ Author: Automattic
8
+ Author URI: http://automattic.com/
9
+ License: GPL2+
10
+ Text Domain: wp-super-cache
11
  */
12
 
13
+ /*
14
+ Copyright Automattic and many other contributors.
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
78
  add_action( 'template_redirect', 'wp_cache_set_home' );
79
 
80
 
81
+ // OSSDL CDN plugin (http://wordpress.org/plugins/ossdl-cdn-off-linker/)
82
  include_once( WPCACHEHOME . 'ossdl-cdn.php' );
83
 
84
  // from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
85
  function is_writeable_ACLSafe($path) {
86
 
87
  // PHP's is_writable does not work with Win32 NTFS
88
+
89
  if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
90
  return is_writeable_ACLSafe($path.uniqid(mt_rand()).'.tmp');
91
  else if (is_dir($path))
172
 
173
  if ( !wpsupercache_site_admin() )
174
  return false;
175
+
176
  if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) ) {
177
  echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h3><p>' .
178
  __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . ' ';
179
+
180
+
181
  if( !ini_get( 'safe_mode_gid' ) ) {
182
  _e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . " ";
183
  printf( __( '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 %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), WP_CONTENT_DIR );
203
  if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
204
  ?><div id="message" class="updated fade"><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3>
205
  <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p>
206
+ <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/faq/' ); ?></p>
207
  </div>
208
  <?php
209
  return false;
217
  if( $cron[ 'response' ][ 'code' ] == '404' ) {
218
  ?><div id="message" class="updated fade"><h3>Warning! wp-cron.php not found!</h3>
219
  <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p>
220
+ <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/faq/' ); ?></p>
221
  </div>
222
  <?php
223
  } else {
238
  return false;
239
  }
240
 
241
+ if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
242
  ?><div id="message" class="updated fade"><h3><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h3>
243
  <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p></div><?php
244
  }
280
  <input type="hidden" name="action" value="dismiss_gc_warning" />
281
  <input type="hidden" name="page" value="wpsupercache" />
282
  <?php wp_nonce_field( 'wp-cache' ); ?>
283
+ <input class='button-secondary' type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
284
  </form>
285
  <br />
286
  </div>
308
  <input type="hidden" name="action" value="dismiss_readable_warning" />
309
  <input type="hidden" name="page" value="wpsupercache" />
310
  <?php wp_nonce_field( 'wp-cache' ); ?>
311
+ <input class='button-secondary' type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
312
  </form>
313
  <br />
314
  </div>
322
  if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
323
  echo '<div id="message" class="updated fade"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>";
324
  echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "2.0\ MMP|240x320" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></div>";
325
+ } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && (
326
  ( false == empty( $wp_cache_mobile_prefixes ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) ) ) ||
327
  ( false == empty( $wp_cache_mobile_browsers ) && false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) )
328
  ) {
334
  <li> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></li>
335
  <li> <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li>
336
  <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%%{HTTP:Cookie} !^.*(comment_author_|%s|wp-postpass_).*$</code> add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path, wpsc_get_logged_in_cookie() ); ?></p>
337
+ <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre><?php echo "RewriteCond %{HTTP_user_agent} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").*\nRewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").*"; ?></pre></div></li></ol></div><?php
338
  }
339
 
340
  if ( $cache_enabled && $super_cache_enabled && $wp_cache_mod_rewrite && $scrules == '' ) {
370
  } elseif ( !isset( $dismiss_htaccess_warning ) ) {
371
  $dismiss_htaccess_warning = 0;
372
  }
373
+ if ( isset( $disable_supercache_htaccess_warning ) == false )
374
+ $disable_supercache_htaccess_warning = false;
375
  if ( $dismiss_htaccess_warning == 0 && $wp_cache_mod_rewrite && $super_cache_enabled && $disable_supercache_htaccess_warning == false && get_option( 'siteurl' ) != get_option( 'home' ) ) {
376
  $home_dir = str_replace( get_option( 'home' ), '', get_option( 'siteurl' ) );
377
  ?><div id="message" class="updated fade"><h3><?php _e( '.htaccess file may need to be moved', 'wp-super-cache' ); ?></h3>
380
  <input type="hidden" name="action" value="dismiss_htaccess_warning" />
381
  <input type="hidden" name="page" value="wpsupercache" />
382
  <?php wp_nonce_field( 'wp-cache' ); ?>
383
+ <input class='button-secondary' type='submit' value='<?php _e( 'Dismiss', 'wp-super-cache' ); ?>' />
384
  </form>
385
+ <br />
386
  </div><?php
387
  }
388
 
396
  if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') )
397
  return false;
398
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) {
399
+ $path = trailingslashit( get_supercache_dir() . preg_replace( '/:.*$/', '', $_GET[ 'path' ] ) );
400
  $files = get_all_supercache_filenames( $path );
401
  foreach( $files as $cache_file )
402
+ prune_super_cache( $path . $cache_file, true );
403
 
404
  wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) );
405
  die();
597
  $wp_cache_refresh_single_only = 0;
598
  }
599
  wp_cache_replace_line('^ *\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file);
600
+
601
  if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
602
  $cache_compression = 0;
603
  wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
607
  } else {
608
  $new_cache_compression = 0;
609
  }
610
+ if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
611
  echo '<div id="message" class="updated fade">' . __( "<strong>Warning!</strong> You attempted to enable compression but <code>zlib.output_compression</code> is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ) . '</div>';
612
  } else {
613
  if ( $new_cache_compression != $cache_compression ) {
652
  $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list
653
  if ( function_exists( 'do_cacheaction' ) ) {
654
  $wp_cache_mobile_browsers = do_cacheaction( 'wp_super_cache_mobile_browsers', $wp_cache_mobile_browsers );
655
+ $wp_cache_mobile_prefixes = do_cacheaction( 'wp_super_cache_mobile_prefixes', $wp_cache_mobile_prefixes );
656
  }
657
  $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default
658
  // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) );
740
  $home_path = parse_url( site_url() );
741
  $home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path[ 'path' ] : '' );
742
  if (! isset( $wp_cache_home_path ) )
743
+ $wp_cache_home_path = '/';
744
  if ( "$home_path" != "$wp_cache_home_path" )
745
  wp_cache_replace_line('^ *\$wp_cache_home_path', "\$wp_cache_home_path = '$home_path';", $wp_cache_config_file);
746
+
747
 
748
  if( $wp_cache_mobile_enabled == 1 ) {
749
  update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
799
  wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' );
800
  if ( $wp_cache_preload_interval == 0 ) {
801
  echo "<p><strong>" . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "</strong></p>";
802
+ }
803
  }
804
  if ( $_POST[ 'custom_preload_interval' ] != 0 )
805
  wp_schedule_single_event( time() + ( $_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' );
917
  echo "<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
918
  }
919
  }
920
+ echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" />&nbsp;<input class="button-secondary" type="submit" name="preload" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />';
921
  if ( $currently_preloading ) {
922
+ echo '&nbsp;<input class="button-primary" type="submit" name="preload" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
923
  }
924
  echo '</div>';
925
  wp_nonce_field('wp-cache');
937
  case 'settings':
938
  if ( isset( $wp_cache_front_page_checks ) == false )
939
  $wp_cache_front_page_checks = true;
940
+ echo '<form name="wp_manager" action="' . esc_url( add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'settings' ) ) ) . '" method="post">';
941
  wp_nonce_field('wp-cache');
942
  echo '<input type="hidden" name="action" value="scupdates" />';
943
  ?><table class="form-table">
947
  <fieldset>
948
  <legend class="hidden">Caching</legend>
949
  <label><input type='checkbox' name='wp_cache_status' value='all' <?php if ( $cache_enabled == true ) { echo 'checked=checked'; } ?>> <?php _e( 'Cache hits to this website for quick access.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /><br />
950
+ <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled ) echo "checked"; ?> value='1'> <?php printf( __( 'Use mod_rewrite to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/plugins/wordpress-mobile-edition/' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
951
+ <label><input type='radio' name='super_cache_enabled' <?php if( $wp_cache_mod_rewrite == 0 ) echo "checked"; ?> value='2'> <?php printf( __( 'Use PHP to serve cache files.', 'wp-super-cache' ), 'http://wordpress.org/plugins/wordpress-mobile-edition/' ); ?></label><br />
952
  <label><input type='radio' name='super_cache_enabled' <?php if( $super_cache_enabled == false ) echo "checked"; ?> value='0'> <?php _e( 'Legacy page caching.', 'wp-super-cache' ); ?></label><br />
953
  <em><?php _e( 'Mod_rewrite is fastest, PHP is almost as fast and easier to get working, while legacy caching is slower again, but more flexible and also easy to get working. New users should use PHP caching.', 'wp-super-cache' ); ?></em><br />
954
  </legend>
994
  <td>
995
  <fieldset>
996
  <legend class="hidden">Advanced</legend>
997
+ <label><input type='checkbox' name='wp_cache_mfunc_enabled' <?php if( $wp_cache_mfunc_enabled ) echo "checked"; ?> value='1' <?php if ( $wp_cache_mod_rewrite ) { echo "disabled='disabled'"; } ?>> <?php _e( 'Enable dynamic caching. Requires PHP or legacy caching. (See <a href="http://wordpress.org/plugins/wp-super-cache/faq/">FAQ</a> or wp-super-cache/plugins/dynamic-cache-test.php for example code.)', 'wp-super-cache' ); ?></label><br />
998
+ <label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php _e( 'Mobile device support. (External plugin or theme required. See the <a href="http://wordpress.org/plugins/wp-super-cache/faq/">FAQ</a> for further details.)', 'wp-super-cache' ); ?></label><br />
999
  <?php if ( $wp_cache_mobile_enabled ) {
1000
  echo '<blockquote><h4>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h4>' . implode( ', ', $wp_cache_mobile_browsers ) . "<br /><h4>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h4>" . implode( ', ', $wp_cache_mobile_prefixes ) . "<br /></blockquote>";
1001
  } ?>
1008
  <label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You probably don&#8217;t need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em>', 'wp-super-cache' ); ?></label><br />
1009
  <?php } ?>
1010
  <label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded. Most useful in legacy mode.', 'wp-super-cache' ); ?></label><br />
1011
+ <?php if ( $_wp_using_ext_object_cache ) {
1012
+ ?><label><input type='checkbox' name='wp_cache_object_cache' <?php if( $wp_cache_object_cache ) echo "checked"; ?> value='1'> <?php echo __( 'Use object cache to store cached files.', 'wp-super-cache' ) . ' ' . __( '(Experimental)', 'wp-super-cache' ); ?></label><?php
1013
  }?>
1014
  <?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
1015
  </legend>
1022
  <li><?php _e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required then simple instructions are provided.', 'wp-super-cache' ); ?></li>
1023
  <li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</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!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></li>
1024
  <li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), WP_PLUGIN_URL ); ?></li><?php
1025
+ echo "<li><em>" . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/', 'http://wordpress.org/tags/wp-super-cache?forum_id=10' ) . "</em></li>";
1026
  echo "</ol>";
1027
+
1028
+ echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . "' /></div>";
1029
  wp_nonce_field('wp-cache');
1030
  ?> </form> <?php
1031
  wsc_mod_rewrite();
1072
  echo "<p><strong>" . __( 'Notice: PHP caching enabled but Supercache mod_rewrite rules detected. Cached files will be served using those rules. If your site is working ok please ignore this message or you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
1073
  }
1074
  }
1075
+ echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . "' /></div></form>";
1076
  if ( $cache_enabled ) {
1077
  echo "<h3>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h3>";
1078
  echo '<p>' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
1153
  echo '<input type="hidden" name="action" value="test" />';
1154
  if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) )
1155
  echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
1156
+ echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1157
  wp_nonce_field('wp-cache');
1158
  echo '</form>';
1159
  }
1161
  echo "<p>" . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them use the button below.", 'wp-super-cache' ) . "</p>";
1162
  echo '<form name="wp_cache_content_delete" action="?page=wpsupercache&tab=contents" method="post">';
1163
  echo '<input type="hidden" name="wp_delete_cache" />';
1164
+ echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . ' " /></div>';
1165
  wp_nonce_field('wp-cache');
1166
  echo "</form>\n";
1167
 
1168
  if ( ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
1169
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
1170
  echo '<input type="hidden" name="wp_delete_all_cache" />';
1171
+ echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" />';
1172
  wp_nonce_field('wp-cache');
1173
  echo "</form><br />\n";
1174
  }
1175
  ?>
1176
+ <h3 class="clear"><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h3>
1177
  <p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
 
1178
  <li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> is an extension for the Firefox add-on Firebug. It analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://developer.yahoo.com/yslow/', 'http://gtmetrix.com/' ); ?></li>
1179
+ <li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically it may reduce your Yslow score.', 'wp-super-cache' ), 'http://wordpress.org/plugins/use-google-libraries/' ); ?></li>
 
1180
  <li><?php printf( __( '<strong>Advanced users only:</strong> <a href="%s">Speed up your site with Caching and cache-control</a> explains how to make your site more cacheable with .htaccess rules.', 'wp-super-cache' ), 'http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html' ); ?></li>
1181
+ <li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'http://wordpress.org/plugins/memcached/', 'http://neosmart.net/dl.php?id=12', 'http://neosmart.net/dl.php?id=13' ); ?></li>
1182
+ <li><?php printf( __( '<a href="%s">Cron View</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'http://wordpress.org/plugins/cron-view/' ); ?></li>
1183
  </ol>
1184
+
1185
  <?php
1186
  break;
1187
  }
1190
  </fieldset>
1191
  </td><td valign='top' style='width: 300px'>
1192
  <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
 
 
 
 
1193
  <h3 align='center'><?php _e( 'Need Help?', 'wp-super-cache' ); ?></h3>
1194
  <ol>
1195
  <li><?php _e( 'Use the debug system in the Debug tab above. It will tell you what the plugin is doing.', 'wp-super-cache' ); ?></li>
1196
+ <li><?php printf( __( '<a href="%1$s">Installation Help</a>', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/installation/' ); ?></li>
1197
+ <li><?php printf( __( '<a href="%1$s">Frequently Asked Questions</a>', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/faq/' ); ?></li>
1198
  <li><?php printf( __( '<a href="%1$s">Support Forum</a>', 'wp-super-cache' ), 'http://wordpress.org/tags/wp-super-cache' ); ?></li>
1199
  <li><?php printf( __( '<a href="%1$s">Development Version</a>', 'wp-super-cache' ), 'http://ocaoimh.ie/y/2o' ); ?></li>
1200
  </ol>
1201
  <h3 align='center'><?php _e( 'Rate This Plugin!', 'wp-super-cache' ); ?></h3>
1202
+ <p><?php printf( __( 'Please <a href="%s">rate</a> this plugin and tell me if it works for you or not. It really helps development.', 'wp-super-cache' ), 'http://wordpress.org/plugins/wp-super-cache/' ); ?></p>
1203
 
1204
+ <?php
1205
+ if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
1206
  $start_date = get_option( 'wpsupercache_start' );
1207
  if ( !$start_date ) {
1208
  $start_date = time();
1217
  }
1218
  ?></ol>
1219
  <small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
1220
+ </p><?php
1221
  } elseif ( false == get_option( 'wpsupercache_start' ) ) {
1222
  update_option( 'wpsupercache_start', time() );
1223
  update_option( 'wpsupercache_count', 0 );
1307
  if ( function_exists( "is_main_site" ) && false == is_main_site() )
1308
  return true;
1309
  ?>
1310
+ <a name="modrewrite"></a><fieldset class="options">
1311
  <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3><?php
1312
 
1313
  extract( wpsc_get_htaccess_info() );
1334
  } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
1335
  $dohtaccess = false;
1336
  }
1337
+ if ( $dohtaccess && !isset( $_POST[ 'updatehtaccess' ] ) ){
1338
  if ( $scrules == '' ) {
1339
  wpsc_update_htaccess_form( 0 ); // don't hide the update htaccess form
1340
  } else {
1341
  wpsc_update_htaccess_form();
1342
  }
1343
+ } elseif ( $valid_nonce && isset( $_POST[ 'updatehtaccess' ] ) ) {
1344
  echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
1345
  if( wpsc_update_htaccess() ) {
1346
  echo "<h4>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h4>";
1362
  echo "<div id='rewriterules' style='display: none;'>";
1363
  if ( $rules != $scrules )
1364
  echo '<div style="background: #fff; border: 1px solid #333; margin: 2px;">' . wp_text_diff( $scrules, $rules, array( 'title' => 'Rewrite Rules', 'title_left' => 'Current Rules', 'title_right' => 'New Rules' ) ) . "</div>";
1365
+ echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>\n";
1366
  echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>";
1367
  echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>";
1368
  echo '</div>';
1380
  echo '<fieldset class="options"><h3>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h3>';
1381
  echo '<form name="wp_restore" action="#top" method="post">';
1382
  echo '<input type="hidden" name="wp_restore_config" />';
1383
+ echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
1384
  wp_nonce_field('wp-cache');
1385
  echo "</form>\n";
1386
  echo '</fieldset>';
1412
  }
1413
  }
1414
  ?><a name='lockdown'></a>
1415
+ <fieldset class="options">
1416
  <h3><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h3>
1417
  <p><?php _e( '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.', 'wp-super-cache' ); ?></p>
1418
  <p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?>
1419
+ <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
1420
  &nbsp;&nbsp;&nbsp;&nbsp;echo "<?php _e( 'Sorry. My blog is locked down. Updates will appear shortly', 'wp-super-cache' ); ?>";
1421
  }</code></blockquote>
1422
  <?php
1429
  $new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
1430
  echo '<form name="wp_lock_down" action="#lockdown" method="post">';
1431
  echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
1432
+ echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} " . __( 'Lock Down', 'wp-super-cache' ) . "' /></div>";
1433
  wp_nonce_field('wp-cache');
1434
  echo "</form>\n";
1435
 
1436
  ?></fieldset><?php
1437
  if( $cache_enabled == true && $super_cache_enabled == true ) {
1438
  ?><a name='direct'></a>
1439
+ <fieldset class="options">
1440
  <h3><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h3><?php
1441
 
1442
  $out = '';
1519
  continue;
1520
  $generated = '';
1521
  if( is_file( ABSPATH . $page . '/index.html' ) )
1522
+ $generated = '<input class="button-secondary" type="Submit" name="deletepage" value="' . $page . '">';
1523
  $out .= "<tr><td><input type='text' $readonly name='direct_pages[]' size='30' value='$page' /></td><td>$generated</td></tr>";
1524
  }
1525
  if( $out != '' ) {
1538
 
1539
  wp_nonce_field('wp-cache');
1540
  if( $readonly != 'READONLY' )
1541
+ echo "<div class='submit'><input class='button-primary' type='submit' ' . SUBMITDISABLED . 'value='" . __( 'Update Direct Pages', 'wp-super-cache' ) . "' /></div>";
1542
  echo "</form>\n";
1543
  ?></fieldset><?php
1544
  } // if $super_cache_enabled
1551
  $dh = @opendir($folderPath);
1552
  while (false !== ($value = @readdir($dh))) {
1553
  if ( $value != "." && $value != ".." ) {
1554
+ $value = $folderPath . "/" . $value;
1555
  if ( @is_dir ( $value ) ) {
1556
  RecursiveFolderDelete ( $value );
1557
  }
1598
 
1599
  if ( isset( $_POST[ 'cache_gc_email_me' ] ) && $valid_nonce ) {
1600
  $cache_gc_email_me = 1;
1601
+ wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file);
1602
  } elseif ( $valid_nonce ) {
1603
  $cache_gc_email_me = 0;
1604
+ wp_cache_replace_line('^ *\$cache_gc_email_me', "\$cache_gc_email_me = $cache_gc_email_me;", $wp_cache_config_file);
1605
  }
1606
  if ( isset( $_POST[ 'cache_schedule_type' ] ) && $_POST[ 'cache_schedule_type' ] == 'interval' && isset( $_POST['cache_time_interval'] ) && $valid_nonce ) {
1607
  wp_clear_scheduled_hook( 'wp_cache_gc' );
1615
  } elseif ( $valid_nonce ) { // clock
1616
  wp_clear_scheduled_hook( 'wp_cache_gc' );
1617
  $cache_schedule_type = 'time';
1618
+ if ( !isset( $_POST[ 'cache_scheduled_time' ] ) || $_POST[ 'cache_scheduled_time' ] == '' )
1619
  $_POST[ 'cache_scheduled_time' ] = '00:00';
1620
  $cache_scheduled_time = $_POST[ 'cache_scheduled_time' ];
1621
  $schedules = wp_get_schedules();
1622
+ if ( !isset( $cache_schedule_interval ) )
1623
+ $cache_schedule_interval = 'daily';
1624
  if ( isset( $schedules[ $_POST[ 'cache_schedule_interval' ] ] ) )
1625
  $cache_schedule_interval = $_POST[ 'cache_schedule_interval' ];
1626
  wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file);
1628
  wp_cache_replace_line('^ *\$cache_scheduled_time', "\$cache_scheduled_time = '$cache_scheduled_time';", $wp_cache_config_file);
1629
  wp_schedule_event( strtotime( $cache_scheduled_time ), $cache_schedule_interval, 'wp_cache_gc' );
1630
  }
1631
+ ?><fieldset class="options">
1632
  <a name='expirytime'></a>
1633
  <h3><?php _e( 'Expiry Time &amp; Garbage Collection', 'wp-super-cache' ); ?></h3><?php
1634
 
1694
  echo "</ol>";
1695
  echo "<p>" . __( 'Checking for and deleting expired files is expensive, but it&#8217;s expensive leaving them there too. On a very busy site you should set the expiry time to <em>600 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. If you are using legacy caching aim to have less than 500 cached files if possible. You can have many times more cached files when using mod_rewrite or PHP caching.', 'wp-super-cache' ) . "</p>";
1696
  echo "<p>" . __( 'Set the expiry time to 0 seconds to disable garbage collection.', 'wp-super-cache' ) . "</p>";
1697
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Change Expiration', 'wp-super-cache' ) . '" /></div>';
1698
  wp_nonce_field('wp-cache');
1699
  echo "</form>\n";
1700
  ?></fieldset><?php
1746
  echo esc_html( $ua ) . "\n";
1747
  }
1748
  echo '</textarea> ';
1749
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save UA Strings', 'wp-super-cache' ) . '" /></div>';
1750
  wp_nonce_field('wp-cache');
1751
  echo '</form>';
1752
  echo "</fieldset>\n";
1783
  echo '<label><input type="checkbox" value="1" name="wp_cache_pages[search]" ' . checked( 1, $wp_cache_pages[ 'search' ], false ) . ' /> ' . __( 'Search Pages', 'wp-super-cache' ) . ' (is_search)</label><br />';
1784
  echo '<label><input type="checkbox" value="1" name="wp_cache_pages[author]" ' . checked( 1, $wp_cache_pages[ 'author' ], false ) . ' /> ' . __( 'Author Pages', 'wp-super-cache' ) . ' (is_author)</label><br />';
1785
 
1786
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save' ) . '" /></div>';
1787
  wp_nonce_field('wp-cache');
1788
  echo "</form>\n";
1789
 
1806
  echo esc_html( $file ) . "\n";
1807
  }
1808
  echo '</textarea> ';
1809
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Strings', 'wp-super-cache' ) . '" /></div>';
1810
  wp_nonce_field('wp-cache');
1811
  echo "</form>\n";
1812
  }
1828
  echo esc_html($file) . "\n";
1829
  }
1830
  echo '</textarea> ';
1831
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Files', 'wp-super-cache' ) . '" /></div>';
1832
  wp_nonce_field('wp-cache');
1833
  echo "</form>\n";
1834
  }
1840
  if ( false == isset( $wp_super_cache_comments ) )
1841
  $wp_super_cache_comments = 1;
1842
  if ( isset( $_POST[ 'wp_cache_debug' ] ) && $valid_nonce ) {
1843
+ if ( !isset( $_POST[ 'wp_super_cache_debug' ] ) )
1844
+ $_POST[ 'wp_super_cache_debug' ] = 0;
1845
  $wp_super_cache_debug = intval( $_POST[ 'wp_super_cache_debug' ] );
1846
  wp_cache_replace_line('^ *\$wp_super_cache_debug', "\$wp_super_cache_debug = '$wp_super_cache_debug';", $wp_cache_config_file);
1847
  if ( $wp_super_cache_debug && ( ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log == '' ) || !isset( $wp_cache_debug_log ) ) ) {
1850
  $wp_cache_debug_log = "";
1851
  }
1852
  wp_cache_replace_line('^ *\$wp_cache_debug_log', "\$wp_cache_debug_log = '$wp_cache_debug_log';", $wp_cache_config_file);
1853
+ $wp_super_cache_comments = isset( $_POST[ 'wp_super_cache_comments' ] ) ? 1 : 0;
1854
  wp_cache_replace_line('^ *\$wp_super_cache_comments', "\$wp_super_cache_comments = '$wp_super_cache_comments';", $wp_cache_config_file);
1855
  $wp_cache_debug_ip = esc_html( $_POST[ 'wp_cache_debug_ip' ] );
1856
  wp_cache_replace_line('^ *\$wp_cache_debug_ip', "\$wp_cache_debug_ip = '$wp_cache_debug_ip';", $wp_cache_config_file);
1857
+ $wp_super_cache_front_page_check = isset( $_POST[ 'wp_super_cache_front_page_check' ] ) ? 1 : 0;
1858
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_check', "\$wp_super_cache_front_page_check = '$wp_super_cache_front_page_check';", $wp_cache_config_file);
1859
+ $wp_super_cache_front_page_clear = isset( $_POST[ 'wp_super_cache_front_page_clear' ] ) ? 1 : 0;
1860
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_clear', "\$wp_super_cache_front_page_clear = '$wp_super_cache_front_page_clear';", $wp_cache_config_file);
1861
  $wp_super_cache_front_page_text = esc_html( $_POST[ 'wp_super_cache_front_page_text' ] );
1862
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_text', "\$wp_super_cache_front_page_text = '$wp_super_cache_front_page_text';", $wp_cache_config_file);
1863
+ $wp_super_cache_front_page_notification = isset( $_POST[ 'wp_super_cache_front_page_notification' ] ) ? 1 : 0;
1864
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_notification', "\$wp_super_cache_front_page_notification = '$wp_super_cache_front_page_notification';", $wp_cache_config_file);
1865
+ if ( $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
1866
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
1867
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
1868
  }
1894
  echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
1895
  echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
1896
  echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
1897
+
1898
  echo "</table>\n";
1899
  }
1900
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
1901
  wp_nonce_field('wp-cache');
1902
  echo "</form>\n";
1903
  echo '</fieldset>';
2116
 
2117
  function wp_cache_check_link() {
2118
  global $wp_cache_link, $wp_cache_file;
2119
+
2120
  $ret = true;
2121
  if( file_exists($wp_cache_link) ) {
2122
  $file = file_get_contents( $wp_cache_link );
2169
  }
2170
  return false;
2171
  } else {
2172
+ echo "<div style='border: 1px solid #333; background: #ffffaa; padding: 2px;'>" . __( '<h3>WP_CACHE constant added to wp-config.php</h3><p>If you continue to see this warning message please see point 5 of the <a href="http://wordpress.org/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>";
2173
  }
2174
  return true;
2175
  }
2212
  $count = 0;
2213
  $expired = 0;
2214
  $now = time();
2215
+ if ( ($handle = @opendir( $blog_cache_dir . 'meta/' )) ) {
2216
  $wp_cache_fsize = 0;
2217
  if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletewpcache' ) {
2218
  $deleteuri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) ) );
2234
  if ( preg_match("/^$file_prefix.*\.meta/", $file) ) {
2235
  $content_file = preg_replace("/meta$/", "html", $file);
2236
  $mtime = filemtime( $blog_cache_dir . 'meta/' . $file );
2237
+ if ( ! ( $fsize = @filesize( $blog_cache_dir . $content_file ) ) )
2238
  continue; // .meta does not exists
2239
 
2240
  $age = $now - $mtime;
2241
+ if ( $valid_nonce && isset( $_GET[ 'listfiles' ] ) ) {
2242
  $meta = unserialize( file_get_contents( $blog_cache_dir . 'meta/' . $file ) );
2243
  if ( $deleteuri != '' && $meta[ 'uri' ] == $deleteuri ) {
2244
  printf( __( "Deleting wp-cache file: <strong>%s</strong><br />", 'wp-super-cache' ), $deleteuri );
2301
  if ( $valid_nonce && $_GET[ 'listfiles' ] && $filem )
2302
  $sizes[ 'cached_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem;
2303
  }
2304
+ }
2305
  $sizes[ 'ts' ] = time();
2306
  $cache_stats = array( 'generated' => time(), 'supercache' => $sizes, 'wpcache' => array( 'cached' => $count, 'expired' => $expired, 'fsize' => $wp_cache_fsize ) );
2307
  update_option( 'supercache_stats', $cache_stats );
2339
  echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'expired' ] / $divisor ) ) . "</li></ul>";
2340
  if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) {
2341
  echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>";
2342
+ if ( isset( $cached_list ) && is_array( $cached_list ) && !empty( $cached_list ) ) {
2343
  echo "<h4>" . __( 'Fresh WP-Cached Files', 'wp-super-cache' ) . "</h4>";
2344
  echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>";
2345
  $c = 1;
2355
  }
2356
  echo "</table>";
2357
  }
2358
+ if ( isset( $expired_list ) && is_array( $expired_list ) && !empty( $expired_list ) ) {
2359
  echo "<h4>" . __( 'Stale WP-Cached Files', 'wp-super-cache' ) . "</h4>";
2360
  echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Key', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>";
2361
  $c = 1;
2422
 
2423
  echo '<form name="wp_cache_content_expired" action="#listfiles" method="post">';
2424
  echo '<input type="hidden" name="wp_delete_expired" />';
2425
+ echo '<div class="submit" style="float:left"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . '" /></div>';
2426
  wp_nonce_field('wp-cache');
2427
  echo "</form>\n";
2428
 
2429
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
2430
  echo '<input type="hidden" name="wp_delete_cache" />';
2431
+ echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
2432
  wp_nonce_field('wp-cache');
2433
  echo "</form>\n";
2434
  if ( ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
2435
  echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
2436
  echo '<input type="hidden" name="wp_delete_all_cache" />';
2437
+ echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" />';
2438
  wp_nonce_field('wp-cache');
2439
  echo "</form>\n";
2440
  }
2512
 
2513
  function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
2514
  global $wpdb;
2515
+ if ( $handle = @opendir( $dir . 'meta/' ) ) {
2516
  while ( false !== ($file = readdir($handle))) {
2517
  if ( preg_match( "/^$file_prefix/", $file ) ) {
2518
  $meta = unserialize( file_get_contents( $dir . 'meta/' . $file ) );
2549
 
2550
  $expr = "/^$file_prefix/";
2551
  $now = time();
2552
+ if ( ($handle = @opendir( $blog_cache_dir )) ) {
2553
  while ( false !== ($file = readdir($handle))) {
2554
  if ( preg_match( $expr, $file ) &&
2555
  ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) {
2645
  if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( "admin_url" ) )
2646
  echo '<div class="error"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
2647
 
2648
+ if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
2649
  echo '<div class="error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
2650
  wp_cache_create_advanced_cache();
2651
  }
2669
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
2670
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) );
2671
  } else {
2672
+ wp_cache_clear_cache( get_current_blog_id() );
2673
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( "The cache on your blog has been cleared because the front page of your site is now downloading. Please visit %s to verify the cache has been cleared.", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) );
2674
  }
2675
  }
2679
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
2680
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( 'Please visit %1$s to clear the cache as the front page of your site is not correct and missing the text, "%2$s"!', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) );
2681
  } else {
2682
+ wp_cache_clear_cache( get_current_blog_id() );
2683
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( 'The cache on your blog has been cleared because the front page of your site is missing the text "%2$s". Please visit %1$s to verify the cache has been cleared.', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) );
2684
  }
2685
  }
2709
  $wp_cache_mobile_groups = $mobile_groups;
2710
  wp_cache_replace_line('^ *\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode( ', ', $mobile_groups ) . "';", $wp_cache_config_file);
2711
  }
2712
+
2713
  return true;
2714
  }
2715
 
2742
  if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
2743
  echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
2744
  echo '<input type="hidden" name="updatehtaccess" value="1" />';
2745
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . '" /></div>';
2746
  wp_nonce_field('wp-cache');
2747
  echo "</form></div>\n";
2748
  }
2749
  }
2750
  }
2751
 
2752
+ /*
2753
  * Return LOGGED_IN_COOKIE if it doesn't begin with wordpress_logged_in
2754
  * to avoid having people update their .htaccess file
2755
  */
2756
  function wpsc_get_logged_in_cookie() {
2757
  $logged_in_cookie = 'wordpress_logged_in';
2758
+ if ( defined( 'LOGGED_IN_COOKIE' ) && substr( constant( 'LOGGED_IN_COOKIE' ), 0, 19 ) != 'wordpress_logged_in' )
2759
  $logged_in_cookie = constant( 'LOGGED_IN_COOKIE' );
2760
  return $logged_in_cookie;
2761
  }
2807
  $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
2808
  $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
2809
  if ( $wp_cache_mobile_enabled ) {
2810
+ if ( false == empty( $wp_cache_mobile_browsers ) )
2811
  $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]";
2812
+ if ( false == empty( $wp_cache_mobile_prefixes ) )
2813
  $condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]";
2814
  }
2815
  $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
2867
  if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "clear_post_supercache: deleting $dir/index*.html files", 2 );
2868
  $files_to_check = get_all_supercache_filenames( $dir );
2869
  foreach( $files_to_check as $cache_file ) {
2870
+ prune_super_cache( $dir . $cache_file, true );
2871
  }
2872
  }
2873
 
3111
  $code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n";
3112
  }
3113
  $code .= "</ul>\n";
3114
+
3115
  $msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forgot to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is use <a href='http://www.google.ie/search?hl=en&q=ftp+chmod+777'>this Google search</a> to find out all about it.</p><p>Please refresh this page when the permissions have been modified.</p>";
3116
  wp_die( $msg );
3117
  }
3119
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
3120
  $wp_rewrite->flush_rules();
3121
  } elseif( $scrules != '' ) {
3122
+ wp_mail( get_option( 'admin_email' ), __( 'Supercache Uninstall Problems', 'wp-super-cache' ), sprintf( __( "Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/plugins/wp-super-cache/", 'wp-super-cache' ), ABSPATH . '/.htaccess' ) );
3123
  }
3124
  }
3125
 
3130
  $dh = @opendir($folderPath);
3131
  while( false !== ( $value = @readdir( $dh ) ) ) {
3132
  if ( $value != "." && $value != ".." ) {
3133
+ $value = $folderPath . "/" . $value;
3134
  if ( @is_dir ( $value ) ) {
3135
  uninstall_supercache( $value );
3136
  } else {
3146
 
3147
  function supercache_admin_bar_render() {
3148
  global $wp_admin_bar, $wp_cache_not_logged_in;
3149
+ if ( !is_user_logged_in() || !$wp_cache_not_logged_in )
3150
  return false;
3151
 
3152
  if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') )