WP Super Cache - Version 1.7.4

Version Description

Download this release

Release Info

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

Code changes from version 1.7.3 to 1.7.4

Files changed (4) hide show
  1. readme.txt +9 -3
  2. wp-cache-phase1.php +13 -2
  3. wp-cache-phase2.php +52 -1
  4. wp-cache.php +92 -15
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  # WP Super Cache #
2
  * Contributors: donncha, automattic
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
- * Tested up to: 5.7.1
5
- * Stable tag: 1.7.3
6
  * Requires at least: 3.1
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
@@ -269,6 +269,12 @@ Your theme is probably responsive which means it resizes the page to suit whatev
269
 
270
  ## Changelog ##
271
 
 
 
 
 
 
 
272
  ### 1.7.3 ###
273
  * Sanitize the settings that are written to the config file #763
274
  * Fix the display of "direct cached" example urls in some circumstance. #766
@@ -761,4 +767,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
761
 
762
 
763
  ## Upgrade Notice ##
764
- Security and bugfix release. Security issue isn't too serious but you should upgrade.
1
  # WP Super Cache #
2
  * Contributors: donncha, automattic
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
+ * Tested up to: 5.8.1
5
+ * Stable tag: 1.7.4
6
  * Requires at least: 3.1
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
269
 
270
  ## Changelog ##
271
 
272
+ ### 1.7.4 ###
273
+ * Make config file path configurable, props @sebastianpopp #755
274
+ * Stop a very rare/difficult attack when updating wp-config.php, props @guyasyou for reporting. #780
275
+ * Add textbox to add tracking parameters to ignore when caching. props @markfinst, @radex02 #777
276
+ * Add "Rejected Cookies" setting to the advanced settings page. #774
277
+
278
  ### 1.7.3 ###
279
  * Sanitize the settings that are written to the config file #763
280
  * Fix the display of "direct cached" example urls in some circumstance. #766
767
 
768
 
769
  ## Upgrade Notice ##
770
+ Security and new feature release. Security issue is very difficult to perform but you should upgrade.
wp-cache-phase1.php CHANGED
@@ -5,7 +5,11 @@ if ( ! function_exists( 'wp_cache_phase2' ) ) {
5
  }
6
 
7
  // error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
8
- if ( ! @include WP_CONTENT_DIR . '/wp-cache-config.php' ) {
 
 
 
 
9
  return false;
10
  }
11
 
@@ -77,6 +81,13 @@ if ( wpsc_is_backend() ) {
77
  return true;
78
  }
79
 
 
 
 
 
 
 
 
80
  if ( wpsc_is_caching_user_disabled() ) {
81
  wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
82
  return true;
@@ -109,7 +120,7 @@ if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6
109
  add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
110
  }
111
 
112
- $wp_cache_request_uri = $_SERVER['REQUEST_URI']; // Cache this in case any plugin modifies it.
113
 
114
  if ( defined( 'DOING_CRON' ) ) {
115
  extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
5
  }
6
 
7
  // error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
8
+ if ( !defined( 'WPCACHECONFIGPATH' ) ) {
9
+ define( 'WPCACHECONFIGPATH', WP_CONTENT_DIR );
10
+ }
11
+
12
+ if ( ! @include WPCACHECONFIGPATH . '/wp-cache-config.php' ) {
13
  return false;
14
  }
15
 
81
  return true;
82
  }
83
 
84
+ if ( wpsc_is_rejected_cookie() ) {
85
+ define( 'DONOTCACHEPAGE', 1 );
86
+ $cache_enabled = false;
87
+ wp_cache_debug( 'Caching disabled because rejected cookie found.' );
88
+ return true;
89
+ }
90
+
91
  if ( wpsc_is_caching_user_disabled() ) {
92
  wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
93
  return true;
120
  add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
121
  }
122
 
123
+ $wp_cache_request_uri = wpsc_remove_tracking_params_from_uri( $_SERVER['REQUEST_URI'] ); // Cache this in case any plugin modifies it and filter out tracking parameters.
124
 
