WP Super Cache - Version 1.5.6

Version Description

  • REST API: Added /plugins endpoint to handle the plugins settings page. (#382)
  • Minor changes to indentaion and spaces to tabs conversion (#371) (#395)
  • Don't set $wp_super_cache_comments here as it's not saved. (#379)
  • realpath() only works on directories. The cache_file wasn't set correctly. (#377)
  • Fix problem deleting cache from admin bar because of realpath() (#381)
  • Use trigger_error() instead of echoing to the screen if a config file isn't writeable. (#394)
  • Added the "wpsc_enable_wp_config_edit" filter to disable editing the wp-config.php (#392)
  • Fix some PHP notices when comments are edited/published/maintained. (#386)
  • Minor changes to description on plugins page. (#393)
Download this release

Release Info

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

Code changes from version 1.5.5 to 1.5.6

plugins/awaitingmoderation.php CHANGED
@@ -51,4 +51,15 @@ function wp_supercache_awaitingmoderation_admin() {
51
 
52
  }
53
  add_cacheaction( 'cache_admin_page', 'wp_supercache_awaitingmoderation_admin' );
 
 
 
 
 
 
 
 
 
 
 
54
  ?>
51
 
52
  }
53
  add_cacheaction( 'cache_admin_page', 'wp_supercache_awaitingmoderation_admin' );
54
+
55
+ function wpsc_awaiting_moderation_list( $list ) {
56
+ $list[ 'awaitingmoderation' ] = array(
57
+ 'key' => 'awaitingmoderation',
58
+ 'url' => '',
59
+ 'title' => __( 'Awaiting Moderation', 'wp-super-cache' ),
60
+ 'desc' => __( 'Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache' ),
61
+ );
62
+ return $list;
63
+ }
64
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_awaiting_moderation_list' );
65
  ?>
plugins/badbehaviour.php CHANGED
@@ -85,4 +85,15 @@ function wp_supercache_badbehaviour_admin() {
85
  }
86
  add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
87
 
 
 
 
 
 
 
 
 
 
 
 
88
  ?>
85
  }
86
  add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
87
 
88
+ function wpsc_badbehaviour_list( $list ) {
89
+ $list[ 'badbehaviour' ] = array(
90
+ 'key' => 'badbehaviour',
91
+ 'url' => 'http://www.bad-behavior.ioerror.us/',
92
+ 'title' => __( 'Bad Behavior', 'wp-super-cache' ),
93
+ 'desc' => sprintf( __( 'Support for Bad Behavior. (Only WPCache caching supported, disabled compression and requires Bad Behavior in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ),
94
+ );
95
+ return $list;
96
+ }
97
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_badbehaviour_list' );
98
+
99
  ?>
plugins/domain-mapping.php CHANGED
@@ -109,4 +109,16 @@ function wp_supercache_domain_mapping_exists() {
109
  if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
110
  add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
112
  ?>
109
  if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
110
  add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
111
  }
112
+
113
+ function wpsc_domain_mapping_list( $list ) {
114
+ $list[ 'domain_mapping' ] = array(
115
+ 'key' => 'domain_mapping',
116
+ 'url' => 'http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/',
117
+ 'title' => __( 'Domain Mapping', 'wp-super-cache' ),
118
+ 'desc' => __( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
119
+ );
120
+ return $list;
121
+ }
122
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_domain_mapping_list' );
123
+
124
  ?>
plugins/jetpack.php CHANGED
@@ -75,4 +75,16 @@ function wp_super_cache_jetpack_cookie_check( $cache_key ) {
75
  if ( isset( $cache_jetpack ) && $cache_jetpack == 1 ) {
76
  add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check' );
77
  }
 
 
 
 
 
 
 
 
 
 
 
 
78
  ?>
75
  if ( isset( $cache_jetpack ) && $cache_jetpack == 1 ) {
76
  add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check' );
77
  }
78
+
79
+ function wpsc_cache_jetpack_list( $list ) {
80
+ $list[ 'jetpack' ] = array(
81
+ 'key' => 'jetpack',
82
+ 'url' => 'http://wordpress.org/extend/plugins/jetpack/',
83
+ 'title' => __( 'Jetpack Mobile Theme', 'wp-super-cache' ),
84
+ 'desc' => __( 'Provides support for the Jetpack mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache' ),
85
+ );
86
+ return $list;
87
+ }
88
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_cache_jetpack_list' );
89
+
90
  ?>
plugins/searchengine.php CHANGED
@@ -2,7 +2,8 @@
2
  function wp_supercache_searchengine( $string ) {
3
  global $passingthrough, $nevershowads, $cache_no_adverts_for_friends;
4
 
5
- if( $cache_no_adverts_for_friends != 'yes' && $cache_no_adverts_for_friends != '1' )
 
6
  return $string;
7
 
8
  if( $string != '' )
@@ -43,39 +44,67 @@ function searchenginesupercache( $user_info ) {
43
  }
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  function searchengine_phase2_actions() {
47
  global $cache_no_adverts_for_friends;
48
- if( $cache_no_adverts_for_friends == 'yes' ) {
 
 
49
  add_filter( 'do_createsupercache', 'searchenginesupercache' );
50
  }
51
  }
52
  add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
53
 
54
  function wp_supercache_searchengine_admin() {
55
- global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
56
 
57
- $cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
58
 
59
  if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
60
- $cache_no_adverts_for_friends = $_POST['cache_no_adverts_for_friends'] == __( 'Disable', 'wp-super-cache' ) ? 'no' : 'yes';
61
- wp_cache_replace_line('^ *\$cache_no_adverts_for_friends', "\$cache_no_adverts_for_friends = '$cache_no_adverts_for_friends';", $wp_cache_config_file);
 
 
 
 
 
62
  }
63
- $id = 'no_adverts_for_friends-section';
64
  ?>
65
- <fieldset id="<?php echo $id; ?>" class="options">
66
  <h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
67
  <form name="wp_manager" action="" method="post">
68
- <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>
69
- <label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php if( $cache_no_adverts_for_friends == 'no' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
70
- <p><?php _e( '', 'wp-super-cache' ); ?></p><?php
71
- echo '<p>' . __( 'Provides support for <a href="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache' ) . '</p>';
72
- if ( isset( $changed ) && $changed ) {
73
- if ( 'yes' == $cache_no_adverts_for_friends )
74
- $status = __( "enabled", 'wp-super-cache' );
75
- else
76
- $status = __( "disabled", 'wp-super-cache' );
77
- echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
78
- }
79
  echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
80
  wp_nonce_field('wp-cache');
81
  ?>
@@ -86,4 +115,15 @@ function wp_supercache_searchengine_admin() {
86
  }
87
  add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
88
 
 
 
 
 
 
 
 
 
 
 
 
89
  ?>
2
  function wp_supercache_searchengine( $string ) {
3
  global $passingthrough, $nevershowads, $cache_no_adverts_for_friends;
4
 
5
+ $cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
6
+ if ( ! $cache_no_adverts_for_friends )
7
  return $string;
8
 
9
  if( $string != '' )
44
  }
45
  }
46
 
47
+ function wpsc_get_searchengine_setting() {
48
+ global $cache_no_adverts_for_friends;
49
+
50
+ if ( ! isset( $cache_no_adverts_for_friends ) ) {
51
+ return 0;
52
+ }
53
+
54
+ $changed = false;
55
+ if ( $cache_no_adverts_for_friends === 'yes' || $cache_no_adverts_for_friends === '1' ) {
56
+ $cache_no_adverts_for_friends = 1;
57
+ $changed = true;
58
+ } elseif ( $cache_no_adverts_for_friends === 'no' ) {
59
+ $cache_no_adverts_for_friends = 0;
60
+ $changed = true;
61
+ }
62
+ if ( $changed ) {
63
+ wp_cache_setting( 'cache_no_adverts_for_friends', $cache_no_adverts_for_friends );
64
+ }
65
+
66
+ return $cache_no_adverts_for_friends;
67
+ }
68
+
69
  function searchengine_phase2_actions() {
70
  global $cache_no_adverts_for_friends;
71
+
72
+ $cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
73
+ if ( $cache_no_adverts_for_friends ) {
74
  add_filter( 'do_createsupercache', 'searchenginesupercache' );
75
  }
76
  }
77
  add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
78
 
79
  function wp_supercache_searchengine_admin() {
80
+ global $cache_no_adverts_for_friends, $valid_nonce;
81
 
82
+ $cache_no_adverts_for_friends = wpsc_get_searchengine_setting();
83
 
84
  if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
85
+ if ( $cache_no_adverts_for_friends != (int)$_POST[ 'cache_no_adverts_for_friends' ] ) {
86
+ $changed = 1;
87
+ } else {
88
+ $changed = 0;
89
+ }
90
+ $cache_no_adverts_for_friends = (int)$_POST[ 'cache_no_adverts_for_friends' ];
91
+ wp_cache_setting( 'cache_no_adverts_for_friends', $cache_no_adverts_for_friends );
92
  }
 
93
  ?>
94
+ <fieldset id="no_adverts_for_friends-section" class="options">
95
  <h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
96
  <form name="wp_manager" action="" method="post">
97
+ <label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if ( $cache_no_adverts_for_friends ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
98
+ <label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php if ( ! $cache_no_adverts_for_friends ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
99
+ <?php
100
+ echo '<p>' . __( 'Provides support for <a href="https://odd.blog/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache' ) . '</p>';
101
+ if ( isset( $changed ) && $changed ) {
102
+ if ( $cache_no_adverts_for_friends )
103
+ $status = __( "enabled", 'wp-super-cache' );
104
+ else
105
+ $status = __( "disabled", 'wp-super-cache' );
106
+ echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
107
+ }
108
  echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
109
  wp_nonce_field('wp-cache');
110
  ?>
115
  }
116
  add_cacheaction( 'cache_admin_page', 'wp_supercache_searchengine_admin' );
117
 
118
+ function wpsc_cache_no_adverts_for_friends_list( $list ) {
119
+ $list[ 'no_adverts_for_friends' ] = array(
120
+ 'key' => 'no_adverts_for_friends',
121
+ 'url' => 'https://odd.blog/no-adverts-for-friends/',
122
+ 'title' => __( 'No Adverts for Friends', 'wp-super-cache' ),
123
+ 'desc' => __( 'Provides support for No Adverts for Friends plugin.', 'wp-super-cache' ),
124
+ );
125
+ return $list;
126
+ }
127
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_cache_no_adverts_for_friends_list' );
128
+
129
  ?>
plugins/wptouch.php CHANGED
@@ -119,4 +119,16 @@ if ( isset( $cache_wptouch ) && $cache_wptouch == 1 ) {
119
  add_cacheaction( 'wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes' );
120
  add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check' );
121
  }
 
 
 
 
 
 
 
 
 
 
 
 
122
  ?>
119
  add_cacheaction( 'wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes' );
120
  add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check' );
121
  }
122
+
123
+ function wpsc_wptouch_list( $list ) {
124
+ $list[ 'wptouch' ] = array(
125
+ 'key' => 'wptouch',
126
+ 'url' => 'http://wordpress.org/extend/plugins/wptouch/',
127
+ 'title' => __( 'WPTouch', 'wp-super-cache' ),
128
+ 'desc' => __( 'Provides support for WPTouch mobile theme and plugin.', 'wp-super-cache' ),
129
+ );
130
+ return $list;
131
+ }
132
+ add_cacheaction( 'wpsc_filter_list', 'wpsc_wptouch_list' );
133
+
134
  ?>
readme.txt CHANGED
@@ -2,7 +2,7 @@
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.5
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -53,9 +53,20 @@ 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
- Fix for older versions of WordPress, catch fatal errors before they're cached, preload fixes.
57
 
58
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
59
  = 1.5.5 =
60
  * Catch fatal errors so they're not cached, improve code that catches unknown page types. (#367)
61
  * Fix caching on older WP installs, and if the plugin is inactive on a blog, but still caching, give feeds a short TTL to ensure they're fresh. (#366)
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.6
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
+ Maintenance release and added /plugins REST API endpoint.
57
 
58
  == Changelog ==
59
+ = 1.5.6 =
60
+ * REST API: Added /plugins endpoint to handle the plugins settings page. (#382)
61
+ * Minor changes to indentaion and spaces to tabs conversion (#371) (#395)
62
+ * Don't set $wp_super_cache_comments here as it's not saved. (#379)
63
+ * realpath() only works on directories. The cache_file wasn't set correctly. (#377)
64
+ * Fix problem deleting cache from admin bar because of realpath() (#381)
65
+ * Use trigger_error() instead of echoing to the screen if a config file isn't writeable. (#394)
66
+ * Added the "wpsc_enable_wp_config_edit" filter to disable editing the wp-config.php (#392)
67
+ * Fix some PHP notices when comments are edited/published/maintained. (#386)
68
+ * Minor changes to description on plugins page. (#393)
69
+
70
  = 1.5.5 =
71
  * Catch fatal errors so they're not cached, improve code that catches unknown page types. (#367)
72
  * Fix caching on older WP installs, and if the plugin is inactive on a blog, but still caching, give feeds a short TTL to ensure they're fresh. (#366)
rest/class.wp-super-cache-rest-get-plugins.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WP_Super_Cache_Rest_Get_Plugins extends WP_REST_Controller {
4
+
5
+ /**
6
+ * GET a list of plugins through the /plugins/ endpoint
7
+ *
8
+ * @param WP_REST_Request $request Full data about the request.
9
+ * @return WP_Error|WP_REST_Response
10
+ */
11
+ public function callback( $request ) {
12
+
13
+ $list = wpsc_get_plugin_list();
14
+ return rest_ensure_response( $list );
15
+ }
16
+ }
rest/class.wp-super-cache-rest-update-plugins.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WP_Super_Cache_Rest_Update_Plugins extends WP_REST_Controller {
4
+
5
+ /**
6
+ * Toggle plugins on/off through the /plugins/ endpoint
7
+ *
8
+ * @param WP_REST_Request $request Full data about the request.
9
+ * @return WP_Error|WP_REST_Response
10
+ */
11
+ public function callback( $request ) {
12
+ $parameters = $request->get_json_params();
13
+
14
+ global $valid_nonce;
15
+ $valid_nonce = true;
16
+
17
+ wpsc_update_plugin_list( $parameters );
18
+ $list = wpsc_get_plugin_list();
19
+
20
+ return rest_ensure_response( $list );
21
+ }
22
+ }
rest/load.php CHANGED
@@ -8,6 +8,8 @@ require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-status.php'
8
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-test-cache.php' );
9
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-delete-cache.php' );
10
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-preload.php' );
 
 
11
 
12
  class WP_Super_Cache_Router {
13
 
@@ -32,6 +34,8 @@ class WP_Super_Cache_Router {
32
  $delete_cache = new WP_Super_Cache_Rest_Delete_Cache();
33
  $preload_cache = new WP_Super_Cache_Rest_Preload();
34
  $get_status = new WP_Super_Cache_Rest_Get_Status();
 
 
35
 
36
  register_rest_route( $namespace, '/settings', array(
37
  array(
@@ -87,6 +91,21 @@ class WP_Super_Cache_Router {
87
  'permission_callback' => __CLASS__ . '::create_item_permissions_check',
88
  ) );
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
 
92
  /**
8
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-test-cache.php' );
9
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-delete-cache.php' );
10
  require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-preload.php' );
11
+ require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-plugins.php' );
12
+ require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-update-plugins.php' );
13
 
14
  class WP_Super_Cache_Router {
15
 
34
  $delete_cache = new WP_Super_Cache_Rest_Delete_Cache();
35
  $preload_cache = new WP_Super_Cache_Rest_Preload();
36
  $get_status = new WP_Super_Cache_Rest_Get_Status();
37
+ $get_plugins = new WP_Super_Cache_Rest_Get_Plugins();
38
+ $update_plugins = new WP_Super_Cache_Rest_Update_plugins();
39
 
40
  register_rest_route( $namespace, '/settings', array(
41
  array(
91
  'permission_callback' => __CLASS__ . '::create_item_permissions_check',
92
  ) );
93
 
94
+ register_rest_route( $namespace, '/plugins', array(
95
+ array(
96
+ 'methods' => WP_REST_Server::READABLE,
97
+ 'callback' => array( $get_plugins, 'callback' ),
98
+ 'permission_callback' => __CLASS__ . '::get_item_permissions_check',
99
+ 'args' => array(),
100
+ ),
101
+ array(
102
+ 'methods' => WP_REST_Server::CREATABLE,
103
+ 'callback' => array( $update_plugins, 'callback' ),
104
+ 'permission_callback' => __CLASS__ . '::update_item_permissions_check',
105
+ 'args' => array(),
106
+ ),
107
+ ) );
108
+
109
  }
110
 
111
  /**
wp-cache-phase1.php CHANGED
@@ -129,8 +129,8 @@ function wp_super_cache_init() {
129
 
130
  $cache_filename = $file_prefix . $key . '.php';
131
  $meta_file = $file_prefix . $key . '.php';
132
- $cache_file = wpsc_get_realpath( $blog_cache_dir . $cache_filename );
133
- $meta_pathname = wpsc_get_realpath( $blog_cache_dir . 'meta/' . $meta_file );
134
  return compact( 'key', 'cache_filename', 'meta_file', 'cache_file', 'meta_pathname' );
135
  }
136
 
@@ -584,7 +584,7 @@ function wp_cache_debug( $message, $level = 1 ) {
584
  return false;
585
 
586
  // Log message: Date URI Message
587
- $log_message = date('H:i:s') . " " . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}\n\r";
588
  // path to the log file in the cache folder
589
  $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log));
590
 
129
 
130
  $cache_filename = $file_prefix . $key . '.php';
131
  $meta_file = $file_prefix . $key . '.php';
132
+ $cache_file = wpsc_get_realpath( $blog_cache_dir ) . '/' . $cache_filename;
133
+ $meta_pathname = wpsc_get_realpath( $blog_cache_dir . 'meta/' ) . '/' . $meta_file;
134
  return compact( 'key', 'cache_filename', 'meta_file', 'cache_file', 'meta_pathname' );
135
  }
136
 
584
  return false;
585
 
586
  // Log message: Date URI Message
587
+ $log_message = date('H:i:s') . " " . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL;
588
  // path to the log file in the cache folder
589
  $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log));
590
 
wp-cache-phase2.php CHANGED
@@ -517,9 +517,9 @@ function wp_cache_append_tag( &$buffer ) {
517
 
518
  $timestamp = gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600)));
519
  if ( $cache_enabled || $super_cache_enabled ) {
520
- $msg = "\n<!-- Cached page generated by WP-Super-Cache on $timestamp -->\n";
521
  } else {
522
- $msg = "\n<!-- Live page served on $timestamp -->\n";
523
  }
524
 
525
  if ( strpos( $buffer, '<html' ) === false ) {
@@ -527,7 +527,7 @@ function wp_cache_append_tag( &$buffer ) {
527
  return false;
528
  }
529
 
530
- $buffer .= $msg;
531
  }
532
 
533
  function wp_cache_add_to_buffer( &$buffer, $text ) {
@@ -606,7 +606,7 @@ function wp_cache_get_ob(&$buffer) {
606
  wp_cache_debug( "robots.txt detected. Not caching.", 2 );
607
  }
608
  }
609
-
610
  if( !$new_cache )
611
  return wp_cache_maybe_dynamic( $buffer );
612
 
@@ -1255,6 +1255,20 @@ function wp_cache_no_postid($id) {
1255
 
1256
  function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
1257
  global $super_cache_enabled, $wp_cache_request_uri;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1258
  $comment = get_comment($comment_id, ARRAY_A);
1259
  if ( $status != 'NA' ) {
1260
  $comment[ 'old_comment_approved' ] = $comment[ 'comment_approved' ];
@@ -1267,7 +1281,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
1267
  define( 'DONOTDELETECACHE', 1 );
1268
  return wp_cache_post_id();
1269
  }
1270
- $postid = $comment['comment_post_ID'];
1271
  // Do nothing if comment is not moderated
1272
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
1273
  if ( !preg_match('/wp-admin\//', $wp_cache_request_uri) ) {
@@ -1297,7 +1311,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
1297
  if ($postid > 0) {
1298
  wp_cache_debug( "Post $postid changed. Update cache.", 4 );
1299
  return wp_cache_post_change( $postid );
1300
- } elseif ( $_GET[ 'delete_all' ] != 'Empty Trash' && $_GET[ 'delete_all2' ] != 'Empty Spam' ) {
1301
  wp_cache_debug( "Unknown post changed. Update cache.", 4 );
1302
  return wp_cache_post_change( wp_cache_post_id() );
1303
  }
@@ -1404,7 +1418,7 @@ function wp_cache_post_edit($post_id) {
1404
 
1405
  function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
1406
  global $wp_cache_object_cache;
1407
-
1408
  if ( $wp_cache_object_cache )
1409
  reset_oc_version();
1410
 
517
 
518
  $timestamp = gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600)));
519
  if ( $cache_enabled || $super_cache_enabled ) {
520
+ $msg = "Cached page generated by WP-Super-Cache on $timestamp";
521
  } else {
522
+ $msg = "Live page served on $timestamp";
523
  }
524
 
525
  if ( strpos( $buffer, '<html' ) === false ) {
527
  return false;
528
  }
529
 
530
+ $buffer .= "\n<!-- $msg -->\n";
531
  }
532
 
533
  function wp_cache_add_to_buffer( &$buffer, $text ) {
606
  wp_cache_debug( "robots.txt detected. Not caching.", 2 );
607
  }
608
  }
609
+
610
  if( !$new_cache )
611
  return wp_cache_maybe_dynamic( $buffer );
612
 
1255
 
1256
  function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
1257
  global $super_cache_enabled, $wp_cache_request_uri;
1258
+
1259
+ if ( defined( 'DONOTDELETECACHE' ) ) {
1260
+ return;
1261
+ }
1262
+
1263
+ // Check is it "Empty Spam" or "Empty Trash"
1264
+ if ( isset( $GLOBALS[ 'pagenow' ] ) && $GLOBALS[ 'pagenow' ] === 'edit-comments.php' &&
1265
+ ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
1266
+ ) {
1267
+ wp_cache_debug( "Delete all SPAM or Trash comments. Don't delete any cache files.", 4 );
1268
+ define( 'DONOTDELETECACHE', 1 );
1269
+ return;
1270
+ }
1271
+
1272
  $comment = get_comment($comment_id, ARRAY_A);
1273
  if ( $status != 'NA' ) {
1274
  $comment[ 'old_comment_approved' ] = $comment[ 'comment_approved' ];
1281
  define( 'DONOTDELETECACHE', 1 );
1282
  return wp_cache_post_id();
1283
  }
1284
+ $postid = isset( $comment[ 'comment_post_ID' ] ) ? (int) $comment[ 'comment_post_ID' ] : 0;
1285
  // Do nothing if comment is not moderated
1286
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
1287
  if ( !preg_match('/wp-admin\//', $wp_cache_request_uri) ) {
1311
  if ($postid > 0) {
1312
  wp_cache_debug( "Post $postid changed. Update cache.", 4 );
1313
  return wp_cache_post_change( $postid );
1314
+ } else {
1315
  wp_cache_debug( "Unknown post changed. Update cache.", 4 );
1316
  return wp_cache_post_change( wp_cache_post_id() );
1317
  }
1418
 
1419
  function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
1420
  global $wp_cache_object_cache;
1421
+
1422
  if ( $wp_cache_object_cache )
1423
  reset_oc_version();
1424
 
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.5
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -455,17 +455,20 @@ function admin_bar_delete_page() {
455
  return false;
456
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) {
457
  $path = realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $_GET[ 'path' ] ) ) ) ) . '/';
458
- if ( $path == '/' )
459
  return false; // Directory not found. Probably not cached.
460
- if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( get_supercache_dir() ) ) != get_supercache_dir() )
 
 
461
  die( "Could not delete directory" );
 
462
  wpsc_delete_files( $path );
463
  wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) );
464
  die();
465
  }
466
  }
467
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' )
468
- add_action( 'admin_init', 'admin_bar_delete_page' );
469
 
470
  function wp_cache_manager_updates() {
471
  global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
@@ -768,18 +771,18 @@ function wp_cache_manager() {
768
  <script type='text/javascript'>
769
  <!--
770
  function toggleLayer( whichLayer ) {
771
- var elem, vis;
772
- if( document.getElementById ) // this is the way the standards work
773
- elem = document.getElementById( whichLayer );
774
- else if( document.all ) // this is the way old msie versions work
775
- elem = document.all[whichLayer];
776
- else if( document.layers ) // this is the way nn4 works
777
- elem = document.layers[whichLayer];
778
- vis = elem.style;
779
- // if the style.display value is blank we try to figure it out here
780
- if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
781
- vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
782
- vis.display = (vis.display==''||vis.display=='block')?'none':'block';
783
  }
784
  // -->
785
  //Clicking header opens fieldset options
@@ -1229,12 +1232,14 @@ table.wpsc-settings-table {
1229
  echo '<input type="hidden" name="action" value="test" />';
1230
  if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) )
1231
  echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
1232
- if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
1233
- echo "<p>" . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . "</p>";
1234
- echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1235
- } else {
1236
- echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1237
- }
 
 
1238
  wp_nonce_field('wp-cache');
1239
  echo '</form>';
1240
  }
@@ -1318,9 +1323,9 @@ table.wpsc-settings-table {
1318
  }
1319
 
1320
  function wpsc_plugins_tab() {
1321
- echo '<p>' . __( 'Cache plugins are PHP scripts that live in a plugins folder inside the wp-super-cache folder. They are loaded when Supercache loads, much sooner than regular WordPress plugins.', 'wp-super-cache' ) . '</p>';
1322
- echo '<p>' . __( 'This is strictly an advanced feature only and knowledge of both PHP and WordPress actions is required to create them.', 'wp-super-cache' ) . '</p>';
1323
- echo '<p>' . __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the plugins you upload to wp-super-cache/plugins/ will be deleted when you upgrade WP Super Cache. You can avoid this by loading the plugins from elsewhere. Set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php and WP Super Cache will look there instead.<br />More info available in the <a href="http://ocaoimh.ie/wp-super-cache-developers/">developer documentation</a>.', 'wp-super-cache' ) . '</p>';
1324
  ob_start();
1325
  if( defined( 'WP_CACHE' ) ) {
1326
  if( function_exists( 'do_cacheaction' ) ) {
@@ -2006,7 +2011,7 @@ function wpsc_update_debug_settings() {
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 );
@@ -2173,7 +2178,7 @@ function wp_cache_is_enabled() {
2173
  }
2174
  $lines = file($wp_cache_config_file);
2175
  foreach($lines as $line) {
2176
- if (preg_match('/^ *\$cache_enabled *= *true *;/', $line))
2177
  return true;
2178
  }
2179
  return false;
@@ -2199,14 +2204,14 @@ function wp_cache_replace_line($old, $new, $my_file) {
2199
  return false;
2200
  }
2201
  if (!is_writeable_ACLSafe($my_file)) {
2202
- echo "Error: file $my_file is not writable.\n";
2203
  return false;
2204
  }
2205
 
2206
  $found = false;
2207
  $lines = file($my_file);
2208
  foreach( (array)$lines as $line ) {
2209
- if ( preg_match("/$old/", $line)) {
2210
  $found = true;
2211
  break;
2212
  }
@@ -2341,7 +2346,7 @@ function wp_cache_logout_all() {
2341
  }
2342
  }
2343
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'wpsclogout' )
2344
- add_action( 'admin_init', 'wp_cache_logout_all' );
2345
 
2346
  function wp_cache_add_index_protection() {
2347
  global $cache_path, $blog_cache_dir;
@@ -2488,6 +2493,12 @@ function wp_cache_create_advanced_cache() {
2488
  }
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;
@@ -2508,7 +2519,7 @@ function wp_cache_create_advanced_cache() {
2508
  function wp_cache_check_link() {
2509
  global $wp_cache_link, $wp_cache_file;
2510
 
2511
- $ret = true;
2512
  if( file_exists($wp_cache_link) ) {
2513
  $file = file_get_contents( $wp_cache_link );
2514
  if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
@@ -3094,13 +3105,13 @@ add_filter( 'favorite_actions', 'wp_cache_favorite_action' );
3094
 
3095
  function wp_cache_plugin_notice( $plugin ) {
3096
  global $cache_enabled;
3097
- if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled && function_exists( "admin_url" ) )
3098
  echo '<td colspan="5" class="plugin-update">' . sprintf( __( 'WP Super Cache must be configured. Go to <a href="%s">the admin page</a> to enable and configure the plugin.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</td>';
3099
  }
3100
  add_action( 'after_plugin_row', 'wp_cache_plugin_notice' );
3101
 
3102
  function wp_cache_plugin_actions( $links, $file ) {
3103
- if( $file == 'wp-super-cache/wp-cache.php' && function_exists( "admin_url" ) ) {
3104
  $settings_link = '<a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">' . __( 'Settings', 'wp-super-cache' ) . '</a>';
3105
  array_unshift( $links, $settings_link ); // before other links
3106
  }
@@ -3110,7 +3121,7 @@ add_filter( 'plugin_action_links', 'wp_cache_plugin_actions', 10, 2 );
3110
 
3111
  function wp_cache_admin_notice() {
3112
  global $cache_enabled, $wp_cache_phase1_loaded;
3113
- if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( "admin_url" ) )
3114
  echo '<div class="notice notice-info"><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>';
3115
 
3116
  if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
@@ -3133,22 +3144,22 @@ function wp_cache_check_site() {
3133
  $front_page = wp_remote_get( site_url(), array('timeout' => 60, 'blocking' => true ) );
3134
  if( is_array( $front_page ) ) {
3135
  // Check for gzipped front page
3136
- if ( $front_page[ 'headers' ][ 'content-type' ] == 'application/x-gzip' ) {
3137
- if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
3138
- wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), home_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
3139
- } else {
3140
- wp_cache_clear_cache( $wpdb->blogid );
3141
- wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
3142
- }
3143
- }
3144
 
3145
  // Check for broken front page
3146
  if ( isset( $wp_super_cache_front_page_text ) && $wp_super_cache_front_page_text != '' && false === strpos( $front_page[ 'body' ], $wp_super_cache_front_page_text ) ) {
3147
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
3148
- wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
3149
- } else {
3150
- wp_cache_clear_cache( $wpdb->blogid );
3151
- wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
3152
  }
3153
  }
3154
  }
@@ -3590,13 +3601,18 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
3590
  } else {
3591
  $global_config_file = dirname(ABSPATH) . '/wp-config.php';
3592
  }
3593
- $line = 'define(\'WP_CACHE\', true);';
3594
- if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', '', $global_config_file ) ) ) {
3595
- wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." );
3596
- }
3597
- $line = 'define( \'WPCACHEHOME\',';
3598
- if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', '', $global_config_file ) ) ) {
3599
- wp_die( "Could not remove WPCACHEHOME define from $global_config_file. Please edit that file and remove the line containing the text 'WPCACHEHOME'. Then refresh this page." );
 
 
 
 
 
3600
  }
3601
 
3602
  uninstall_supercache( WP_CONTENT_DIR . '/cache' );
@@ -3734,8 +3750,8 @@ function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
3734
  } elseif ( isset( $_POST[ 'preload_now' ] ) ) {
3735
  wpsc_enable_preload();
3736
  return $return;
3737
- }
3738
-
3739
  if ( $min_refresh_interval == 'NA' ) {
3740
  $count = wpsc_post_count();
3741
  if ( $count > 1000 ) {
@@ -3802,7 +3818,7 @@ function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
3802
  }
3803
 
3804
  function wpsc_is_preloading() {
3805
- if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
3806
  return true;
3807
  } else {
3808
  return false;
@@ -3967,3 +3983,31 @@ function wpsc_timestamp_cache_update( $type, $permalink ) {
3967
  wp_cache_setting( 'wpsc_last_post_update', time() );
3968
  }
3969
  add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.6
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
455
  return false;
456
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) {
457
  $path = realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $_GET[ 'path' ] ) ) ) ) . '/';
458
+ if ( $path == '/' ) {
459
  return false; // Directory not found. Probably not cached.
460
+ }
461
+ $supercachepath = realpath(get_supercache_dir());
462
+ if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( $supercachepath ) ) != $supercachepath ) {
463
  die( "Could not delete directory" );
464
+ }
465
  wpsc_delete_files( $path );
466
  wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) );
467
  die();
468
  }
469
  }
470
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' )
471
+ add_action( 'admin_init', 'admin_bar_delete_page' );
472
 
473
  function wp_cache_manager_updates() {
474
  global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
771
  <script type='text/javascript'>
772
  <!--
773
  function toggleLayer( whichLayer ) {
774
+ var elem, vis;
775
+ if( document.getElementById ) // this is the way the standards work
776
+ elem = document.getElementById( whichLayer );
777
+ else if( document.all ) // this is the way old msie versions work
778
+ elem = document.all[whichLayer];
779
+ else if( document.layers ) // this is the way nn4 works
780
+ elem = document.layers[whichLayer];
781
+ vis = elem.style;
782
+ // if the style.display value is blank we try to figure it out here
783
+ if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
784
+ vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
785
+ vis.display = (vis.display==''||vis.display=='block')?'none':'block';
786
  }
787
  // -->
788
  //Clicking header opens fieldset options
1232
  echo '<input type="hidden" name="action" value="test" />';
1233
  if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) )
1234
  echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
1235
+
1236
+ if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
1237
+ echo "<p>" . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . "</p>";
1238
+ echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1239
+ } else {
1240
+ echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
1241
+ }
1242
+
1243
  wp_nonce_field('wp-cache');
1244
  echo '</form>';
1245
  }
1323
  }
1324
 
1325
  function wpsc_plugins_tab() {
1326
+ echo '<p>' . __( 'Cache plugins are PHP scripts you\'ll find in a dedicated folder inside the WP Super Cache folder (wp-super-cache/plugins/). They load at the same time as WP Super Cache, and before regular WordPress plugins.', 'wp-super-cache' ) . '</p>';
1327
+ echo '<p>' . __( 'Keep in mind that cache plugins are for advanced users only. To create and manage them, you\'ll need extensive knowledge of both PHP and WordPress actions.', 'wp-super-cache' ) . '</p>';
1328
+ echo '<p>' . sprintf( __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the ones you upload to the WP Super Cache folder (wp-super-cache/plugins/) will be deleted when you upgrade WP Super Cache. To avoid this loss, load your cache plugins from a different location. When you set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php, WP Super Cache will look there instead. <br />You can find additional details in the <a href="%s">developer documentation</a>.', 'wp-super-cache' ), 'https://odd.blog/wp-super-cache-developers/' ) . '</p>';
1329
  ob_start();
1330
  if( defined( 'WP_CACHE' ) ) {
1331
  if( function_exists( 'do_cacheaction' ) ) {
2011
  if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
2012
  extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
2013
  } elseif ( ! file_exists( $cache_path . $wp_cache_debug_log ) ) { // make sure debug log exists before toggling debugging
2014
+ extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
2015
  }
2016
  $wp_super_cache_debug = (int) $_POST[ 'wp_super_cache_debug' ];
2017
  wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug );
2178
  }
2179
  $lines = file($wp_cache_config_file);
2180
  foreach($lines as $line) {
2181
+ if (preg_match('/^ *\$cache_enabled *= *true *;/', $line))
2182
  return true;
2183
  }
2184
  return false;
2204
  return false;
2205
  }
2206
  if (!is_writeable_ACLSafe($my_file)) {
2207
+ trigger_error( "Error: file $my_file is not writable." );
2208
  return false;
2209
  }
2210
 
2211
  $found = false;
2212
  $lines = file($my_file);
2213
  foreach( (array)$lines as $line ) {
2214
+ if ( preg_match("/$old/", $line)) {
2215
  $found = true;
2216
  break;
2217
  }
2346
  }
2347
  }
2348
  if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'wpsclogout' )
2349
+ add_action( 'admin_init', 'wp_cache_logout_all' );
2350
 
2351
  function wp_cache_add_index_protection() {
2352
  global $cache_path, $blog_cache_dir;
2493
  }
2494
 
2495
  $line = 'define( \'WPCACHEHOME\', \'' . dirname( __FILE__ ) . '/\' );';
2496
+
2497
+ if ( ! apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
2498
+ echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! " . sprintf( __( 'Not allowed to edit %s per configuration.', 'wp-super-cache' ), $global_config_file ) . "</h3></div>";
2499
+ return false;
2500
+ }
2501
+
2502
  if ( !is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\( *\'WPCACHEHOME\'', $line, $global_config_file ) ) {
2503
  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>";
2504
  return false;
2519
  function wp_cache_check_link() {
2520
  global $wp_cache_link, $wp_cache_file;
2521
 
2522
+ $ret = true;
2523
  if( file_exists($wp_cache_link) ) {
2524
  $file = file_get_contents( $wp_cache_link );
2525
  if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
3105
 
3106
  function wp_cache_plugin_notice( $plugin ) {
3107
  global $cache_enabled;
3108
+ if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled && function_exists( 'admin_url' ) )
3109
  echo '<td colspan="5" class="plugin-update">' . sprintf( __( 'WP Super Cache must be configured. Go to <a href="%s">the admin page</a> to enable and configure the plugin.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</td>';
3110
  }
3111
  add_action( 'after_plugin_row', 'wp_cache_plugin_notice' );
3112
 
3113
  function wp_cache_plugin_actions( $links, $file ) {
3114
+ if( $file == 'wp-super-cache/wp-cache.php' && function_exists( 'admin_url' ) ) {
3115
  $settings_link = '<a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">' . __( 'Settings', 'wp-super-cache' ) . '</a>';
3116
  array_unshift( $links, $settings_link ); // before other links
3117
  }
3121
 
3122
  function wp_cache_admin_notice() {
3123
  global $cache_enabled, $wp_cache_phase1_loaded;
3124
+ if( substr( $_SERVER['PHP_SELF'], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( 'admin_url' ) )
3125
  echo '<div class="notice notice-info"><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>';
3126
 
3127
  if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
3144
  $front_page = wp_remote_get( site_url(), array('timeout' => 60, 'blocking' => true ) );
3145
  if( is_array( $front_page ) ) {
3146
  // Check for gzipped front page
3147
+ if ( $front_page[ 'headers' ][ 'content-type' ] == 'application/x-gzip' ) {
3148
+ if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
3149
+ wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), home_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
3150
+ } else {
3151
+ wp_cache_clear_cache( $wpdb->blogid );
3152
+ wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
3153
+ }
3154
+ }
3155
 
3156
  // Check for broken front page
3157
  if ( isset( $wp_super_cache_front_page_text ) && $wp_super_cache_front_page_text != '' && false === strpos( $front_page[ 'body' ], $wp_super_cache_front_page_text ) ) {
3158
  if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
3159
+ wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
3160
+ } else {
3161
+ wp_cache_clear_cache( $wpdb->blogid );
3162
+ wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), home_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' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
3163
  }
3164
  }
3165
  }
3601
  } else {
3602
  $global_config_file = dirname(ABSPATH) . '/wp-config.php';
3603
  }
3604
+
3605
+ if ( apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
3606
+ $line = 'define(\'WP_CACHE\', true);';
3607
+ if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', '', $global_config_file ) ) ) {
3608
+ wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." );
3609
+ }
3610
+ $line = 'define( \'WPCACHEHOME\',';
3611
+ if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', '', $global_config_file ) ) ) {
3612
+ wp_die( "Could not remove WPCACHEHOME define from $global_config_file. Please edit that file and remove the line containing the text 'WPCACHEHOME'. Then refresh this page." );
3613
+ }
3614
+ } elseif ( function_exists( 'wp_cache_debug' ) ) {
3615
+ wp_cache_debug( 'wp_cache_disable_plugin: not allowed to edit wp-config.php per configuration.' );
3616
  }
3617
 
3618
  uninstall_supercache( WP_CONTENT_DIR . '/cache' );
3750
  } elseif ( isset( $_POST[ 'preload_now' ] ) ) {
3751
  wpsc_enable_preload();
3752
  return $return;
3753
+ }
3754
+
3755
  if ( $min_refresh_interval == 'NA' ) {
3756
  $count = wpsc_post_count();
3757
  if ( $count > 1000 ) {
3818
  }
3819
 
3820
  function wpsc_is_preloading() {
3821
+ if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
3822
  return true;
3823
  } else {
3824
  return false;
3983
  wp_cache_setting( 'wpsc_last_post_update', time() );
3984
  }
3985
  add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
3986
+
3987
+ function wpsc_get_plugin_list() {
3988
+ $list = do_cacheaction( 'wpsc_filter_list' );
3989
+ foreach( $list as $t => $details ) {
3990
+ $key = "cache_" . $details[ 'key' ];
3991
+ global $$key;
3992
+ if ( isset( $$key ) && $$key == 1 ) {
3993
+ $list[ $t ][ 'enabled' ] = true;
3994
+ } else {
3995
+ $list[ $t ][ 'enabled' ] = false;
3996
+ }
3997
+
3998
+ $list[ $t ][ 'desc' ] = strip_tags( $list[ $t ][ 'desc' ] );
3999
+ $list[ $t ][ 'title' ] = strip_tags( $list[ $t ][ 'title' ] );
4000
+ }
4001
+ return $list;
4002
+ }
4003
+
4004
+ function wpsc_update_plugin_list( $update ) {
4005
+ $list = do_cacheaction( 'wpsc_filter_list' );
4006
+ foreach( $update as $key => $enabled ) {
4007
+ $plugin_toggle = "cache_{$key}";
4008
+ global $$plugin_toggle;
4009
+ if ( isset( $$plugin_toggle ) || isset( $list[ $key ] ) ) {
4010
+ wp_cache_setting( $plugin_toggle, (int)$enabled );
4011
+ }
4012
+ }
4013
+ }