WP Super Cache - Version 1.7.8

Version Description

Download this release

Release Info

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

Code changes from version 1.7.7 to 1.7.8

inc/delete-cache-button.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ $(document).ready(function () {
3
+ $('#wp-admin-bar-delete-cache').click(function () {
4
+ $('#wp-admin-bar-delete-cache').fadeOut('slow');
5
+ $.ajax({
6
+ type: "post",
7
+ dataType: "json",
8
+ url: wpsc_ajax.ajax_url,
9
+ data: {
10
+ // wp ajax action
11
+ action: 'ajax-delete-cache',
12
+
13
+ path: wpsc_ajax.path,
14
+ admin: wpsc_ajax.admin,
15
+
16
+ // send the nonce along with the request
17
+ nonce: wpsc_ajax.nonce
18
+ },
19
+ success: function(msg) {
20
+ wpsc_ajax.admin == 1 && console.log( 'Deleted entire cache' );
21
+ wpsc_ajax.admin == 0 && console.log( 'Deleted cache for this page and reloading' ); window.location.reload();
22
+ },
23
+ complete: function(msg) {
24
+ $('#wp-admin-bar-delete-cache').fadeIn('slow');
25
+ },
26
+ });
27
+ return false;
28
+ });
29
+
30
+ });
31
+ })(jQuery);
inc/delete-cache-button.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adds "Delete Cache" button in WP Toolbar.
5
+ */
6
+ function wpsc_admin_bar_render( $wp_admin_bar ) {
7
+
8
+ if ( ! function_exists( 'current_user_can' ) || ! is_user_logged_in() ) {
9
+ return false;
10
+ }
11
+
12
+ $path_to_home = rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' );
13
+ if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) {
14
+
15
+ $site_regex = preg_quote( $path_to_home, '`' );
16
+ $req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] );
17
+ $path = preg_replace( '`^' . $site_regex . '`', '', $req_uri );
18
+
19
+ $wp_admin_bar->add_menu( array(
20
+ 'parent' => '',
21
+ 'id' => 'delete-cache',
22
+ 'title' => __( 'Delete Cache', 'wp-super-cache' ),
23
+ 'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
24
+ 'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . rawurlencode( $path ) ), 'delete-cache' )
25
+ ) );
26
+ }
27
+
28
+ if ( is_admin() && ( wpsupercache_site_admin() || current_user_can( 'delete_others_posts' ) ) ) {
29
+ $wp_admin_bar->add_menu( array(
30
+ 'parent' => '',
31
+ 'id' => 'delete-cache',
32
+ 'title' => __( 'Delete Cache', 'wp-super-cache' ),
33
+ 'meta' => array( 'title' => __( 'Delete Super Cache cached files', 'wp-super-cache' ) ),
34
+ 'href' => wp_nonce_url( admin_url( 'index.php?admin=1&action=delcachepage&path=' . rawurlencode( trailingslashit( $path_to_home ) ) ), 'delete-cache' )
35
+ ) );
36
+ }
37
+ }
38
+ add_action( 'admin_bar_menu', 'wpsc_admin_bar_render', 99 );
39
+
40
+ function wpsc_delete_cache_scripts() {
41
+ if ( ! is_user_logged_in() ) {
42
+ return;
43
+ }
44
+ $path_to_home = rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' );
45
+
46
+ wp_enqueue_script( 'delete-cache-button', plugins_url( '/delete-cache-button.js', __FILE__ ), array('jquery'), '1.0', 1 );
47
+
48
+ if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) {
49
+ $site_regex = preg_quote( $path_to_home, '`' );
50
+ $req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] );
51
+ $path_to_home = preg_replace( '`^' . $site_regex . '`', '', $req_uri );
52
+ $admin = 0;
53
+ } else {
54
+ $admin = 1;
55
+ }
56
+
57
+ if ( $path_to_home === '' ) {
58
+ $path_to_home = '/';
59
+ }
60
+
61
+ $nonce = wp_create_nonce( 'delete-cache-' . rawurlencode( $path_to_home ) . '_' . $admin );
62
+ wp_localize_script( 'delete-cache-button', 'wpsc_ajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'path' => $path_to_home, 'admin' => $admin, 'nonce' => $nonce ) );
63
+ }
64
+ add_action( 'wp_ajax_ajax-delete-cache', 'wpsc_admin_bar_delete_cache' );
65
+ add_action( 'wp_enqueue_scripts', 'wpsc_delete_cache_scripts' );
66
+ add_action( 'admin_enqueue_scripts', 'wpsc_delete_cache_scripts' );
67
+
68
+ /**
69
+ * Delete cache for a specific page.
70
+ */
71
+ function wpsc_admin_bar_delete_cache() {
72
+ // response output
73
+ header( "Content-Type: application/json" );
74
+
75
+ if ( ! current_user_can( 'delete_others_posts' ) ) {
76
+ return json_encode( false );
77
+ }
78
+
79
+ $req_path = isset( $_POST['path'] ) ? sanitize_text_field( stripslashes( $_POST['path'] ) ) : '';
80
+ $valid_nonce = ( $req_path && isset( $_POST['nonce'] ) ) ? wp_verify_nonce( $_POST['nonce'], 'delete-cache-' . rawurlencode( $_POST['path'] ) . '_' . $_POST['admin'] ) : false;
81
+
82
+ $path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
83
+
84
+ if ( $path ) {
85
+ if ( isset( $_POST['admin'] ) && (int) $_POST['admin'] === 1 ) {
86
+ global $file_prefix;
87
+ wp_cache_debug( 'Cleaning cache for this site.' );
88
+ wp_cache_clean_cache( $file_prefix );
89
+ return;
90
+ }
91
+ $path = trailingslashit( $path );
92
+ $supercachepath = realpath( get_supercache_dir() );
93
+
94
+ if ( false === wp_cache_confirm_delete( $path ) ||
95
+ 0 !== strpos( $path, $supercachepath )
96
+ ) {
97
+ wp_cache_debug( 'Could not delete directory: ' . $path );
98
+ wp_die( json_encode( 'Could not delete directory' ) );
99
+ }
100
+
101
+ wp_cache_debug( 'Deleting cache files in directory: ' . $path );
102
+ wpsc_delete_files( $path );
103
+ return;
104
+ } else {
105
+ wp_cache_debug( 'Could not delete directory. It does not exist: ' . esc_attr( $_POST['path'] ) );
106
+ }
107
+ }
inc/preload-notification.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function () {
2
+ load_preload_status();
3
+ setInterval(
4
+ function(){
5
+ load_preload_status();
6
+ },
7
+ 1000
8
+ );
9
+ })
10
+
11
+ function load_preload_status() {
12
+ jQuery.get({
13
+ url: wpsc_preload_ajax.preload_permalink_url + '?' + Math.random(),
14
+ success: function( response ) {
15
+ jQuery( '#preload_status' ).html( response );
16
+ }
17
+ })
18
+ }
inc/preload-notification.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wpsc_preload_notification_scripts() {
4
+ global $cache_path;
5
+ if (
6
+ isset( $_GET['page'] ) && $_GET['page'] === 'wpsupercache' &&
7
+ isset( $_GET['tab'] ) && $_GET['tab'] === 'preload' &&
8
+ @file_exists( $cache_path . 'preload_permalink.txt' )
9
+ ) {
10
+ wp_enqueue_script( 'preload-notification', plugins_url( '/preload-notification.js', __FILE__ ), array('jquery'), '1.0', 1 );
11
+ wp_localize_script( 'preload-notification', 'wpsc_preload_ajax', array( 'preload_permalink_url' => home_url( str_replace( $_SERVER['DOCUMENT_ROOT'], '', $cache_path ) . '/preload_permalink.txt' ) ) );
12
+ }
13
+ }
14
+ add_action( 'admin_enqueue_scripts', 'wpsc_preload_notification_scripts' );
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  * Contributors: donncha, automattic
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
  * Tested up to: 6.0