125
  if ( defined( 'DOING_CRON' ) ) {
126
  extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
wp-cache-phase2.php CHANGED
@@ -28,6 +28,36 @@ function get_wp_cache_key( $url = false ) {
28
  return do_cacheaction( 'wp_cache_key', wp_cache_check_mobile( $WPSC_HTTP_HOST . $server_port . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() ) );
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  function wp_super_cache_init() {
32
  global $wp_cache_key, $key, $blogcacheid, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname;
33
 
@@ -1235,7 +1265,13 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
1235
  }
1236
  }
1237
 
1238
- $tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
 
 
 
 
 
 
1239
  rename( $tmp_config_filename, $tmp_config_filename . ".php" );
1240
  $tmp_config_filename .= ".php";
1241
  wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
@@ -1606,6 +1642,21 @@ function wp_cache_get_response_headers() {
1606
  return $headers;
1607
  }
1608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1609
  function wp_cache_is_rejected($uri) {
1610
  global $cache_rejected_uri;
1611
 
28
  return do_cacheaction( 'wp_cache_key', wp_cache_check_mobile( $WPSC_HTTP_HOST . $server_port . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() ) );
29
  }
30
 
31
+ function wpsc_remove_tracking_params_from_uri( $uri ) {
32
+ global $wpsc_tracking_parameters, $wpsc_ignore_tracking_parameters;
33
+
34
+ if ( ! isset( $wpsc_ignore_tracking_parameters ) || ! $wpsc_ignore_tracking_parameters ) {
35
+ return $uri;
36
+ }
37
+
38
+ if ( ! isset( $wpsc_tracking_parameters ) || empty( $wpsc_tracking_parameters ) ) {
39
+ return $uri;
40
+ }
41
+
42
+ $parsed_url = parse_url( $uri );
43
+ $query = array();
44
+
45
+ if ( isset( $parsed_url['query'] ) ) {
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
+ }
57
+
58
+ return $path . $query;
59
+ }
60
+
61
  function wp_super_cache_init() {
62
  global $wp_cache_key, $key, $blogcacheid, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname;
63
 
1265
  }
1266
  }
1267
 
1268
+ $tmp_config_filename = tempnam( $GLOBALS['cache_path'], md5( mt_rand( 0, 9999 ) ) );
1269
+ if ( file_exists( $tmp_config_filename . '.php' ) ) {
1270
+ unlink( $tmp_config_filename . '.php' );
1271
+ if ( file_exists( $tmp_config_filename . '.php' ) ) {
1272
+ die( __( 'WARNING: attempt to intercept updating of config file.', 'wp-super-cache' ) );
1273
+ }
1274
+ }
1275
  rename( $tmp_config_filename, $tmp_config_filename . ".php" );
1276
  $tmp_config_filename .= ".php";
1277
  wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
1642
  return $headers;
1643
  }
1644
 
