WP Super Cache - Version 1.5.4

Version Description

  • Fix messages related to creating advanced-cache.php (#355, #354)
  • Deleting the plugin doesn't need to delete the cache directory as it's already done on deactivation. (#323)
  • Disable Jetpack mobile detection if Jetpack Beta is detected. (#298)
  • Add more checks on directories to make sure they exist before deleting them. (#324)
  • Add siteurl setting to CDN page for users who have WordPress in it's own directory. (#332)
  • Don't enable and then not save debug comments when toggling logging. (#334)
  • Show plugin activity html comments to users who disable caching for logged in users. (#335)
  • Better notifications on Preload page, and redo sql to fetch posts. Added "wpsc_preload_post_types_args" filter on post visibility, and wpsc_preload_post_types filter on post types used. (#336)
  • Use a cached feed if it is newer than the last time a post was updated. (#337)
  • Better define a sitemap (#340) but when the content type is unknown add more checks to find out what it is. (#346)
  • Save cache location correctly on the advanced settings page. (#345)
  • Make sure the debug log exists before toggling it on/off to ensure the http auth code is added to it.
  • Return the correct cache type to the REST API. Ignore supercache enabled status. (#352)
  • Fix cache contents in REST API showing double count of supercache files. (#353)
  • Move the nonce in the CDN page back into a function. (#346)
  • Use realpath to compare directories when loading the sample config file to account for symlinked directories. (#342)
  • Other minor changes to html or typos (Numbers are pull requests on Github.)
Download this release

Release Info

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

Code changes from version 1.5.3 to 1.5.4

ossdl-cdn.php CHANGED
@@ -5,7 +5,9 @@
5
  /* Set up some defaults */
6
  if ( get_option( 'ossdl_off_cdn_url' ) == false )
7
  add_option( 'ossdl_off_cdn_url', get_option( 'siteurl' ) );
8
- $ossdl_off_blog_url = apply_filters( 'ossdl_off_blog_url', get_option( 'siteurl' ) );
 
 
9
  $ossdl_off_cdn_url = trim( get_option('ossdl_off_cdn_url') );
10
  if ( get_option( 'ossdl_off_include_dirs' ) == false )
11
  add_option('ossdl_off_include_dirs', 'wp-content,wp-includes');
@@ -123,16 +125,14 @@ if ( false == isset( $ossdlcdn ) )
123
  if ( $ossdlcdn == 1 )
124
  add_action('init', 'do_scossdl_off_ob_start');
125
 
126
- if ( function_exists( 'wp_verify_nonce' ) )
127
- $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
128
- else
129
- $valid_nonce = false;
130
-
131
  function scossdl_off_update() {
132
- global $ossdlcdn, $wp_cache_config_file, $valid_nonce;
 
 
133
 
134
  if ( $valid_nonce && isset($_POST['action']) && ( $_POST['action'] == 'update_ossdl_off' )){
135
- update_option('ossdl_off_cdn_url', $_POST['ossdl_off_cdn_url']);
 
136
  update_option('ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs']);
137
  update_option('ossdl_off_exclude', $_POST['ossdl_off_exclude']);
138
  update_option('ossdl_cname', $_POST['ossdl_cname']);
@@ -149,7 +149,7 @@ function scossdl_off_update() {
149
  }
150
 
151
  function scossdl_off_options() {
152
- global $ossdlcdn, $wp_cache_config_file, $valid_nonce, $ossdl_off_blog_url;
153
 
154
  scossdl_off_update();
155
 
@@ -178,6 +178,13 @@ function scossdl_off_options() {
178
  </td>
179
  <th scope="row"><label for="ossdlcdn"><?php _e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
180
  </tr>
 
 
 
 
 
 
 
181
  <tr valign="top">
182
  <th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
183
  <td>
@@ -196,7 +203,7 @@ function scossdl_off_options() {
196
  <th scope="row"><label for="ossdl_off_exclude"><?php _e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
197
  <td>
198
  <input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( get_option( 'ossdl_off_exclude' ) ); ?>" size="64" class="regular-text code" /><br />
199
- <span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the match. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
200
  </td>
201
  </tr>
202
  <tr valign="top">
5
  /* Set up some defaults */
6
  if ( get_option( 'ossdl_off_cdn_url' ) == false )
7
  add_option( 'ossdl_off_cdn_url', get_option( 'siteurl' ) );
8
+ if ( get_option( 'ossdl_off_blog_url' ) == false )
9
+ add_option( 'ossdl_off_blog_url', apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) ) );
10
+ $ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
11
  $ossdl_off_cdn_url = trim( get_option('ossdl_off_cdn_url') );
12
  if ( get_option( 'ossdl_off_include_dirs' ) == false )
13
  add_option('ossdl_off_include_dirs', 'wp-content,wp-includes');
125
  if ( $ossdlcdn == 1 )
126
  add_action('init', 'do_scossdl_off_ob_start');
127
 
 
 
 
 
 
128
  function scossdl_off_update() {
129
+ global $ossdlcdn, $wp_cache_config_file;
130
+
131
+ $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
132
 
133
  if ( $valid_nonce && isset($_POST['action']) && ( $_POST['action'] == 'update_ossdl_off' )){
134
+ update_option( 'ossdl_off_cdn_url', untrailingslashit( $_POST[ 'ossdl_off_cdn_url' ] ) );
135
+ update_option( 'ossdl_off_blog_url', untrailingslashit( $_POST[ 'ossdl_off_blog_url' ] ) );
136
  update_option('ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs']);
137
  update_option('ossdl_off_exclude', $_POST['ossdl_off_exclude']);
138
  update_option('ossdl_cname', $_POST['ossdl_cname']);
149
  }
150
 
151
  function scossdl_off_options() {
152
+ global $ossdlcdn, $wp_cache_config_file, $ossdl_off_blog_url;
153
 
154
  scossdl_off_update();
155
 
178
  </td>
179
  <th scope="row"><label for="ossdlcdn"><?php _e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
180
  </tr>
181
+ <tr valign="top">
182
+ <th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Site URL', 'wp-super-cache' ); ?></label></th>
183
+ <td>
184
+ <input type="text" name="ossdl_off_blog_url" value="<?php echo esc_url( untrailingslashit( get_option( 'ossdl_off_blog_url' ) ) ); ?>" size="64" class="regular-text code" /><br />
185
+ <span class="description"><?php _e( 'The URL of your site. No trailing <code>/</code> please.', 'wp-super-cache' ); ?></span>
186
+ </td>
187
+ </tr>
188
  <tr valign="top">
189
  <th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
190
  <td>
203
  <th scope="row"><label for="ossdl_off_exclude"><?php _e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
204
  <td>
205
  <input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( get_option( 'ossdl_off_exclude' ) ); ?>" size="64" class="regular-text code" /><br />
206
+ <span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the URL. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
207
  </td>
208
  </tr>
209
  <tr valign="top">
plugins/jetpack.php CHANGED
@@ -50,16 +50,24 @@ function wp_super_cache_jetpack_admin() {
50
  add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
51
 
52
  function wp_super_cache_jetpack_cookie_check( $cache_key ) {
53
- if ( file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
54
- if ( function_exists( "jetpack_is_mobile" ) == false )
55
- include( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' );
56
 
 
 
 
 
 
 
 
 
 
 
 
57
  if ( jetpack_is_mobile() )
58
  return 'mobile';
59
  else
60
  return 'normal';
61
  } else {
62
- wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack UA file not found." );
63
  return "normal";
64
  }
65
  }
50
  add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
51
 
52
  function wp_super_cache_jetpack_cookie_check( $cache_key ) {
53
+ if ( function_exists( "jetpack_is_mobile" ) == false ) {
 
 
54
 
55
+ if ( file_exists( dirname( WPCACHEHOME ) . '/jetpack-dev/class.jetpack-user-agent.php' ) ) {
56
+ wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack dev detected. Returning 'normal' to avoid loading Jetpack." );
57
+ return "normal";
58
+ } elseif ( file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
59
+ include_once( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' );
60
+ } else {
61
+ wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack UA file not found." );
62
+ }
63
+ }
64
+
65
+ if ( function_exists( "jetpack_is_mobile" ) ) {
66
  if ( jetpack_is_mobile() )
67
  return 'mobile';
68
  else
69
  return 'normal';
70
  } else {
 
71
  return "normal";
72
  }
73
  }
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic, kraftbj
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 4.8
5
- Stable tag: 1.5.3
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -53,11 +53,29 @@ Interested in translating WP Super Cache to your language? See the [translation
53
  The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
54
 
55
  == Upgrade Notice ==
 
56
 
57
- = 1.5.3 =
58
- Emergency fix of a critical bug that caused wp-super-cache to delete the wp-admin when deleting the plugin thanks to a null cache path
59
 
60
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  = 1.5.3 =
63
  * Fix a critical bug that caused unlink to be run on null while deleting the plugin.
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic, kraftbj
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 4.8.1
5
+ Stable tag: 1.5.4
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
53
  The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
54
 
55
  == Upgrade Notice ==
56
+ Sitemap, feed, REST API and other maintenance fixes.
57
 
 
 
58
 
59
  == Changelog ==
60
+ = 1.5.4 =
61
+ * Fix messages related to creating advanced-cache.php (#355, #354)
62
+ * Deleting the plugin doesn't need to delete the cache directory as it's already done on deactivation. (#323)
63
+ * Disable Jetpack mobile detection if Jetpack Beta is detected. (#298)
64
+ * Add more checks on directories to make sure they exist before deleting them. (#324)
65
+ * Add siteurl setting to CDN page for users who have WordPress in it's own directory. (#332)
66
+ * Don't enable and then not save debug comments when toggling logging. (#334)
67
+ * Show plugin activity html comments to users who disable caching for logged in users. (#335)
68
+ * Better notifications on Preload page, and redo sql to fetch posts. Added "wpsc_preload_post_types_args" filter on post visibility, and wpsc_preload_post_types filter on post types used. (#336)
69
+ * Use a cached feed if it is newer than the last time a post was updated. (#337)
70
+ * Better define a sitemap (#340) but when the content type is unknown add more checks to find out what it is. (#346)
71
+ * Save cache location correctly on the advanced settings page. (#345)
72
+ * Make sure the debug log exists before toggling it on/off to ensure the http auth code is added to it.
73
+ * Return the correct cache type to the REST API. Ignore supercache enabled status. (#352)
74
+ * Fix cache contents in REST API showing double count of supercache files. (#353)
75
+ * Move the nonce in the CDN page back into a function. (#346)
76
+ * Use realpath to compare directories when loading the sample config file to account for symlinked directories. (#342)
77
+ * Other minor changes to html or typos
78
+ (Numbers are [pull requests](https://github.com/Automattic/wp-super-cache/pulls) on Github.)
79
 
80
  = 1.5.3 =
81
  * Fix a critical bug that caused unlink to be run on null while deleting the plugin.
rest/class.wp-super-cache-rest-get-settings.php CHANGED
@@ -50,6 +50,16 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
50
  return $this->prepare_item_for_response( $settings, $request );
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * @return string
55
  */
@@ -69,14 +79,10 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
69
  }
70
  include( $wp_cache_config_file );
71
 
72
- if ( $super_cache_enabled ) {
73
- if ( $wp_cache_mod_rewrite == 1 ) {
74
- return 'mod_rewrite';
75
- } else {
76
- return 'PHP';
77
- }
78
  } else {
79
- return 'wpcache';
80
  }
81
  }
82
 
@@ -162,8 +168,7 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
162
  */
163
  protected function get_minimum_preload_interval() {
164
  global $wpdb;
165
- $posts_count = wp_count_posts();
166
- $count = $posts_count->publish;
167
  if ( $count > 1000 ) {
168
  $min_refresh_interval = 720;
169
  } else {
@@ -188,8 +193,7 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
188
  * @return int
189
  */
190
  protected function get_post_count() {
191
- $posts_count = wp_count_posts();
192
- return $posts_count->publish;
193
  }
194
 
195
  /**
50
  return $this->prepare_item_for_response( $settings, $request );
51
  }
52
 
53
+ /**
54
+ * @return string
55
+ */
56
+ public function get_ossdl_off_blog_url() {
57
+ $url = get_option( 'ossdl_off_blog_url' );
58
+ if ( ! $url )
59
+ $url = apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) );
60
+ return $url;
61
+ }
62
+
63
  /**
64
  * @return string
65
  */
79
  }
80
  include( $wp_cache_config_file );
81
 
82
+ if ( $wp_cache_mod_rewrite == 1 ) {
83
+ return 'mod_rewrite';
 
 
 
 
84
  } else {
85
+ return 'PHP';
86
  }
87
  }
88
 
168
  */
169
  protected function get_minimum_preload_interval() {
170
  global $wpdb;
171
+ $count = $this->get_post_count();
 
172
  if ( $count > 1000 ) {
173
  $min_refresh_interval = 720;
174
  } else {
193
  * @return int
194
  */
195
  protected function get_post_count() {
196
+ return wpsc_post_count();
 
197
  }
198
 
199
  /**
rest/class.wp-super-cache-rest-update-settings.php CHANGED
@@ -381,6 +381,13 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
381
  update_option( 'ossdl_cname', $value );
382
  }
383
 
 
 
 
 
 
 
 
384
  /**
385
  * @param mixed $value
386
  */
381
  update_option( 'ossdl_cname', $value );
382
  }
383
 
384
+ /**
385
+ * @param mixed $value
386
+ */
387
+ protected function set_ossdl_off_blog_url( $value ) {
388
+ update_option( 'ossdl_off_blog_url', untrailingslashit( $value ) );
389
+ }
390
+
391
  /**
392
  * @param mixed $value
393
  */
rest/class.wp-super-cache-settings-map.php CHANGED
@@ -216,6 +216,10 @@ class WP_Super_Cache_Settings_Map {
216
  'option' => 'ossdl_off_cdn_url',
217
  'set' => 'set_ossdl_off_cdn_url',
218
  ),
 
 
 
 
219
  'ossdl_off_exclude' => array(
220
  'option' => 'ossdl_off_exclude',
221
  'set' => 'set_ossdl_off_exclude',
216
  'option' => 'ossdl_off_cdn_url',
217
  'set' => 'set_ossdl_off_cdn_url',
218
  ),
219
+ 'ossdl_off_blog_url' => array(
220
+ 'option' => 'ossdl_off_blog_url',
221
+ 'set' => 'set_ossdl_off_blog_url',
222
+ ),
223
  'ossdl_off_exclude' => array(
224
  'option' => 'ossdl_off_exclude',
225
  'set' => 'set_ossdl_off_exclude',
wp-cache-phase1.php CHANGED
@@ -48,7 +48,6 @@ if( is_array( $plugins ) ) {
48
 
49
  if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
50
  wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
51
- define( 'DONOTCACHEPAGE', 1 );
52
  return true;
53
  }
54
 
@@ -155,7 +154,7 @@ function wp_cache_serve_cache_file() {
155
  return false;
156
  }
157
 
158
- extract( wp_super_cache_init() );
159
 
160
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
161
  if ( !empty( $_GET ) ) {
@@ -175,7 +174,7 @@ function wp_cache_serve_cache_file() {
175
  wp_cache_debug( "Meta array from object cache corrupt. Ignoring cache.", 1 );
176
  return true;
177
  }
178
- } elseif ( file_exists( $cache_file ) || file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
179
  if ( file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
180
  $cache_file = get_current_url_supercache_dir() . $cache_filename;
181
  $meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
@@ -195,6 +194,21 @@ function wp_cache_serve_cache_file() {
195
  @unlink( $cache_file );
196
  return true;
197
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  } else { // no $cache_file
199
  global $wpsc_save_headers;
200
  // last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
@@ -376,7 +390,7 @@ function wp_cache_get_legacy_cache( $cache_file ) {
376
  }
377
 
378
  if(defined('DOING_CRON')) {
379
- extract( wp_super_cache_init() );
380
  return true;
381
  }
382
 
@@ -674,7 +688,18 @@ function wpsc_rebuild_files( $dir ) {
674
 
675
  // realpath() doesn't always remove the trailing slash
676
  function wpsc_get_realpath( $directory ) {
 
 
 
 
 
677
  $directory = realpath( $directory );
 
 
 
 
 
 
678
  if ( substr( $directory, -1 ) == '/' || substr( $directory, -1 ) == '\\' ) {
679
  $directory = substr( $directory, 0, -1 ); // remove trailing slash
680
  }
@@ -687,12 +712,32 @@ function wpsc_is_in_cache_directory( $directory ) {
687
  global $cache_path;
688
  static $rp_cache_path = '';
689
 
 
 
 
 
 
 
 
 
 
 
690
  if ( $rp_cache_path == '' ) {
691
  $rp_cache_path = wpsc_get_realpath( $cache_path );
692
  }
693
 
 
 
 
 
 
694
  $directory = wpsc_get_realpath( $directory );
695
 
 
 
 
 
 
696
  if ( substr( $directory, 0, strlen( $rp_cache_path ) ) == $rp_cache_path ) {
697
  return true;
698
  } else {
@@ -704,6 +749,11 @@ function wpsc_delete_files( $dir, $delete = true ) {
704
  global $cache_path;
705
  static $protected = '';
706
 
 
 
 
 
 
707
  // only do this once, this function will be called many times
708
  if ( $protected == '' ) {
709
  $protected = array( $cache_path, $cache_path . "blogs/", $cache_path . 'supercache' );
@@ -712,7 +762,13 @@ function wpsc_delete_files( $dir, $delete = true ) {
712
  }
713
  }
714
 
715
- $dir = trailingslashit( wpsc_get_realpath( $dir ) );
 
 
 
 
 
 
716
 
717
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
718
  return false;
@@ -741,6 +797,10 @@ function get_all_supercache_filenames( $dir = '' ) {
741
  global $wp_cache_mobile_enabled, $cache_path;
742
 
743
  $dir = wpsc_get_realpath( $dir );
 
 
 
 
744
 
745
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
746
  return array();
@@ -852,13 +912,25 @@ function wp_cache_confirm_delete( $dir ) {
852
  global $cache_path, $blog_cache_dir;
853
  // don't allow cache_path, blog cache dir, blog meta dir, supercache.
854
  $dir = wpsc_get_realpath( $dir );
855
- $rp_cache_path = wpsc_get_realpath( $cache_path );
 
 
 
 
 
856
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
857
  return false;
858
  }
859
 
 
 
 
 
 
 
860
 
861
- if (
 
862
  $dir == $rp_cache_path ||
863
  $dir == wpsc_get_realpath( $blog_cache_dir ) ||
864
  $dir == wpsc_get_realpath( $blog_cache_dir . "meta/" ) ||
48
 
49
  if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
50
  wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
 
51
  return true;
52
  }
53
 
154
  return false;
155
  }
156
 
157
+ extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
158
 
159
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
160
  if ( !empty( $_GET ) ) {
174
  wp_cache_debug( "Meta array from object cache corrupt. Ignoring cache.", 1 );
175
  return true;
176
  }
177
+ } elseif ( ( $cache_file && file_exists( $cache_file ) ) || file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
178
  if ( file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
179
  $cache_file = get_current_url_supercache_dir() . $cache_filename;
180
  $meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
194
  @unlink( $cache_file );
195
  return true;
196
  }
197
+ // check for updated feed
198
+ if ( isset( $meta[ 'headers' ][ 'Content-Type' ] ) ) {
199
+ $rss_types = apply_filters( 'wpsc_rss_types', array( 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml' ) );
200
+ foreach( $rss_types as $rss_type ) {
201
+ if ( strpos( $meta[ 'headers' ][ 'Content-Type' ], $rss_type ) ) {
202
+ global $wpsc_last_post_update;
203
+ if ( isset( $wpsc_last_post_update ) && filemtime( $meta_pathname ) < $wpsc_last_post_update ) {
204
+ wp_cache_debug( "wp_cache_serve_cache_file: feed out of date. deleting cache files: $meta_pathname, $cache_file" );
205
+ @unlink( $meta_pathname );
206
+ @unlink( $cache_file );
207
+ return true;
208
+ }
209
+ }
210
+ }
211
+ }
212
  } else { // no $cache_file
213
  global $wpsc_save_headers;
214
  // last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
390
  }
391
 
392
  if(defined('DOING_CRON')) {
393
+ extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
394
  return true;
395
  }
396
 
688
 
689
  // realpath() doesn't always remove the trailing slash
690
  function wpsc_get_realpath( $directory ) {
691
+ if ( $directory == '/' ) {
692
+ return false;
693
+ }
694
+
695
+ $original_dir = $directory;
696
  $directory = realpath( $directory );
697
+
698
+ if ( ! $directory ) {
699
+ wp_cache_debug( "wpsc_get_realpath: directory does not exist - $original_dir" );
700
+ return false;
701
+ }
702
+
703
  if ( substr( $directory, -1 ) == '/' || substr( $directory, -1 ) == '\\' ) {
704
  $directory = substr( $directory, 0, -1 ); // remove trailing slash
705
  }
712
  global $cache_path;
713
  static $rp_cache_path = '';
714
 
715
+ if ( $directory == '' ) {
716
+ wp_cache_debug( "wpsc_is_in_cache_directory: exiting as directory is blank" );
717
+ return false;
718
+ }
719
+
720
+ if ( $cache_path == '' ) {
721
+ wp_cache_debug( "wpsc_is_in_cache_directory: exiting as cache_path is blank" );
722
+ return false;
723
+ }
724
+
725
  if ( $rp_cache_path == '' ) {
726
  $rp_cache_path = wpsc_get_realpath( $cache_path );
727
  }
728
 
729
+ if ( ! $rp_cache_path ) {
730
+ wp_cache_debug( "wpsc_is_in_cache_directory: exiting as cache_path directory does not exist" );
731
+ return false;
732
+ }
733
+
734
  $directory = wpsc_get_realpath( $directory );
735
 
736
+ if ( ! $directory ) {
737
+ wp_cache_debug( "wpsc_is_in_cache_directory: directory does not exist" );
738
+ return false;
739
+ }
740
+
741
  if ( substr( $directory, 0, strlen( $rp_cache_path ) ) == $rp_cache_path ) {
742
  return true;
743
  } else {
749
  global $cache_path;
750
  static $protected = '';
751
 
752
+ if ( $dir == '' ) {
753
+ wp_cache_debug( "wpsc_delete_files: directory is blank" );
754
+ return false;
755
+ }
756
+
757
  // only do this once, this function will be called many times
758
  if ( $protected == '' ) {
759
  $protected = array( $cache_path, $cache_path . "blogs/", $cache_path . 'supercache' );
762
  }
763
  }
764
 
765
+ $dir = wpsc_get_realpath( $dir );
766
+ if ( ! $dir ) {
767
+ wp_cache_debug( "wpsc_delete_files: directory does not exist" );
768
+ return false;
769
+ }
770
+
771
+ $dir = trailingslashit( $dir );
772
 
773
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
774
  return false;
797
  global $wp_cache_mobile_enabled, $cache_path;
798
 
799
  $dir = wpsc_get_realpath( $dir );
800
+ if ( ! $dir ) {
801
+ wp_cache_debug( "get_all_supercache_filenames: directory does not exist" );
802
+ return array();
803
+ }
804
 
805
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
806
  return array();
912
  global $cache_path, $blog_cache_dir;
913
  // don't allow cache_path, blog cache dir, blog meta dir, supercache.
914
  $dir = wpsc_get_realpath( $dir );
915
+
916
+ if ( ! $dir ) {
917
+ wp_cache_debug( "wp_cache_confirm_delete: directory does not exist" );
918
+ return false;
919
+ }
920
+
921
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
922
  return false;
923
  }
924
 
925
+ $rp_cache_path = wpsc_get_realpath( $cache_path );
926
+
927
+ if ( ! $rp_cache_path ) {
928
+ wp_cache_debug( "wp_cache_confirm_delete: cache_path does not exist: $cache_path" );
929
+ return false;
930
+ }
931
 
932
+ if (
933
+ $dir == '' ||
934
  $dir == $rp_cache_path ||
935
  $dir == wpsc_get_realpath( $blog_cache_dir ) ||
936
  $dir == wpsc_get_realpath( $blog_cache_dir . "meta/" ) ||
wp-cache-phase2.php CHANGED
@@ -82,6 +82,10 @@ function wpcache_do_rebuild( $dir ) {
82
  }
83
 
84
  $dir = wpsc_get_realpath( $dir );
 
 
 
 
85
 
86
  if ( isset( $do_rebuild_list[ $dir ] ) ) {
87
  wp_cache_debug( "wpcache_do_rebuild: directory already rebuilt: $dir" );
@@ -228,6 +232,7 @@ function wp_cache_get_response_headers() {
228
  'X-Content-Type-Options',
229
  'X-Powered-By',
230
  'X-UA-Compatible',
 
231
  );
232
 
233
  $known_headers = apply_filters( 'wpsc_known_headers', $known_headers );
@@ -365,8 +370,10 @@ function wp_super_cache_query_vars() {
365
  $wp_super_cache_query[ 'is_home' ] = 1;
366
  if ( is_author() )
367
  $wp_super_cache_query[ 'is_author' ] = 1;
368
- if ( is_feed() )
369
  $wp_super_cache_query[ 'is_feed' ] = 1;
 
 
370
  }
371
 
372
  function wp_cache_ob_callback( $buffer ) {
@@ -377,7 +384,15 @@ function wp_cache_ob_callback( $buffer ) {
377
 
378
  // All the things that can stop a page being cached
379
  $cache_this_page = true;
380
- if ( defined( 'DONOTCACHEPAGE' ) ) {
 
 
 
 
 
 
 
 
381
  wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
382
  $cache_this_page = false;
383
  } elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
@@ -532,7 +547,7 @@ function wp_cache_maybe_dynamic( &$buffer ) {
532
 
533
  function wp_cache_get_ob(&$buffer) {
534
  global $cache_enabled, $cache_path, $cache_filename, $wp_start_time, $supercachedir;
535
- global $new_cache, $wp_cache_meta, $cache_compression;
536
  global $wp_cache_gzip_encoding, $super_cache_enabled;
537
  global $wp_cache_404, $gzsize, $supercacheonly;
538
  global $blog_cache_dir, $wp_supercache_cache_list;
@@ -588,7 +603,7 @@ function wp_cache_get_ob(&$buffer) {
588
  return wp_cache_maybe_dynamic( $buffer );
589
  }
590
 
591
- if ( $wp_cache_not_logged_in && is_feed() ) {
592
  wp_cache_debug( "Feed detected. Writing wpcache cache files.", 5 );
593
  $wp_cache_not_logged_in = false;
594
  }
@@ -597,7 +612,7 @@ function wp_cache_get_ob(&$buffer) {
597
 
598
  $dir = get_current_url_supercache_dir();
599
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
600
- if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
601
  wp_cache_debug( "Supercache disabled: GET or feed detected or disabled by config.", 2 );
602
  $super_cache_enabled = false;
603
  }
@@ -645,7 +660,15 @@ function wp_cache_get_ob(&$buffer) {
645
 
646
  if( @is_dir( $dir ) == false )
647
  @wp_mkdir_p( $dir );
648
- $dir = trailingslashit( wpsc_get_realpath( $dir ) );
 
 
 
 
 
 
 
 
649
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
650
  wp_cache_debug( "wp_cache_get_ob: not caching as directory is not in cache_path: $dir" );
651
  return $buffer;
@@ -877,6 +900,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
877
 
878
  // Don't prune a NULL/empty directory.
879
  if ( null === $directory || '' === $directory ) {
 
880
  return false;
881
  }
882
 
@@ -978,6 +1002,11 @@ function wp_cache_rebuild_or_delete( $file ) {
978
 
979
  $file = wpsc_get_realpath( $file );
980
 
 
 
 
 
 
981
  if ( ! wpsc_is_in_cache_directory( $file ) ) {
982
  wp_cache_debug( "rebuild_or_gc quitting because file is not in cache_path: $file" );
983
  return false;
@@ -1067,7 +1096,7 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
1067
  function wp_cache_shutdown_callback() {
1068
  global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
1069
  global $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
1070
- global $WPSC_HTTP_HOST;
1071
 
1072
  if ( false == $new_cache ) {
1073
  wp_cache_debug( "wp_cache_shutdown_callback: No cache file created. Returning." );
@@ -1080,8 +1109,8 @@ function wp_cache_shutdown_callback() {
1080
  $wp_cache_meta[ 'key' ] = $wp_cache_key;
1081
  $wp_cache_meta = apply_filters( 'wp_cache_meta', $wp_cache_meta );
1082
 
1083
- $headers = wp_cache_get_response_headers();
1084
- foreach( $headers as $key => $value ) {
1085
  $wp_cache_meta[ 'headers' ][ $key ] = "$key: $value";
1086
  }
1087
 
@@ -1098,7 +1127,7 @@ function wp_cache_shutdown_callback() {
1098
  // the output buffer. This is a last ditch effort to set the
1099
  // correct Content-Type header for feeds, if we didn't see
1100
  // it in the response headers already. -- dougal
1101
- if (is_feed()) {
1102
  $type = get_query_var('feed');
1103
  $type = str_replace('/','',$type);
1104
  switch ($type) {
@@ -1108,14 +1137,23 @@ function wp_cache_shutdown_callback() {
1108
  case 'rdf':
1109
  $value = "application/rdf+xml";
1110
  break;
1111
- case ( 'sitemap' || 'sitemap_n' ):
1112
  $value = "text/xml";
1113
  break;
1114
  case 'rss':
1115
  case 'rss2':
1116
  default:
1117
- $value = "application/rss+xml";
 
 
 
 
 
1118
  }
 
 
 
 
1119
  } else { // not a feed
1120
  $value = get_option( 'html_type' );
1121
  if( $value == '' )
@@ -1604,4 +1642,9 @@ function wp_cache_gc_watcher() {
1604
  }
1605
  }
1606
 
 
 
 
 
 
1607
  ?>
82
  }
83
 
84
  $dir = wpsc_get_realpath( $dir );
85
+ if ( ! $dir ) {
86
+ wp_cache_debug( "wpcache_do_rebuild: exiting as directory does not exist." );
87
+ return false;
88
+ }
89
 
90
  if ( isset( $do_rebuild_list[ $dir ] ) ) {
91
  wp_cache_debug( "wpcache_do_rebuild: directory already rebuilt: $dir" );
232
  'X-Content-Type-Options',
233
  'X-Powered-By',
234
  'X-UA-Compatible',
235
+ 'X-Robots-Tag',
236
  );
237
 
238
  $known_headers = apply_filters( 'wpsc_known_headers', $known_headers );
370
  $wp_super_cache_query[ 'is_home' ] = 1;
371
  if ( is_author() )
372
  $wp_super_cache_query[ 'is_author' ] = 1;
373
+ if ( is_feed() || get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) )
374
  $wp_super_cache_query[ 'is_feed' ] = 1;
375
+
376
+ return $wp_super_cache_query;
377
  }
378
 
379
  function wp_cache_ob_callback( $buffer ) {
384
 
385
  // All the things that can stop a page being cached
386
  $cache_this_page = true;
387
+
388
+ if ( empty( $wp_super_cache_query ) ) {
389
+ $wp_super_cache_query = wp_super_cache_query_vars();
390
+ }
391
+
392
+ if ( empty( $wp_super_cache_query ) ) {
393
+ $cache_this_page = false;
394
+ wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type.' );
395
+ } elseif ( defined( 'DONOTCACHEPAGE' ) ) {
396
  wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
397
  $cache_this_page = false;
398
  } elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
547
 
548
  function wp_cache_get_ob(&$buffer) {
549
  global $cache_enabled, $cache_path, $cache_filename, $wp_start_time, $supercachedir;
550
+ global $new_cache, $wp_cache_meta, $cache_compression, $wp_super_cache_query;
551
  global $wp_cache_gzip_encoding, $super_cache_enabled;
552
  global $wp_cache_404, $gzsize, $supercacheonly;
553
  global $blog_cache_dir, $wp_supercache_cache_list;
603
  return wp_cache_maybe_dynamic( $buffer );
604
  }
605
 
606
+ if ( $wp_cache_not_logged_in && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
607
  wp_cache_debug( "Feed detected. Writing wpcache cache files.", 5 );
608
  $wp_cache_not_logged_in = false;
609
  }
612
 
613
  $dir = get_current_url_supercache_dir();
614
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
615
+ if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
616
  wp_cache_debug( "Supercache disabled: GET or feed detected or disabled by config.", 2 );
617
  $super_cache_enabled = false;
618
  }
660
 
661
  if( @is_dir( $dir ) == false )
662
  @wp_mkdir_p( $dir );
663
+ $dir = wpsc_get_realpath( $dir );
664
+
665
+ if ( ! $dir ) {
666
+ wp_cache_debug( "wp_cache_get_ob: not caching as directory does not exist." );
667
+ return $buffer;
668
+ }
669
+
670
+ $dir = trailingslashit( $dir );
671
+
672
  if ( ! wpsc_is_in_cache_directory( $dir ) ) {
673
  wp_cache_debug( "wp_cache_get_ob: not caching as directory is not in cache_path: $dir" );
674
  return $buffer;
900
 
901
  // Don't prune a NULL/empty directory.
902
  if ( null === $directory || '' === $directory ) {
903
+ wp_cache_debug( "prune_super_cache: directory is blank" );
904
  return false;
905
  }
906
 
1002
 
1003
  $file = wpsc_get_realpath( $file );
1004
 
1005
+ if ( ! $file ) {
1006
+ wp_cache_debug( "wp_cache_rebuild_or_delete: file doesn't exist" );
1007
+ return false;
1008
+ }
1009
+
1010
  if ( ! wpsc_is_in_cache_directory( $file ) ) {
1011
  wp_cache_debug( "rebuild_or_gc quitting because file is not in cache_path: $file" );
1012
  return false;
1096
  function wp_cache_shutdown_callback() {
1097
  global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
1098
  global $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
1099
+ global $WPSC_HTTP_HOST, $wp_super_cache_query;
1100
 
1101
  if ( false == $new_cache ) {
1102
  wp_cache_debug( "wp_cache_shutdown_callback: No cache file created. Returning." );
1109
  $wp_cache_meta[ 'key' ] = $wp_cache_key;
1110
  $wp_cache_meta = apply_filters( 'wp_cache_meta', $wp_cache_meta );
1111
 
1112
+ $response = wp_cache_get_response_headers();
1113
+ foreach( $response as $key => $value ) {
1114
  $wp_cache_meta[ 'headers' ][ $key ] = "$key: $value";
1115
  }
1116
 
1127
  // the output buffer. This is a last ditch effort to set the
1128
  // correct Content-Type header for feeds, if we didn't see
1129
  // it in the response headers already. -- dougal
1130
+ if ( isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
1131
  $type = get_query_var('feed');
1132
  $type = str_replace('/','',$type);
1133
  switch ($type) {
1137
  case 'rdf':
1138
  $value = "application/rdf+xml";
1139
  break;
1140
+ case 'sitemap':
1141
  $value = "text/xml";
1142
  break;
1143
  case 'rss':
1144
  case 'rss2':
1145
  default:
1146
+ if ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
1147
+ wp_cache_debug( "wp_cache_shutdown_callback: feed sitemap detected: text/xml" );
1148
+ $value = "text/xml";
1149
+ } else {
1150
+ $value = "application/rss+xml";
1151
+ }
1152
  }
1153
+ wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
1154
+ } elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
1155
+ wp_cache_debug( "wp_cache_shutdown_callback: sitemap detected: text/xml" );
1156
+ $value = "text/xml";
1157
  } else { // not a feed
1158
  $value = get_option( 'html_type' );
1159
  if( $value == '' )
1642
  }
1643
  }
1644
 
1645
+ function wpsc_timestamp_cache_update( $type, $permalink ) {
1646
+ wp_cache_setting( 'wpsc_last_post_update', time() );
1647
+ }
1648
+ add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
1649
+
1650
  ?>
wp-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Super Cache
4
  Plugin URI: https://wordpress.org/plugins/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
- Version: 1.5.3
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -42,7 +42,7 @@ function wpsc_init() {
42
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
43
  $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
44
  $wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
45
- } elseif ( WPCACHEHOME != dirname( __FILE__ ) . '/' ) {
46
  $wp_cache_config_file_sample = dirname( __FILE__ ) . '/wp-cache-config-sample.php';
47
  $wp_cache_file = dirname( __FILE__ ) . '/advanced-cache.php';
48
  if ( ! defined( 'ADVANCEDCACHEPROBLEM' ) ) {
@@ -137,8 +137,6 @@ function wpsupercache_uninstall() {
137
  if ( !function_exists( 'prune_super_cache' ) )
138
  include_once( 'wp-cache-phase2.php' );
139
 
140
- prune_super_cache( $cache_path, true );
141
-
142
  wp_cache_remove_index();
143
 
144
  if ( null !== $cache_path && '' !== $cache_path ) {
@@ -524,8 +522,7 @@ function wp_cache_manager_updates() {
524
  }
525
 
526
  if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
527
- if( isset( $_POST[ 'wp_cache_location' ] ) && $_POST[ 'wp_cache_location' ] != '' &&
528
- ( !isset( $cache_path ) || $_POST[ 'wp_cache_location' ] != $cache_path ) ) {
529
  $dir = realpath( trailingslashit( dirname( $_POST[ 'wp_cache_location' ] ) ) );
530
  if ( $dir == false )
531
  $dir = WP_CONTENT_DIR . '/cache/';
@@ -823,6 +820,52 @@ table.wpsc-settings-table {
823
  $_GET[ 'tab' ] = 'easy';
824
  }
825
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
826
  wpsc_admin_tabs();
827
 
828
  if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
@@ -869,20 +912,6 @@ table.wpsc-settings-table {
869
  wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
870
  echo '<a name="preload"></a>';
871
  if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
872
- global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
873
- $posts_count = wp_count_posts();
874
- $count = $posts_count->publish;
875
- if ( $count > 1000 ) {
876
- $min_refresh_interval = 720;
877
- } else {
878
- $min_refresh_interval = 30;
879
- }
880
- $return = wpsc_preload_settings( $min_refresh_interval );
881
- if ( empty( $return ) == false ) {
882
- foreach( $return as $message ) {
883
- echo $message;
884
- }
885
- }
886
  echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
887
  echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
888
  echo '<p>' . __( 'In &#8217;Preload Mode&#8217; regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
@@ -936,25 +965,9 @@ table.wpsc-settings-table {
936
  echo '<option value="less" '. selected( 'less', $wp_cache_preload_email_volume ) . '>'. __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '</option>';
937
  echo "</select>";
938
 
939
- $currently_preloading = false;
940
-
941
- next_preload_message( 'wp_cache_preload_hook', __( 'Refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ), 60 );
942
- next_preload_message( 'wp_cache_full_preload_hook', __( 'Full refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ) );
943
-
944
  if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
945
  $currently_preloading = true;
946
  }
947
- $preload_counter = get_option( 'preload_cache_counter' );
948
- if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array
949
- update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) );
950
- if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) {
951
- echo '<p><strong>' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '</strong></p>';
952
- $currently_preloading = true;
953
- if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) {
954
- $url = file_get_contents( $cache_path . "preload_permalink.txt" );
955
- echo "<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
956
- }
957
- }
958
  echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" />';
959
  echo '</div>';
960
  wp_nonce_field('wp-cache');
@@ -1366,7 +1379,7 @@ function wsc_mod_rewrite() {
1366
  <p><?php _e( 'When Expert cache delivery is enabled a file called <em>.htaccess</em> is modified. It should probably be in the same directory as your wp-config.php. This file has special rules that serve the cached files very quickly to visitors without ever executing PHP. The .htaccess file can be updated automatically, but if that fails, the rules will be displayed here and it can be edited by you. You will not need to update the rules unless a warning shows here.', 'wp-super-cache' ); ?></p>
1367
 
1368
  <?php
1369
- extract( wpsc_get_htaccess_info() );
1370
  $dohtaccess = true;
1371
  if( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
1372
  echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately, you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it&#8217;s backwards compatible with older versions if you&#8217;re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>";
@@ -1988,18 +2001,17 @@ function wpsc_update_debug_settings() {
1988
 
1989
  if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $wp_cache_debug_log != '' ) {
1990
  @unlink( $cache_path . $wp_cache_debug_log );
1991
- extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) );
1992
  } elseif ( isset( $_POST[ 'wp_super_cache_debug' ] ) ) {
1993
- $wp_super_cache_debug = (int) $_POST[ 'wp_super_cache_debug' ];
1994
- wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug );
1995
  if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
1996
- extract( wpsc_create_debug_log() );
 
 
1997
  }
 
 
1998
  }
1999
 
2000
- if ( false == isset( $wp_super_cache_comments ) )
2001
- $wp_super_cache_comments = 1;
2002
-
2003
  if ( isset( $_POST[ 'wp_cache_debug' ] ) ) {
2004
  wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
2005
  wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
@@ -2040,13 +2052,13 @@ function wp_cache_debug_settings() {
2040
  global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug;
2041
  global $wp_cache_debug_username;
2042
 
2043
- extract( wpsc_update_debug_settings() );
2044
 
2045
  echo '<a name="debug"></a>';
2046
  echo '<fieldset class="options">';
2047
  echo '<p>' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '</p>';
2048
  if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
2049
- extract( wpsc_create_debug_log() );
2050
  }
2051
  $log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}{$wp_cache_debug_log}" ) ) . "'>$wp_cache_debug_log</a>";
2052
  if ( $wp_super_cache_debug == 1 ) {
@@ -2477,8 +2489,8 @@ function wp_cache_create_advanced_cache() {
2477
 
2478
  $line = 'define( \'WPCACHEHOME\', \'' . dirname( __FILE__ ) . '/\' );';
2479
  if ( !is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\( *\'WPCACHEHOME\'', $line, $global_config_file ) ) {
2480
- echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h3>";
2481
- return false;
2482
  }
2483
  $ret = true;
2484
 
@@ -2514,11 +2526,12 @@ function wp_cache_check_link() {
2514
 
2515
  if( false == $ret ) {
2516
  echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( '%s/advanced-cache.php</em> does not exist or cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</h3>";
2517
- echo "<p><ul><li>" . __( '1. If it already exists, please delete the file first.', 'wp-super-cache' ) . "</li>";
2518
- echo "<li>" . sprintf( __( '2. Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you&#8217;ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li>";
2519
- echo "<li>" . sprintf( __( '3. Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ul>";
2520
  echo sprintf( __( 'If that doesn&#8217;t work, make sure the file <em>%s/advanced-cache.php</em> doesn&#8217;t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "<ol>";
2521
- printf( __( '<li>1. Open <em>%1$s$wp_cache_file</em> in a text editor.</li><li>2. Change the text <em>CACHEHOME</em> to <em>%2$s</em></li><li>3. Save the file and copy it to <em>%3$s</em> and refresh this page.</li>', 'wp-super-cache' ), $wp_cache_file, WPCACHEHOME, $wp_cache_link );
 
2522
  echo "</div>";
2523
  return false;
2524
  }
@@ -2581,7 +2594,7 @@ function wp_cache_format_fsize( $fsize ) {
2581
  }
2582
 
2583
  function wp_cache_regenerate_cache_file_stats() {
2584
- global $supercachedir, $file_prefix, $wp_cache_preload_on, $cache_max_time;
2585
 
2586
  if ( $supercachedir == '' )
2587
  $supercachedir = get_supercache_dir();
@@ -2610,6 +2623,10 @@ function wp_cache_regenerate_cache_file_stats() {
2610
  $sizes[ $cache_type ][ $status ] = $cached_list;
2611
  }
2612
  }
 
 
 
 
2613
  $cache_stats = array( 'generated' => time(), 'supercache' => $sizes[ 'supercache' ], 'wpcache' => $sizes[ 'wpcache' ] );
2614
  update_option( 'supercache_stats', $cache_stats );
2615
  return $cache_stats;
@@ -2739,19 +2756,18 @@ function wp_cache_files() {
2739
  echo "<p><strong>" . __( 'WP-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
2740
  echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'cached' ] ) . "</li>";
2741
  echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'expired' ] ) . "</li></ul>";
2742
- $divisor = $cache_compression == 1 ? 2 : 1;
2743
  if ( array_key_exists('fsize', (array)$cache_stats[ 'supercache' ]) )
2744
  $fsize = $cache_stats[ 'supercache' ][ 'fsize' ] / 1024;
2745
  else
2746
  $fsize = 0;
2747
  $fsize = wp_cache_format_fsize( $fsize );
2748
  echo "<p><strong>" . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
2749
- echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'cached' ] / $divisor ) ) . "</li>";
2750
  if ( isset( $now ) && isset( $cache_stats ) )
2751
  $age = intval( ( $now - $cache_stats['generated'] ) / 60 );
2752
  else
2753
  $age = 0;
2754
- echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), intval( $cache_stats[ 'supercache' ][ 'expired' ] / $divisor ) ) . "</li></ul>";
2755
  if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) {
2756
  echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>";
2757
  $cache_description = array( 'supercache' => __( 'Super Cached Files', 'wp-super-cache' ), 'wpcache' => __( 'Full Cache Files', 'wp-super-cache' ) );
@@ -2783,7 +2799,7 @@ function wp_cache_files() {
2783
  }
2784
  echo "</div>";
2785
  echo "<p><a href='?page=wpsupercache&tab=contents#top'>" . __( 'Hide file list', 'wp-super-cache' ) . "</a></p>";
2786
- } elseif ( $cache_stats[ 'supercache' ][ 'cached' ] > 500 || $cache_stats[ 'supercache' ][ 'expired' ] > 500 || ( $cache_stats[ 'wpcache' ][ 'cached' ] / $divisor ) > 500 || ( $cache_stats[ 'wpcache' ][ 'expired' ] / $divisor) > 500 ) {
2787
  echo "<p><em>" . __( 'Too many cached files, no listing possible.', 'wp-super-cache' ) . "</em></p>";
2788
  } else {
2789
  echo "<p><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "</a></p>";
@@ -3160,7 +3176,7 @@ function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $
3160
  }
3161
 
3162
  function wpsc_update_htaccess() {
3163
- extract( wpsc_get_htaccess_info() );
3164
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
3165
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
3166
  return true;
@@ -3172,7 +3188,7 @@ function wpsc_update_htaccess() {
3172
  function wpsc_update_htaccess_form( $short_form = true ) {
3173
  global $wpmu_version;
3174
 
3175
- extract( wpsc_get_htaccess_info() );
3176
  if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
3177
  echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
3178
  echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>";
@@ -3445,10 +3461,8 @@ function wp_cron_preload_cache() {
3445
  }
3446
 
3447
  if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) {
3448
- $types = get_post_types( array( 'public' => true, 'publicly_queryable' => true ), 'names', 'or' );
3449
- $types = array_map( 'esc_sql', $types );
3450
- $types = "'" . implode( "','", $types ) . "'";
3451
- $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE ( post_type IN ( $types ) ) AND post_status = 'publish' ORDER BY ID DESC LIMIT $c, 100" );
3452
  wp_cache_debug( "wp_cron_preload_cache: got 100 posts from position $c.", 5 );
3453
  } else {
3454
  wp_cache_debug( "wp_cron_preload_cache: no more posts to get. Limit ($wp_cache_preload_posts) reached.", 5 );
@@ -3539,7 +3553,7 @@ function next_preload_message( $hook, $text, $limit = 0 ) {
3539
  $h = (int)($m / 60); $m = $m % 60;
3540
  }
3541
  if ( $next_time > 0 && $next_time < ( 60 * $wp_cache_preload_interval ) )
3542
- echo '<p><strong>' . sprintf( $text, $h, $m, $s ) . '</strong></p>';
3543
  if ( ( $next_preload - time() ) <= 60 )
3544
  $currently_preloading = true;
3545
  }
@@ -3603,7 +3617,7 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
3603
  $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>";
3604
  wp_die( $msg );
3605
  }
3606
- extract( wpsc_get_htaccess_info() );
3607
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
3608
  $wp_rewrite->flush_rules();
3609
  } elseif( $scrules != '' ) {
@@ -3677,6 +3691,30 @@ function wpsc_enable_preload() {
3677
  wp_schedule_single_event( time() + 10, 'wp_cache_full_preload_hook' );
3678
  }
3679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3680
  function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
3681
  global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
3682
 
@@ -3695,8 +3733,7 @@ function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
3695
  }
3696
 
3697
  if ( $min_refresh_interval == 'NA' ) {
3698
- $posts_count = wp_count_posts();
3699
- $count = $posts_count->publish;
3700
  if ( $count > 1000 ) {
3701
  $min_refresh_interval = 720;
3702
  } else {
3
  Plugin Name: WP Super Cache
4
  Plugin URI: https://wordpress.org/plugins/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
+ Version: 1.5.4
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
42
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
43
  $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
44
  $wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
45
+ } elseif ( realpath( WPCACHEHOME ) != realpath( dirname( __FILE__ ) ) ) {
46
  $wp_cache_config_file_sample = dirname( __FILE__ ) . '/wp-cache-config-sample.php';
47
  $wp_cache_file = dirname( __FILE__ ) . '/advanced-cache.php';
48
  if ( ! defined( 'ADVANCEDCACHEPROBLEM' ) ) {
137
  if ( !function_exists( 'prune_super_cache' ) )
138
  include_once( 'wp-cache-phase2.php' );
139
 
 
 
140
  wp_cache_remove_index();
141
 
142
  if ( null !== $cache_path && '' !== $cache_path ) {
522
  }
523
 
524
  if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
525
+ if( isset( $_POST[ 'wp_cache_location' ] ) && $_POST[ 'wp_cache_location' ] != '' ) {
 
526
  $dir = realpath( trailingslashit( dirname( $_POST[ 'wp_cache_location' ] ) ) );
527
  if ( $dir == false )
528
  $dir = WP_CONTENT_DIR . '/cache/';
820
  $_GET[ 'tab' ] = 'easy';
821
  }
822
 
823
+ if ( $_GET[ 'tab' ] == 'preload' ) {
824
+ if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
825
+ global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
826
+ $count = wpsc_post_count();
827
+ if ( $count > 1000 ) {
828
+ $min_refresh_interval = 720;
829
+ } else {
830
+ $min_refresh_interval = 30;
831
+ }
832
+ $return = wpsc_preload_settings( $min_refresh_interval );
833
+ $msg = '';
834
+ if ( empty( $return ) == false ) {
835
+ foreach( $return as $message ) {
836
+ $msg .= $message;
837
+ }
838
+ }
839
+ $currently_preloading = false;
840
+
841
+ $preload_counter = get_option( 'preload_cache_counter' );
842
+ if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array
843
+ update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) );
844
+ if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) {
845
+ $msg .= '<p>' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '</p>';
846
+ $currently_preloading = true;
847
+ if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) {
848
+ $url = file_get_contents( $cache_path . "preload_permalink.txt" );
849
+ $msg .="<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
850
+ }
851
+ if ( $msg != '' ) {
852
+ echo '<div class="notice notice-warning"><h3>' . __( 'Preload Active', 'wp-super-cache' ) . '</h3>' . $msg;
853
+ echo '<form name="do_preload" action="" method="POST">';
854
+ echo '<input type="hidden" name="action" value="preload" />';
855
+ echo '<input type="hidden" name="page" value="wpsupercache" />';
856
+ echo '<p><input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" /></p>';
857
+ wp_nonce_field('wp-cache');
858
+ echo '</form>';
859
+ echo '</div>';
860
+ }
861
+ }
862
+ next_preload_message( 'wp_cache_preload_hook', __( 'Refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ), 60 );
863
+ next_preload_message( 'wp_cache_full_preload_hook', __( 'Full refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ) );
864
+
865
+ }
866
+ }
867
+
868
+
869
  wpsc_admin_tabs();
870
 
871
  if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
912
  wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
913
  echo '<a name="preload"></a>';
914
  if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
915
  echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
916
  echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
917
  echo '<p>' . __( 'In &#8217;Preload Mode&#8217; regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
965
  echo '<option value="less" '. selected( 'less', $wp_cache_preload_email_volume ) . '>'. __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '</option>';
966
  echo "</select>";
967
 
 
 
 
 
 
968
  if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
969
  $currently_preloading = true;
970
  }
 
 
 
 
 
 
 
 
 
 
 
971
  echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Update Settings', 'wp-super-cache' ) . '" />';
972
  echo '</div>';
973
  wp_nonce_field('wp-cache');
1379
  <p><?php _e( 'When Expert cache delivery is enabled a file called <em>.htaccess</em> is modified. It should probably be in the same directory as your wp-config.php. This file has special rules that serve the cached files very quickly to visitors without ever executing PHP. The .htaccess file can be updated automatically, but if that fails, the rules will be displayed here and it can be edited by you. You will not need to update the rules unless a warning shows here.', 'wp-super-cache' ); ?></p>
1380
 
1381
  <?php
1382
+ extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
1383
  $dohtaccess = true;
1384
  if( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
1385
  echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately, you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it&#8217;s backwards compatible with older versions if you&#8217;re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>";
2001
 
2002
  if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $wp_cache_debug_log != '' ) {
2003
  @unlink( $cache_path . $wp_cache_debug_log );
2004
+ extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
2005
  } elseif ( isset( $_POST[ 'wp_super_cache_debug' ] ) ) {
 
 
2006
  if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
2007
+ extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
2008
+ } elseif ( ! file_exists( $cache_path . $wp_cache_debug_log ) ) { // make sure debug log exists before toggling debugging
2009
+ extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
2010
  }
2011
+ $wp_super_cache_debug = (int) $_POST[ 'wp_super_cache_debug' ];
2012
+ wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug );
2013
  }
2014
 
 
 
 
2015
  if ( isset( $_POST[ 'wp_cache_debug' ] ) ) {
2016
  wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
2017
  wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
2052
  global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug;
2053
  global $wp_cache_debug_username;
2054
 
2055
+ extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
2056
 
2057
  echo '<a name="debug"></a>';
2058
  echo '<fieldset class="options">';
2059
  echo '<p>' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '</p>';
2060
  if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
2061
+ extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
2062
  }
2063
  $log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}{$wp_cache_debug_log}" ) ) . "'>$wp_cache_debug_log</a>";
2064
  if ( $wp_super_cache_debug == 1 ) {
2489
 
2490
  $line = 'define( \'WPCACHEHOME\', \'' . dirname( __FILE__ ) . '/\' );';
2491
  if ( !is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\( *\'WPCACHEHOME\'', $line, $global_config_file ) ) {
2492
+ echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h3></div>";
2493
+ return false;
2494
  }
2495
  $ret = true;
2496
 
2526
 
2527
  if( false == $ret ) {
2528
  echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( '%s/advanced-cache.php</em> does not exist or cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</h3>";
2529
+ echo "<p><ol><li>" . __( 'If it already exists, please delete the file first.', 'wp-super-cache' ) . "</li>";
2530
+ echo "<li>" . sprintf( __( 'Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you&#8217;ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li>";
2531
+ echo "<li>" . sprintf( __( 'Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ol>";
2532
  echo sprintf( __( 'If that doesn&#8217;t work, make sure the file <em>%s/advanced-cache.php</em> doesn&#8217;t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "<ol>";
2533
+ printf( __( '<li>Open <em>%1$s</em> in a text editor.</li><li>Change the text <em>CACHEHOME</em> to <em>%2$s</em></li><li> Save the file and copy it to <em>%3$s</em> and refresh this page.</li>', 'wp-super-cache' ), $wp_cache_file, WPCACHEHOME, $wp_cache_link );
2534
+ echo "</ol>";
2535
  echo "</div>";
2536
  return false;
2537
  }
2594
  }
2595
 
2596
  function wp_cache_regenerate_cache_file_stats() {
2597
+ global $cache_compression, $supercachedir, $file_prefix, $wp_cache_preload_on, $cache_max_time;
2598
 
2599
  if ( $supercachedir == '' )
2600
  $supercachedir = get_supercache_dir();
2623
  $sizes[ $cache_type ][ $status ] = $cached_list;
2624
  }
2625
  }
2626
+ if ( $cache_compression ) {
2627
+ $sizes[ 'supercache' ][ 'cached' ] = intval( $sizes[ 'supercache' ][ 'cached' ] / 2 );
2628
+ $sizes[ 'supercache' ][ 'expired' ] = intval( $sizes[ 'supercache' ][ 'expired' ] / 2 );
2629
+ }
2630
  $cache_stats = array( 'generated' => time(), 'supercache' => $sizes[ 'supercache' ], 'wpcache' => $sizes[ 'wpcache' ] );
2631
  update_option( 'supercache_stats', $cache_stats );
2632
  return $cache_stats;
2756
  echo "<p><strong>" . __( 'WP-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
2757
  echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'cached' ] ) . "</li>";
2758
  echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'expired' ] ) . "</li></ul>";
 
2759
  if ( array_key_exists('fsize', (array)$cache_stats[ 'supercache' ]) )
2760
  $fsize = $cache_stats[ 'supercache' ][ 'fsize' ] / 1024;
2761
  else
2762
  $fsize = 0;
2763
  $fsize = wp_cache_format_fsize( $fsize );
2764
  echo "<p><strong>" . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
2765
+ echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'supercache' ][ 'cached' ] ) . "</li>";
2766
  if ( isset( $now ) && isset( $cache_stats ) )
2767
  $age = intval( ( $now - $cache_stats['generated'] ) / 60 );
2768
  else
2769
  $age = 0;
2770
+ echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'supercache' ][ 'expired' ] ) . "</li></ul>";
2771
  if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) {
2772
  echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>";
2773
  $cache_description = array( 'supercache' => __( 'Super Cached Files', 'wp-super-cache' ), 'wpcache' => __( 'Full Cache Files', 'wp-super-cache' ) );
2799
  }
2800
  echo "</div>";
2801
  echo "<p><a href='?page=wpsupercache&tab=contents#top'>" . __( 'Hide file list', 'wp-super-cache' ) . "</a></p>";
2802
+ } elseif ( $cache_stats[ 'supercache' ][ 'cached' ] > 500 || $cache_stats[ 'supercache' ][ 'expired' ] > 500 || $cache_stats[ 'wpcache' ][ 'cached' ] > 500 || $cache_stats[ 'wpcache' ][ 'expired' ] > 500 ) {
2803
  echo "<p><em>" . __( 'Too many cached files, no listing possible.', 'wp-super-cache' ) . "</em></p>";
2804
  } else {
2805
  echo "<p><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "</a></p>";
3176
  }
3177
 
3178
  function wpsc_update_htaccess() {
3179
+ extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3180
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
3181
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
3182
  return true;
3188
  function wpsc_update_htaccess_form( $short_form = true ) {
3189
  global $wpmu_version;
3190
 
3191
+ extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3192
  if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
3193
  echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
3194
  echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>";
3461
  }
3462
 
3463
  if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) {
3464
+ $types = wpsc_get_post_types();
3465
+ $posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE ( post_type IN ( $types ) ) AND post_status = 'publish' ORDER BY ID DESC LIMIT %d, 100", $c ) );
 
 
3466
  wp_cache_debug( "wp_cron_preload_cache: got 100 posts from position $c.", 5 );
3467
  } else {
3468
  wp_cache_debug( "wp_cron_preload_cache: no more posts to get. Limit ($wp_cache_preload_posts) reached.", 5 );
3553
  $h = (int)($m / 60); $m = $m % 60;
3554
  }
3555
  if ( $next_time > 0 && $next_time < ( 60 * $wp_cache_preload_interval ) )
3556
+ echo '<div class="notice notice-warning"><p>' . sprintf( $text, $h, $m, $s ) . '</p></div>';
3557
  if ( ( $next_preload - time() ) <= 60 )
3558
  $currently_preloading = true;
3559
  }
3617
  $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>";
3618
  wp_die( $msg );
3619
  }
3620
+ extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3621
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
3622
  $wp_rewrite->flush_rules();
3623
  } elseif( $scrules != '' ) {
3691
  wp_schedule_single_event( time() + 10, 'wp_cache_full_preload_hook' );
3692
  }
3693
 
3694
+ function wpsc_get_post_types() {
3695
+
3696
+ $preload_type_args = apply_filters( 'wpsc_preload_post_types_args', array(
3697
+ 'public' => true,
3698
+ 'publicly_queryable' => true
3699
+ ) );
3700
+
3701
+ $post_types = (array) apply_filters( 'wpsc_preload_post_types', get_post_types( $preload_type_args, 'names', 'or' ));
3702
+
3703
+ return "'" . join( "', '", array_map( 'esc_sql', $post_types ) ) . "'";
3704
+ }
3705
+ function wpsc_post_count() {
3706
+ global $wpdb;
3707
+ static $count;
3708
+
3709
+ if ( isset( $count ) ) {
3710
+ return $count;
3711
+ }
3712
+
3713
+ $post_type_list = wpsc_get_post_types();
3714
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type IN ( $post_type_list ) AND post_status = 'publish'" );
3715
+
3716
+ return $count;
3717
+ }
3718
  function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
3719
  global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
3720
 
3733
  }
3734
 
3735
  if ( $min_refresh_interval == 'NA' ) {
3736
+ $count = wpsc_post_count();
 
3737
  if ( $count > 1000 ) {
3738
  $min_refresh_interval = 720;
3739
  } else {