5
- * Stable tag: 1.7.7
6
  * Requires at least: 3.1
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
@@ -269,6 +269,17 @@ Your theme is probably responsive which means it resizes the page to suit whatev
269
 
270
  ## Changelog ##
271
 
 
 
 
 
 
 
 
 
 
 
 
272
  ### 1.7.7 ###
273
  * Fixes to settings page
274
 
@@ -781,4 +792,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
781
 
782
 
783
  ## Upgrade Notice ##
784
- Fixes for settings page
2
  * Contributors: donncha, automattic
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
  * Tested up to: 6.0
5
+ * Stable tag: 1.7.8
6
  * Requires at least: 3.1
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
269
 
270
  ## Changelog ##
271
 
272
+ ### 1.7.8 ###
273
+ * Change the admin bar "Delete Cache" button into an AJAX link #808 #810
274
+ * Fix link to log file in custom WordPress structure #807
275
+ * Add an auto updating preload message. #811 #816
276
+ * Use REQUEST_URI instead of GET to check GET status. #813
277
+ * Add commonWP and disclaimer to "recommended links" #812
278
+ * Hide warnings in case files deleted #814
279
+ * Remove the GET param when removing tracking params #818
280
+ * Check that post is private to unpublish it and clear cache 2249e58e6f585d936c0993e9d18e6382fa976a66
281
+ * Check $gc_flag was opened before closing it. #819
282
+
283
  ### 1.7.7 ###