1645
+ function wpsc_is_rejected_cookie() {
1646
+ global $wpsc_rejected_cookies;
1647
+ if ( false == is_array( $wpsc_rejected_cookies ) ) {
1648
+ return false;
1649
+ }
1650
+
1651
+ foreach ( $wpsc_rejected_cookies as $expr ) {
1652
+ if ( $expr !== '' && $match = preg_grep( "~$expr~", array_keys( $_COOKIE ) ) ) {
1653
+ wp_cache_debug( 'wpsc_is_rejected_cookie: found cookie: ' . $expr );
1654
+ return true;
1655
+ }
1656
+ }
1657
+ return false;
1658
+ }
1659
+
1660
  function wp_cache_is_rejected($uri) {
1661
  global $cache_rejected_uri;
1662
 
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.3
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -43,7 +43,11 @@ if ( ! defined( 'PHP_VERSION_ID' ) ) {
43
  function wpsc_init() {
44
  global $wp_cache_config_file, $wp_cache_config_file_sample, $wpsc_advanced_cache_dist_filename, $wp_cache_check_wp_config, $wpsc_advanced_cache_filename;
45
 
46
- $wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
 
 
 
 
47
 
48
  if ( !defined( 'WPCACHEHOME' ) ) {
49
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
@@ -128,7 +132,7 @@ function get_wpcachehome() {
128
  } elseif ( is_file( dirname( __FILE__ ) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
129
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/wp-super-cache/' );
130
  } else {
131
- die( sprintf( esc_html__( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ) );
132
  }
133
  }
134
  }
@@ -350,11 +354,11 @@ function wp_cache_manager_error_checks() {
350
  if ( !defined( 'SUBMITDISABLED' ) )
351
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
352
  ?><div class="notice notice-error"><h4><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h4>
353
- <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the web server to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?>
354
  <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it&#8217;s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p>
355
  <p><?php _e( '<a href="https://codex.wordpress.org/Changing_File_Permissions">This page</a> explains how to change file permissions.', 'wp-super-cache' ); ?></p>
356
- <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code><br />
357
- <?php _e( 'Read-only:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
358
  </div><?php
359
  } elseif ( !defined( 'SUBMITDISABLED' ) ) {
360
  define( "SUBMITDISABLED", ' ' );
@@ -1142,7 +1146,9 @@ table.wpsc-settings-table {
1142
  <legend class="hidden">Cache Location</legend>
1143
  <input type='text' size=80 name='wp_cache_location' value='<?php echo esc_attr( $cache_path ); ?>' />
1144
  <p><?php printf( __( 'Change the location of your cache files. The default is WP_CONTENT_DIR . /cache/ which translates to %s.', 'wp-super-cache' ), WP_CONTENT_DIR . '/cache/' ); ?></p>
1145
- <ol><li><?php _e( 'You must give the full path to the directory.', 'wp-super-cache' ); ?></li>
 
 
1146
  <li><?php _e( 'If the directory does not exist, it will be created. Please make sure your web server user has write access to the parent directory. The parent directory must exist.', 'wp-super-cache' ); ?></li>
1147
  <li><?php _e( 'If the new cache directory does not exist, it will be created and the contents of the old cache directory will be moved there. Otherwise, the old cache directory will be left where it is.', 'wp-super-cache' ); ?></li>
1148
  <li><?php _e( 'Submit a blank entry to set it to the default directory, WP_CONTENT_DIR . /cache/.', 'wp-super-cache' ); ?></li>
@@ -1172,6 +1178,7 @@ table.wpsc-settings-table {
1172
  <li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ); ?></li>
1173
  <li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li>
1174
  <li><?php echo '<em>' . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/', 'https://wordpress.org/support/topic-tag/wp-super-cache/?forum_id=10' ) . '</em>'; ?></li>
 
1175
  </ol>
1176
 
1177
  <?php
@@ -1189,9 +1196,13 @@ table.wpsc-settings-table {
1189
  echo "\n";
1190
  wp_cache_edit_rejected();
1191
  echo "\n";
 
 
1192
  wp_cache_edit_accepted();
1193
  echo '</fieldset>';
1194
 
 
 
1195
  wp_cache_edit_rejected_ua();
1196
 
1197
  wp_lock_down();
@@ -1979,6 +1990,72 @@ function wp_cache_edit_rejected_pages() {
1979
 
1980
  }
1981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1982
  function wp_cache_update_rejected_strings() {
1983
  global $cache_rejected_uri, $wp_cache_config_file, $valid_nonce;
1984
 
@@ -1995,7 +2072,7 @@ function wp_cache_edit_rejected() {
1995
  $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
1996
  wp_cache_update_rejected_strings();
1997
 
1998
- echo '<a name="rejecturi"></a>';
1999
  echo '<form name="wp_edit_rejected" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejecturi' ) . '" method="post">';
2000
  echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it&#8217;s enough to specify the year, i.e. &#8217;/2004/&#8217;. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
2001
  echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
@@ -2023,7 +2100,7 @@ function wp_cache_edit_accepted() {
2023
  wp_cache_update_accepted_strings();
2024
  $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
2025
 
2026
- echo '<a name="cancache"></a>';
2027
  echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#cancache' ) . '" method="post">';
2028
  echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
2029
  echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
@@ -3809,16 +3886,16 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
3809
  $file_not_deleted = false;
3810
  wpsc_remove_advanced_cache();
3811
  if ( @file_exists( WP_CONTENT_DIR . "/advanced-cache.php" ) ) {
3812
- $file_not_deleted[] = 'advanced-cache.php';
3813
  }
3814
- if ( $delete_config_file && @file_exists( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) {
3815
- if ( false == unlink( WP_CONTENT_DIR . "/wp-cache-config.php" ) )
3816
- $file_not_deleted[] = 'wp-cache-config.php';
3817
  }
3818
  if ( $file_not_deleted ) {
3819
  $msg = __( "Dear User,\n\nWP Super Cache was removed from your blog or deactivated but some files could\nnot be deleted.\n\n", 'wp-super-cache' );
3820
- foreach( (array)$file_not_deleted as $filename ) {
3821
- $msg .= WP_CONTENT_DIR . "/{$filename}\n";
3822
  }
3823
  $msg .= "\n";
3824
  $msg .= sprintf( __( "You should delete these files manually.\nYou may need to change the permissions of the files or parent directory.\nYou can read more about this in the Codex at\n%s\n\nThank you.", 'wp-super-cache' ), 'https://codex.wordpress.org/Changing_File_Permissions#About_Chmod' );
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.4
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
43
  function wpsc_init() {
44
  global $wp_cache_config_file, $wp_cache_config_file_sample, $wpsc_advanced_cache_dist_filename, $wp_cache_check_wp_config, $wpsc_advanced_cache_filename;
45
 
46
+ if ( !defined( 'WPCACHECONFIGPATH' ) ) {
47
+ define( 'WPCACHECONFIGPATH', WP_CONTENT_DIR );
48
+ }
49
+
50
+ $wp_cache_config_file = WPCACHECONFIGPATH . '/wp-cache-config.php';
51
 
52
  if ( !defined( 'WPCACHEHOME' ) ) {
53
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
132
  } elseif ( is_file( dirname( __FILE__ ) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
133
  define( 'WPCACHEHOME', dirname( __FILE__ ) . '/wp-super-cache/' );
134
  } else {
135
+ die( sprintf( esc_html__( 'Please create %s/wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), esc_attr( WPCACHECONFIGPATH ) ) );
136
  }
137
  }
138
  }
354
  if ( !defined( 'SUBMITDISABLED' ) )
355
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
356
  ?><div class="notice notice-error"><h4><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h4>
357
+ <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the web server to make any changes.', 'wp-super-cache' ), WPCACHECONFIGPATH ); ?>
358
  <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it&#8217;s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p>
359
  <p><?php _e( '<a href="https://codex.wordpress.org/Changing_File_Permissions">This page</a> explains how to change file permissions.', 'wp-super-cache' ); ?></p>
360
+ <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WPCACHECONFIGPATH; ?>/wp-cache-config.php</code><br />
361
+ <?php _e( 'Read-only:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WPCACHECONFIGPATH; ?>/wp-cache-config.php</code></p>
362
  </div><?php
363
  } elseif ( !defined( 'SUBMITDISABLED' ) ) {
364
  define( "SUBMITDISABLED", ' ' );
1146
  <legend class="hidden">Cache Location</legend>
1147
  <input type='text' size=80 name='wp_cache_location' value='<?php echo esc_attr( $cache_path ); ?>' />
1148
  <p><?php printf( __( 'Change the location of your cache files. The default is WP_CONTENT_DIR . /cache/ which translates to %s.', 'wp-super-cache' ), WP_CONTENT_DIR . '/cache/' ); ?></p>
1149
+ <ol>
1150
+ <li><?php _e( 'Warning: do not use a shared directory like /tmp/ where other users on this server can modify files. Your cache files could be modified to deface your website.', 'wp-super-cache' ); ?></li>
1151
+ <li><?php _e( 'You must give the full path to the directory.', 'wp-super-cache' ); ?></li>
1152
  <li><?php _e( 'If the directory does not exist, it will be created. Please make sure your web server user has write access to the parent directory. The parent directory must exist.', 'wp-super-cache' ); ?></li>
1153
  <li><?php _e( 'If the new cache directory does not exist, it will be created and the contents of the old cache directory will be moved there. Otherwise, the old cache directory will be left where it is.', 'wp-super-cache' ); ?></li>
1154
  <li><?php _e( 'Submit a blank entry to set it to the default directory, WP_CONTENT_DIR . /cache/.', 'wp-super-cache' ); ?></li>
1178
  <li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ); ?></li>
1179
  <li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li>
1180
  <li><?php echo '<em>' . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/', 'https://wordpress.org/support/topic-tag/wp-super-cache/?forum_id=10' ) . '</em>'; ?></li>
1181
+ <li><?php _e( 'The location of the plugin configuration file can be changed by defining the WPCACHECONFIGPATH constant in wp-config.php. If not defined it will be set to WP_CONTENT_DIR.', 'wp-super-cache' ); ?></li>
1182
  </ol>
1183
 
1184
  <?php
1196
  echo "\n";
1197
  wp_cache_edit_rejected();
1198
  echo "\n";
1199
+ wp_cache_edit_rejected_cookies();
1200
+ echo "\n";
1201
  wp_cache_edit_accepted();
1202
  echo '</fieldset>';
1203
 
1204
+ wpsc_edit_tracking_parameters();
1205
+
1206
  wp_cache_edit_rejected_ua();
1207
 
1208
  wp_lock_down();
1990
 
1991
  }
1992
 
1993
+ function wpsc_update_tracking_parameters() {
1994
+ global $wpsc_tracking_parameters, $valid_nonce, $wp_cache_config_file;
1995
+
1996
+ if ( isset( $_POST['tracking_parameters'] ) && $valid_nonce ) {
1997
+ $text = wp_cache_sanitize_value( str_replace( '\\\\', '\\', $_POST['tracking_parameters'] ), $wpsc_tracking_parameters );
1998
+ wp_cache_replace_line( '^ *\$wpsc_tracking_parameters', "\$wpsc_tracking_parameters = $text;", $wp_cache_config_file );
1999
+ wp_cache_setting( 'wpsc_ignore_tracking_parameters', isset( $_POST['wpsc_ignore_tracking_parameters'] ) ? 1 : 0 );
2000
+ }
2001
+ }
2002
+
2003
+ function wpsc_edit_tracking_parameters() {
2004
+ global $wpsc_tracking_parameters, $wpsc_ignore_tracking_parameters;
2005
+
2006
+ $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
2007
+ wpsc_update_tracking_parameters();
2008
+
2009
+ if ( ! isset( $wpsc_tracking_parameters ) ) {
2010
+ $wpsc_tracking_parameters = array( 'fbclid', 'ref', 'gclid', 'fb_source', 'mc_cid', 'mc_eid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_expid', 'mtm_source', 'mtm_medium', 'mtm_campaign', 'mtm_keyword', 'mtm_content', 'mtm_cid', 'mtm_group', 'mtm_placement' );
2011
+ }
2012
+
2013
+ if ( ! isset( $wpsc_ignore_tracking_parameters ) ) {
2014
+ $wpsc_ignore_tracking_parameters = 0;
2015
+ }
2016
+
2017
+ echo '<a name="trackingparameters"></a><fieldset class="options"><h4>' . __( 'Tracking Parameters', 'wp-super-cache' ) . '</h4>';
2018
+ echo '<form name="edit_tracking_parameters" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#trackingparameters' ) . '" method="post">';
2019
+ echo "<p>" . __( 'Tracking parameters to ignore when caching. Visitors from Facebook, Twitter and elsewhere to your website will go to a URL with tracking parameters added. This setting allows the plugin to ignore those parameters and show an already cached page. Any actual tracking by Google Analytics or other Javascript based code should still work as the URL of the page is not modified.', 'wp-super-cache' ) . "</p>\n";
2020
+ echo '<textarea name="tracking_parameters" cols="20" rows="10" style="width: 50%; font-size: 12px;" class="code">';
2021
+ foreach ( $wpsc_tracking_parameters as $parameter) {
2022
+ echo esc_html( $parameter ) . "\n";
2023
+ }
2024
+ echo '</textarea> ';
2025
+ echo "<p><label><input type='checkbox' name='wpsc_ignore_tracking_parameters' value='1' " . checked( 1, $wpsc_ignore_tracking_parameters, false ) . " /> " . __( 'Enable', 'wp-super-cache' ) . "</label></p>";
2026
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
2027
+ wp_nonce_field('wp-cache');
2028
+ echo "</form>\n";
2029
+ }
2030
+
2031
+ function wp_cache_update_rejected_cookies() {
2032
+ global $wpsc_rejected_cookies, $wp_cache_config_file, $valid_nonce;
2033
+
2034
+ if ( isset( $_POST['wp_rejected_cookies'] ) && $valid_nonce ) {
2035
+ $text = wp_cache_sanitize_value( str_replace( '\\\\', '\\', $_POST['wp_rejected_cookies'] ), $wpsc_rejected_cookies );
2036
+ wp_cache_replace_line( '^ *\$wpsc_rejected_cookies', "\$wpsc_rejected_cookies = $text;", $wp_cache_config_file );
2037
+ }
2038
+ }
2039
+
2040
+ function wp_cache_edit_rejected_cookies() {
2041
+ global $wpsc_rejected_cookies;
2042
+
2043
+ $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
2044
+ wp_cache_update_rejected_cookies();
2045
+
2046
+ echo '<a name="rejectcookies"></a><fieldset class="options"><h4>' . __( 'Rejected Cookies', 'wp-super-cache' ) . '</h4>';
2047
+ echo '<form name="wp_edit_rejected_cookies" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejectcookies' ) . '" method="post">';
2048
+ echo "<p>" . __( 'Do not cache pages when these cookies are set. Add the cookie names here, one per line. Matches on fragments, so "test" will match "WordPress_test_cookie". (Simple caching only)', 'wp-super-cache' ) . "</p>\n";
2049
+ echo '<textarea name="wp_rejected_cookies" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
2050
+ foreach ( $wpsc_rejected_cookies as $file) {
2051
+ echo esc_html( $file ) . "\n";
2052
+ }
2053
+ echo '</textarea> ';
2054
+ echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
2055
+ wp_nonce_field('wp-cache');
2056
+ echo "</form>\n";
2057
+ }
2058
+
2059
  function wp_cache_update_rejected_strings() {
2060
  global $cache_rejected_uri, $wp_cache_config_file, $valid_nonce;
2061
 
2072
  $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
2073
  wp_cache_update_rejected_strings();
2074
 
2075
+ echo '<a name="rejecturi"></a><fieldset class="options"><h4>' . __( 'Rejected URL Strings', 'wp-super-cache' ) . '</h4>';
2076
  echo '<form name="wp_edit_rejected" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejecturi' ) . '" method="post">';
2077
  echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it&#8217;s enough to specify the year, i.e. &#8217;/2004/&#8217;. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
2078
  echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
2100
  wp_cache_update_accepted_strings();
2101
  $admin_url = admin_url( 'options-general.php?page=wpsupercache' );
2102
 
2103
+ echo '<a name="cancache"></a><fieldset class="options"><h4>' . __( 'Always Cache Filenames', 'wp-super-cache' ) . '</h4>';
2104
  echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#cancache' ) . '" method="post">';
2105
  echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
2106
  echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
3886
  $file_not_deleted = false;
3887
  wpsc_remove_advanced_cache();
3888
  if ( @file_exists( WP_CONTENT_DIR . "/advanced-cache.php" ) ) {
3889
+ $file_not_deleted[] = WP_CONTENT_DIR . '/advanced-cache.php';
3890
  }
3891
+ if ( $delete_config_file && @file_exists( WPCACHECONFIGPATH . "/wp-cache-config.php" ) ) {
3892
+ if ( false == unlink( WPCACHECONFIGPATH . "/wp-cache-config.php" ) )
3893
+ $file_not_deleted[] = WPCACHECONFIGPATH . '/wp-cache-config.php';
3894
  }
3895
  if ( $file_not_deleted ) {
3896
  $msg = __( "Dear User,\n\nWP Super Cache was removed from your blog or deactivated but some files could\nnot be deleted.\n\n", 'wp-super-cache' );
3897
+ foreach( (array)$file_not_deleted as $path ) {
3898
+ $msg .= "{$path}\n";
3899
  }
3900
  $msg .= "\n";
3901
  $msg .= sprintf( __( "You should delete these files manually.\nYou may need to change the permissions of the files or parent directory.\nYou can read more about this in the Codex at\n%s\n\nThank you.", 'wp-super-cache' ), 'https://codex.wordpress.org/Changing_File_Permissions#About_Chmod' );