284
  * Fixes to settings page
285
 
792
 
793
 
794
  ## Upgrade Notice ##
795
+ Misc fixes and new features
wp-cache-phase2.php CHANGED
@@ -46,11 +46,16 @@ function wpsc_remove_tracking_params_from_uri( $uri ) {
46
  parse_str( $parsed_url['query'], $query );
47
  foreach( $wpsc_tracking_parameters as $param_name ) {
48
  unset( $query[$param_name] );
 
49
  }
50
  }
51
  $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
52
  $query = ! empty( $query ) ? '?' . http_build_query( $query ) : '';
53
 
 
 
 
 
54
  if ( $uri !== $path . $query ) {
55
  wp_cache_debug( 'Removed tracking parameters from URL. Returning ' . $path . $query );
56
  }
@@ -93,7 +98,7 @@ function wp_cache_serve_cache_file() {
93
  return false;
94
  }
95
 
96
- if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
97
  wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
98
  return false;
99
  }
@@ -145,7 +150,7 @@ function wp_cache_serve_cache_file() {
145
  if ( false == file_exists( $file ) ) {
146
  wp_cache_debug( "No Super Cache file found for current URL: $file" );
147
  return false;
148
- } elseif ( false == empty( $_GET ) ) {
149
  wp_cache_debug( 'GET array not empty. Cannot serve a supercache file. ' . wpsc_dump_get_request() );
150
  return false;
151
  } elseif ( wp_cache_get_cookies_values() != '' ) {
@@ -1397,7 +1402,7 @@ function wp_cache_phase2() {
1397
  return false;
1398
  }
1399
 
1400
- if ( ! empty( $_GET ) ) {
1401
  wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . wpsc_dump_get_request(), 5 );
1402
  $super_cache_enabled = false;
1403
  }
@@ -1878,7 +1883,7 @@ function wp_cache_ob_callback( $buffer ) {
1878
  if ( defined( 'DONOTCACHEPAGE' ) ) {
1879
  wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
1880
  $cache_this_page = false;
1881
- } elseif ( $wp_cache_no_cache_for_get && ! empty( $_GET ) ) {
1882
  wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
1883
  $cache_this_page = false;
1884
  } elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
@@ -2107,7 +2112,7 @@ function wp_cache_get_ob(&$buffer) {
2107
 
2108
  $dir = get_current_url_supercache_dir();
2109
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
2110
- if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
2111
  wp_cache_debug( 'Supercache disabled: GET or feed detected or disabled by config.', 2 );
2112
  $super_cache_enabled = false;
2113
  }
@@ -2122,7 +2127,7 @@ function wp_cache_get_ob(&$buffer) {
2122
  }
2123
 
2124
  if( $super_cache_enabled ) {
2125
- if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
2126
  wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
2127
  $supercacheonly = true;
2128
  }
@@ -2328,7 +2333,7 @@ function wp_cache_get_ob(&$buffer) {
2328
  wp_cache_writers_exit();
2329
  wp_cache_debug( 'Warning! Not writing another page to front page cache.', 1 );
2330
  return $buffer;
2331
- } elseif ( filesize( $tmp_cache_filename ) == 0 ) {
2332
  wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
2333
  @unlink( $tmp_cache_filename );
2334
  } else {
@@ -2342,7 +2347,7 @@ function wp_cache_get_ob(&$buffer) {
2342
  }
2343
  if ( $gz ) {
2344
  fclose( $gz );
2345
- if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
2346
  wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
2347
  @unlink( $tmp_cache_filename . '.gz' );
2348
  } else {
@@ -2948,14 +2953,13 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
2948
  return;
2949
  }
2950
 
2951
- if ( $old_status === 'publish' && $new_status !== 'publish' ) { // post unpublished
2952
  if ( ! function_exists( 'get_sample_permalink' ) ) {
2953
  require_once( ABSPATH . 'wp-admin/includes/post.php' );
2954
  }
2955
  list( $permalink, $post_name ) = get_sample_permalink( $post );
2956
  $post_url = str_replace( array( "%postname%", "%pagename%" ), $post->post_name, $permalink );
2957
- }
2958
- elseif ( $old_status !== 'publish' && $new_status === 'publish' ) { // post published
2959
  wp_cache_post_edit( $post->ID );
2960
  return;
2961
  }
@@ -3224,7 +3228,9 @@ function wp_cache_gc_cron() {
3224
  update_option( 'wpsupercache_gc_time', time() );
3225
  wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
3226
  $fp = @fopen( $gc_flag, 'w' );
3227
- @fclose( $fp );
 
 
3228
 
3229
  wp_cache_debug( 'Cache garbage collection.', 5 );
3230
 
@@ -3303,6 +3309,17 @@ function wp_cache_gc_watcher() {
3303
  }
3304
  }
3305
 
 
 
 
 
 
 
 
 
 
 
 
3306
  if ( ! function_exists( 'apache_request_headers' ) ) {
3307
  /**
3308
  * A fallback for get request headers.
46
  parse_str( $parsed_url['query'], $query );
47
  foreach( $wpsc_tracking_parameters as $param_name ) {
48
  unset( $query[$param_name] );
49
+ unset( $_GET[ $param_name ] );
50
  }
51
  }
52
  $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
53
  $query = ! empty( $query ) ? '?' . http_build_query( $query ) : '';
54
 
55
+ if ( empty( $_GET ) ) {
56
+ $_SERVER['REQUEST_URI'] = strtok( $_SERVER['REQUEST_URI'], '?' );
57
+ }
58
+
59
  if ( $uri !== $path . $query ) {
60
  wp_cache_debug( 'Removed tracking parameters from URL. Returning ' . $path . $query );
61
  }
98
  return false;
99
  }
100
 
101
+ if ( $wp_cache_no_cache_for_get && wpsc_is_get_query() ) {
102
  wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
103
  return false;
104
  }
150
  if ( false == file_exists( $file ) ) {
151
  wp_cache_debug( "No Super Cache file found for current URL: $file" );
152
  return false;
153
+ } elseif ( wpsc_is_get_query() ) {
154
  wp_cache_debug( 'GET array not empty. Cannot serve a supercache file. ' . wpsc_dump_get_request() );
155
  return false;
156
  } elseif ( wp_cache_get_cookies_values() != '' ) {
1402
  return false;
1403
  }
1404
 
1405
+ if ( wpsc_is_get_query() ) {
1406
  wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . wpsc_dump_get_request(), 5 );
1407
  $super_cache_enabled = false;
1408
  }
1883
  if ( defined( 'DONOTCACHEPAGE' ) ) {
1884
  wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
1885
  $cache_this_page = false;
1886
+ } elseif ( $wp_cache_no_cache_for_get && wpsc_is_get_query() ) {
1887
  wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
1888
  $cache_this_page = false;
1889
  } elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
2112
 
2113
  $dir = get_current_url_supercache_dir();
2114
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
2115
+ if ( wpsc_is_get_query() || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
2116
  wp_cache_debug( 'Supercache disabled: GET or feed detected or disabled by config.', 2 );
2117
  $super_cache_enabled = false;
2118
  }
2127
  }
2128
 
2129
  if( $super_cache_enabled ) {
2130
+ if ( wp_cache_get_cookies_values() == '' && ! wpsc_is_get_query() ) {
2131
  wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
2132
  $supercacheonly = true;
2133
  }
2333
  wp_cache_writers_exit();
2334
  wp_cache_debug( 'Warning! Not writing another page to front page cache.', 1 );
2335
  return $buffer;
2336
+ } elseif ( @filesize( $tmp_cache_filename ) == 0 ) {
2337
  wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
2338
  @unlink( $tmp_cache_filename );
2339
  } else {
2347
  }
2348
  if ( $gz ) {
2349
  fclose( $gz );
2350
+ if ( @filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
2351
  wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
2352
  @unlink( $tmp_cache_filename . '.gz' );
2353
  } else {
2953
  return;
2954
  }
2955
 
2956
+ if ( ( $old_status === 'private' || $old_status === 'publish') && $new_status !== 'publish' ) { // post unpublished
2957
  if ( ! function_exists( 'get_sample_permalink' ) ) {
2958
  require_once( ABSPATH . 'wp-admin/includes/post.php' );
2959
  }
2960
  list( $permalink, $post_name ) = get_sample_permalink( $post );
2961
  $post_url = str_replace( array( "%postname%", "%pagename%" ), $post->post_name, $permalink );
2962
+ } elseif ( $old_status !== 'publish' && $new_status === 'publish' ) { // post published
 
2963
  wp_cache_post_edit( $post->ID );
2964
  return;
2965
  }
3228
  update_option( 'wpsupercache_gc_time', time() );
3229
  wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
3230
  $fp = @fopen( $gc_flag, 'w' );
3231
+ if ( $fp ) {
3232
+ @fclose( $fp );
3233
+ }
3234
 
3235
  wp_cache_debug( 'Cache garbage collection.', 5 );
3236
 
3309
  }
3310
  }
3311
 
3312
+ function wpsc_is_get_query() {
3313
+ static $is_get_query = null;
3314
+
3315
+ if ( null === $is_get_query ) {
3316
+ $request_uri = parse_url( $_SERVER['REQUEST_URI'] );
3317
+ $is_get_query = $request_uri && ! empty( $request_uri['query'] );
3318
+ }
3319
+
3320
+ return $is_get_query;
3321
+ }
3322
+
3323
  if ( ! function_exists( 'apache_request_headers' ) ) {
3324
  /**
3325
  * A fallback for get request headers.
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.7.7
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -29,6 +29,9 @@ Text Domain: wp-super-cache
29
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
  */
31
 
 
 
 
32
  if ( ! function_exists( 'wp_cache_phase2' ) ) {
33
  require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
34
  }
@@ -496,54 +499,6 @@ function wp_cache_manager_error_checks() {
496
  }
497
  add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
498
 
499
- /**
500
- * Delete cache for a specific page.
501
- */
502
- function admin_bar_delete_page() {
503
-
504
- if ( ! current_user_can( 'delete_others_posts' ) ) {
505
- return false;
506
- }
507
-
508
- $req_path = isset( $_GET['path'] ) ? sanitize_text_field( stripslashes( $_GET['path'] ) ) : '';
509
- $referer = wp_get_referer();
510
- $valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
511
-
512
- $path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
513
-
514
- if ( $path ) {
515
- if ( isset( $_GET['admin'] ) ) {
516
- global $file_prefix;
517
- wp_cache_clean_cache( $file_prefix );
518
- wp_safe_redirect( admin_url( '/' ) );
519
- exit;
520
- }
521
- $path = trailingslashit( $path );
522
- $supercachepath = realpath( get_supercache_dir() );
523
-
524
- if ( false === wp_cache_confirm_delete( $path ) ||
525
- 0 !== strpos( $path, $supercachepath )
526
- ) {
527
- wp_die( 'Could not delete directory' );
528
- }
529
-
530
- wpsc_delete_files( $path );
531
- }
532
-
533
- if ( isset( $_GET['admin'] ) ) {
534
- wp_safe_redirect( admin_url( '/' ) );
535
- exit;
536
- }
537
-
538
- if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
539
- wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
540
- exit;
541
- }
542
- }
543
- if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
544
- add_action( 'admin_init', 'admin_bar_delete_page' );
545
- }
546
-
547
  function wp_cache_manager_updates() {
548
  global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $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_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;
549
  global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
@@ -913,7 +868,7 @@ table.wpsc-settings-table {
913
  $currently_preloading = true;
914
  if ( @file_exists( $cache_path . 'preload_permalink.txt' ) ) {
915
  $url = file_get_contents( $cache_path . 'preload_permalink.txt' );
916
- $msg .= '<p>' . sprintf( __( '<strong>Page last cached:</strong> %s', 'wp-super-cache' ), $url ) . '</p>';
917
  }
918
  if ( $msg != '' ) {
919
  echo '<div class="notice notice-warning"><h4>' . esc_html__( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg;
@@ -3283,43 +3238,6 @@ function supercache_admin_bar_render() {
3283
  wpsc_admin_bar_render( $wp_admin_bar );
3284
  }
3285
 
3286
- /**
3287
- * Adds "Delete Cache" button in WP Toolbar.
3288
- */
3289
- function wpsc_admin_bar_render( $wp_admin_bar ) {
3290
-
3291
- if ( ! function_exists( 'current_user_can' ) || ! is_user_logged_in() ) {
3292
- return false;
3293
- }
3294
-
3295
- $path_to_home = rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' );
3296
- if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) {
3297
-
3298
- $site_regex = preg_quote( $path_to_home, '`' );
3299
- $req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] );
3300
- $path = preg_replace( '`^' . $site_regex . '`', '', $req_uri );
3301
-
3302
- $wp_admin_bar->add_menu( array(
3303
- 'parent' => '',
3304
- 'id' => 'delete-cache',
3305
- 'title' => __( 'Delete Cache', 'wp-super-cache' ),
3306
- 'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
3307
- 'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . rawurlencode( $path ) ), 'delete-cache' )
3308
- ) );
3309
- }
3310
-
3311
- if ( is_admin() && ( wpsupercache_site_admin() || current_user_can( 'delete_others_posts' ) ) ) {
3312
- $wp_admin_bar->add_menu( array(
3313
- 'parent' => '',
3314
- 'id' => 'delete-cache',
3315
- 'title' => __( 'Delete Cache', 'wp-super-cache' ),
3316
- 'meta' => array( 'title' => __( 'Delete Super Cache cached files', 'wp-super-cache' ) ),
3317
- 'href' => wp_nonce_url( admin_url( 'index.php?admin=1&action=delcachepage&path=' . rawurlencode( trailingslashit( $path_to_home ) ) ), 'delete-cache' )
3318
- ) );
3319
- }
3320
- }
3321
- add_action( 'admin_bar_menu', 'wpsc_admin_bar_render', 99 );
3322
-
3323
  function wpsc_cancel_preload() {
3324
  global $cache_path;
3325
  $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' );
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.7.8
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
29
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
  */
31
 
32
+ require_once( dirname( __FILE__ ) . '/inc/delete-cache-button.php');
33
+ require_once( dirname( __FILE__ ) . '/inc/preload-notification.php');
34
+
35
  if ( ! function_exists( 'wp_cache_phase2' ) ) {
36
  require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
37
  }
499
  }
500
  add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  function wp_cache_manager_updates() {
503
  global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $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_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;
504
  global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
868
  $currently_preloading = true;
869
  if ( @file_exists( $cache_path . 'preload_permalink.txt' ) ) {
870
  $url = file_get_contents( $cache_path . 'preload_permalink.txt' );
871
+ $msg .= '<p>' . sprintf( __( '<strong>Page last cached:</strong> %s', 'wp-super-cache' ), '<span id="preload_status">' . $url . '</span>' ) . '</p>';
872
  }
873
  if ( $msg != '' ) {
874
  echo '<div class="notice notice-warning"><h4>' . esc_html__( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg;
3238
  wpsc_admin_bar_render( $wp_admin_bar );
3239
  }
3240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3241
  function wpsc_cancel_preload() {
3242
  global $cache_path;
3243
  $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' );