diff --git a/wp-content/plugins/wp-super-cache/readme.txt b/wp-content/plugins/wp-super-cache/readme.txt index 92c9c776c2d8f62b034a85a5c8b3ecfdcd7dc093..46f7e0e2bb58b5a656cf5709051673051ace1354 100644 --- a/wp-content/plugins/wp-super-cache/readme.txt +++ b/wp-content/plugins/wp-super-cache/readme.txt @@ -1,9 +1,9 @@ # WP Super Cache # * Contributors: donncha, automattic, kraftbj * Tags: performance, caching, wp-cache, wp-super-cache, cache -* Tested up to: 4.9.6 -* Stable tag: 1.6.2 -* Requires at least: 3.0 +* Tested up to: 4.9.8 +* Stable tag: 1.6.4 +* Requires at least: 3.1 * Requires PHP: 5.2.4 * License: GPLv2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -89,6 +89,11 @@ There is one regular WordPress filter too. Use the "do_createsupercache" filter to customize the checks made before caching. The filter accepts one parameter. The output of WP-Cache's wp_cache_get_cookies_values() function. +WP Super Cache has it's own plugin system. This code is loaded when WP Super Cache loads and can be used to change how caching is done. This is before most of WordPress loads so some functionality will not be available. Plugins can be located anywhere that PHP can load them. Add your own plugin by calling wpsc_add_plugin( $name ) where $name is the full filename and path to the plugin. You only need to call that function once to add it. Use wpsc_delete_plugin( $name ) to remove it from the list of loaded plugins. + +The cookies WP Super Cache uses to identify "known users" can be modified now by adding the names of those cookies to a list in the plugin configuration. Use wpsc_add_cookie( $name ) to add a new cookie, and wpsc_delete_cookie( $name ) to remove it. The cookie names also modify the mod_rewrite rules used by the plugin but I recommend using Simple mode caching to avoid complications with updating the .htaccess file. +The cookie name and value are used to differenciate users so you can have one cookie, but different values for each type of user on your site for example. They'll be served different cache files. + See [plugins/searchengine.php](https://github.com/Automattic/wp-super-cache/blob/4cda5c0f2218e40e118232b5bf22d227fb3206b7/plugins/searchengine.php) as an example I use for my [No Adverts for Friends](https://odd.blog/no-adverts-for-friends/) plugin. ### Troubleshooting ### @@ -200,7 +205,7 @@ Cached files are served before almost all of WordPress is loaded. While that's g This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the wpsc_cachedata filter described in the previous answer to update or display dynamic information. ### Why do my WP Super Cache plugins disappear when I upgrade the plugin? ### -WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins. +WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can put your custom plugins in a different directory in a number of ways. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins. Or if you distribute a plugin that needs to load early you can use the function `wpsc_add_plugin( $filename )` to add a new plugin wherever it may be. Use `wpsc_delete_plugin( $filename )` to remove the plugin file. See [#574](https://github.com/Automattic/wp-super-cache/pull/574/) or [this post](https://odd.blog/2017/10/25/writing-wp-super-cache-plugins/) on writing WP Super Cache plugins. ### What does the Cache Rebuild feature do? ### When a visitor leaves a comment the cached file for that page is deleted and the next visitor recreates the cached page. A page takes time to load so what happens if it receives 100 visitors during this time? There won't be a cached page so WordPress will serve a fresh page for each user and the plugin will try to create a cached page for each of those 100 visitors causing a huge load on your server. This feature stops this happening. The cached page is not cleared when a comment is left. It is marked for rebuilding instead. The next visitor within the next 10 seconds will regenerate the cached page while the old page is served to the other 99 visitors. The page is eventually loaded by the first visitor and the cached page updated. See [this post](https://odd.blog/2009/01/23/wp-super-cache-089/) for more. @@ -261,6 +266,29 @@ Your theme is probably responsive which means it resizes the page to suit whatev ## Changelog ## +### 1.6.4 ### +* Changes between [1.6.3 and 1.6.4](https://github.com/Automattic/wp-super-cache/compare/1.6.3...1.6.4) +* Fixes for WP-CLI (#587) (#592) +* Bumped the minimum WordPress version to 3.1 to use functions introduced then. (#591) +* Fixes to wpsc_post_transition to avoid a fatal error using get_sample_permalink. (#595) +* Fixed the admin bar "Delete Cache" link. (#589) +* Fixed the headings used in the settings page. (#597) + +### 1.6.3 ### +* Changes between [1.6.2 and 1.6.3](https://github.com/Automattic/wp-super-cache/compare/1.6.2...1.6.3) +* Added cookie helper functions (#580) +* Added plugin helper functions (#574) +* Added actions to modify cookie and plugin lists. (#582) +* Really disable garbage collection when timeout = 0 (#571) +* Added warnings about DISABLE_WP_CRON (#575) +* Don't clean expired cache files after preload if garbage collection is disabled (#572) +* On preload, if deleting a post don't delete the sub directories if it's the homepage. (#573) +* Fix generation of semaphores when using WP CLI (#576) +* Fix deleting from the admin bar (#578) +* Avoid a strpos() warning. (#579) +* Improve deleting of cache in edit/delete/publish actions (#577) +* Fixes to headers code (#496) + ### 1.6.2 ### * Fixed serving expired supercache files (#562) * Write directly to the config file to avoid permission problems with wp-content. (#563) @@ -663,4 +691,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev ## Upgrade Notice ## -Fix problems writing to the config file for some users. +Bug fixes diff --git a/wp-content/plugins/wp-super-cache/wp-cache-base.php b/wp-content/plugins/wp-super-cache/wp-cache-base.php index 2cb1646bded77039d6fc9a03a08611e8bdce97e6..5ee15c28cf4f70b2ef49ed50e949fb3b6b9e786b 100644 --- a/wp-content/plugins/wp-super-cache/wp-cache-base.php +++ b/wp-content/plugins/wp-super-cache/wp-cache-base.php @@ -1,9 +1,13 @@ <?php -if ( false == isset( $_SERVER['HTTP_HOST'] ) ) { +global $WPSC_HTTP_HOST, $blogcacheid; + +if ( ! empty( $_SERVER['HTTP_HOST'] ) ) { + $WPSC_HTTP_HOST = htmlentities( $_SERVER['HTTP_HOST'] ); +} elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) { + $WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST ); +} else { $cache_enabled = false; $WPSC_HTTP_HOST = ''; -} else { - $WPSC_HTTP_HOST = htmlentities( $_SERVER['HTTP_HOST'] ); } // We want to be able to identify each blog in a WordPress MU install @@ -17,7 +21,7 @@ if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == tr $base = ''; } $request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) ); - if ( strpos( $request_uri, '/', 1 ) ) { + if ( strlen( $request_uri ) > 0 && strpos( $request_uri, '/', 1 ) ) { if ( $base == '/' ) { $blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 ); } else { diff --git a/wp-content/plugins/wp-super-cache/wp-cache-phase1.php b/wp-content/plugins/wp-super-cache/wp-cache-phase1.php index d5291f3c2012fb109862155f7f0dabf46c19c1a5..3a3e047ff5f65419f54e9aa128853d5dda56a3c2 100644 --- a/wp-content/plugins/wp-super-cache/wp-cache-phase1.php +++ b/wp-content/plugins/wp-super-cache/wp-cache-phase1.php @@ -49,6 +49,28 @@ if ( is_array( $plugins ) ) { } } +if ( isset( $wpsc_plugins ) && is_array( $wpsc_plugins ) ) { + foreach( $wpsc_plugins as $plugin_file ) { + if ( file_exists( ABSPATH . $plugin_file ) ) { + include_once( ABSPATH . $plugin_file ); + } + } +} + +if ( + file_exists( WPCACHEHOME . '../wp-super-cache-plugins/' ) && + is_dir( WPCACHEHOME . '../wp-super-cache-plugins/' ) +) { + $plugins = glob( WPCACHEHOME . '../wp-super-cache-plugins/*.php' ); + if ( is_array( $plugins ) ) { + foreach ( $plugins as $plugin ) { + if ( is_file( $plugin ) ) { + require_once $plugin; + } + } + } +} + $wp_start_time = microtime(); if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) { diff --git a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php index 95449bf106d61cb76645d5d5f94a06ae8c82e91a..41fb0c66101b710e08e444c7b1c88f9687603731 100644 --- a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php +++ b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php @@ -120,7 +120,7 @@ function wp_cache_serve_cache_file() { } elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) { wp_cache_debug( 'Saving headers. Cannot serve a supercache file.' ); return false; - } elseif ( ( filemtime( $file ) + $cache_max_time ) < time() ) { + } elseif ( $cache_max_time > 0 && ( filemtime( $file ) + $cache_max_time ) < time() ) { wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $cache_max_time ) ); return false; } @@ -196,17 +196,15 @@ function wp_cache_serve_cache_file() { // don't try to match modified dates if using dynamic code. if ( $wp_cache_mfunc_enabled == 0 && $wp_supercache_304 ) { - if ( function_exists( 'apache_request_headers' ) ) { - $request = apache_request_headers(); - $remote_mod_time = ( isset ( $request[ 'If-Modified-Since' ] ) ) ? $request[ 'If-Modified-Since' ] : null; - } else { - if ( isset( $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ] ) ) - $remote_mod_time = $_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ]; - else - $remote_mod_time = null; + $headers = apache_request_headers(); + $remote_mod_time = isset ( $headers['If-Modified-Since'] ) ? $headers['If-Modified-Since'] : null; + + if ( is_null( $remote_mod_time ) && isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { + $remote_mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE']; } + $local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT'; - if ( !is_null($remote_mod_time) && $remote_mod_time == $local_mod_time ) { + if ( ! is_null( $remote_mod_time ) && $remote_mod_time == $local_mod_time ) { header( $_SERVER[ 'SERVER_PROTOCOL' ] . " 304 Not Modified" ); exit(); } @@ -322,6 +320,7 @@ function wp_cache_late_loader() { } function wp_cache_get_cookies_values() { + global $wpsc_cookies; static $string = ''; if ( $string != '' ) { @@ -350,6 +349,20 @@ function wp_cache_get_cookies_values() { // If you use this hook, make sure you update your .htaccess rules with the same conditions $string = do_cacheaction( 'wp_cache_get_cookies_values', $string ); + + if ( + isset( $wpsc_cookies ) && + is_array( $wpsc_cookies ) && + ! empty( $wpsc_cookies ) + ) { + foreach( $wpsc_cookies as $name ) { + if ( isset( $_COOKIE[ $name ] ) ) { + wp_cache_debug( "wp_cache_get_cookies_values - found extra cookie: $name" ); + $string .= $name . "=" . $_COOKIE[ $name ] . ","; + } + } + } + if ( $string != '' ) $string = md5( $string ); @@ -698,9 +711,10 @@ function wpsc_delete_files( $dir, $delete = true ) { } } + $orig_dir = $dir; $dir = wpsc_get_realpath( $dir ); if ( ! $dir ) { - wp_cache_debug( 'wpsc_delete_files: directory does not exist: ' . $dir ); + wp_cache_debug( 'wpsc_delete_files: directory does not exist: ' . $orig_dir ); return false; } @@ -1340,15 +1354,21 @@ function wpcache_logged_in_message() { function wp_cache_user_agent_is_rejected() { global $cache_rejected_user_agent; - if (!function_exists('apache_request_headers')) return false; + if ( empty( $cache_rejected_user_agent ) || ! is_array( $cache_rejected_user_agent ) ) { + return false; + } + $headers = apache_request_headers(); - if (!isset($headers["User-Agent"])) return false; - if ( false == is_array( $cache_rejected_user_agent ) ) + if ( empty( $headers['User-Agent'] ) ) { return false; - foreach ($cache_rejected_user_agent as $expr) { - if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr)) + } + + foreach ( $cache_rejected_user_agent as $user_agent ) { + if ( ! empty( $user_agent ) && stristr( $headers['User-Agent'], $user_agent ) ) { return true; + } } + return false; } @@ -2325,6 +2345,11 @@ function wp_cache_rebuild_or_delete( $file ) { function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) { global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on; + if ( $cache_max_time == 0 ) { + wp_cache_debug( "wp_cache_phase2_clean_expired: disabled because GC disabled.", 2 ); + return false; + } + clearstatcache(); if( !wp_cache_writers_entry() ) return false; @@ -2662,6 +2687,10 @@ function wpsc_delete_post_archives( $post ) { } function wpsc_delete_cats_tags( $post ) { + if ( function_exists( '_deprecated_function' ) ) { + _deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.3', 'wpsc_delete_post_archives' ); + } + $post = get_post($post); $categories = get_the_category($post->ID); if ( $categories ) { @@ -2688,32 +2717,46 @@ function wpsc_delete_cats_tags( $post ) { } function wpsc_post_transition( $new_status, $old_status, $post ) { - if ( - ($old_status == 'publish' && $new_status != 'publish' ) // post unpublished - || - ($new_status == 'publish') // post published or updated - ) { - //wpsc_delete_cats_tags( $post ); - wpsc_delete_post_archives( $post ); - $post_url = get_permalink( $post->ID ); - wpsc_delete_url_cache( $post_url ); + + $ptype = is_object( $post ) ? get_post_type_object( $post->post_type ) : null; + if ( empty( $ptype ) || ! $ptype->public ) { + return; + } + + if ( $old_status === 'publish' && $new_status !== 'publish' ) { // post unpublished + if ( ! function_exists( 'get_sample_permalink' ) ) { + require_once( ABSPATH . 'wp-admin/includes/post.php' ); + } + list( $permalink, $post_name ) = get_sample_permalink( $post ); + $post_url = str_replace( array( "%postname%", "%pagename%" ), $post->post_name, $permalink ); + } + elseif ( $old_status !== 'publish' && $new_status === 'publish' ) { // post published + wp_cache_post_edit( $post->ID ); + return; + } + + if ( ! empty( $post_url ) ) { wp_cache_debug( 'wpsc_post_transition: deleting cache of post: ' . $post_url ); + wpsc_delete_url_cache( $post_url ); + wpsc_delete_post_archives( $post ); } } /* check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change() */ -function wp_cache_post_edit($post_id) { +function wp_cache_post_edit( $post_id ) { global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir, $wp_cache_object_cache; static $last_post_edited = -1; if ( $post_id == $last_post_edited ) { - wp_cache_debug( "wp_cache_post_edit: Already processed post $post_id.", 4 ); + $action = current_filter(); + wp_cache_debug( "wp_cache_post_edit(${action}): Already processed post $post_id.", 4 ); return $post_id; } $post = get_post( $post_id ); - if ( is_object( $post ) == false ) + if ( ! is_object( $post ) || 'auto-draft' === $post->post_status ) { return $post_id; + } // Some users are inexplicibly seeing this error on scheduled posts. // define this constant to disable the post status check. @@ -2733,8 +2776,10 @@ function wp_cache_post_edit($post_id) { prune_super_cache( get_supercache_dir(), true ); } } else { - wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on post edit.", 2 ); + $action = current_filter(); + wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on ${action}", 2 ); wp_cache_post_change( $post_id ); + wpsc_delete_post_archives( $post_id ); // delete related archive pages. } } @@ -2776,7 +2821,8 @@ function wp_cache_post_change( $post_id ) { static $last_processed = -1; if ( $post_id == $last_processed ) { - wp_cache_debug( "wp_cache_post_change: Already processed post $post_id.", 4 ); + $action = current_filter(); + wp_cache_debug( "wp_cache_post_change(${action}): Already processed post $post_id.", 4 ); return $post_id; } $post = get_post( $post_id ); @@ -2834,10 +2880,17 @@ function wp_cache_post_change( $post_id ) { if ( get_option( 'show_on_front' ) == 'page' ) { wp_cache_debug( 'Post change: deleting page_on_front and page_for_posts pages.', 4 ); wp_cache_debug( 'Post change: page_on_front ' . get_option( 'page_on_front' ), 4 ); - $permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) ); - wp_cache_debug( 'Post change: Deleting files in: ' . str_replace( '//', '/', $dir . $permalink ) ); - wpsc_rebuild_files( $dir . $permalink ); - do_action( 'gc_cache', 'prune', $permalink ); + /** + * It's possible that page_for_posts is zero. + * Quick fix to reduce issues in debugging. + */ + wp_cache_debug( 'Post change: page_for_posts ' . get_option( 'page_for_posts' ), 4 ); + if ( get_option( 'page_for_posts' ) ) { + $permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) ); + wp_cache_debug( 'Post change: Deleting files in: ' . str_replace( '//', '/', $dir . $permalink ) ); + wpsc_rebuild_files( $dir . $permalink ); + do_action( 'gc_cache', 'prune', $permalink ); + } } } else { wp_cache_debug( 'wp_cache_post_change: not deleting all pages.', 4 ); @@ -3029,4 +3082,23 @@ function wp_cache_gc_watcher() { } } -?> +if ( ! function_exists( 'apache_request_headers' ) ) { + /** + * A fallback for get request headers. + * Based on comments from http://php.net/manual/en/function.apache-request-headers.php + * + * @return array List of request headers + */ + function apache_request_headers() { + $headers = array(); + + foreach ( array_keys( $_SERVER ) as $skey ) { + if ( 0 === strpos( $skey, 'HTTP_' ) ) { + $header = implode( '-', array_map( 'ucfirst', array_slice( explode( '_', strtolower( $skey ) ) , 1 ) ) ); + $headers[ $header ] = $_SERVER[ $skey ]; + } + } + + return $headers; + } +} diff --git a/wp-content/plugins/wp-super-cache/wp-cache.php b/wp-content/plugins/wp-super-cache/wp-cache.php index 9ca88af225baa8fdbec109dddb87022c5fe07d0c..3a04cb1f8ebae2b7ba526000c9625d1c2ad4c0a6 100644 --- a/wp-content/plugins/wp-super-cache/wp-cache.php +++ b/wp-content/plugins/wp-super-cache/wp-cache.php @@ -3,7 +3,7 @@ Plugin Name: WP Super Cache Plugin URI: https://wordpress.org/plugins/wp-super-cache/ Description: Very fast caching plugin for WordPress. -Version: 1.6.2 +Version: 1.6.4 Author: Automattic Author URI: https://automattic.com/ License: GPL2+ @@ -65,9 +65,22 @@ wpsc_init(); * WP-CLI requires explicit declaration of global variables. * It's minimal list of global variables. */ -global $super_cache_enabled, $cache_enabled, $wp_cache_home_path, $cache_path; +global $super_cache_enabled, $cache_enabled, $wp_cache_mod_rewrite, $wp_cache_home_path, $cache_path, $file_prefix; +global $wp_cache_mutex_disabled, $mutex_filename, $sem_id, $wp_super_cache_late_init; +global $cache_compression, $cache_max_time, $wp_cache_shutdown_gc, $cache_rebuild_files; +global $wp_super_cache_debug, $wp_super_cache_advanced_debug, $wp_cache_debug_level, $wp_cache_debug_to_file; +global $wp_cache_debug_log, $wp_cache_debug_ip, $wp_cache_debug_username, $wp_cache_debug_email; +global $cache_time_interval, $cache_scheduled_time, $cache_schedule_interval, $cache_schedule_type, $cache_gc_email_me; +global $wp_cache_preload_on, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_taxonomies; +global $wp_cache_preload_email_me, $wp_cache_preload_email_volume; +global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes; global $wp_cache_config_file, $wp_cache_config_file_sample; +// WP-CLI: Hotfix for $blog_cache_dir for single site. It'll be removed after merging #590 +if ( empty( $GLOBALS['blog_cache_dir'] ) && ! is_multisite() ) { + $GLOBALS['blog_cache_dir'] = $cache_path; +} + if( !@include($wp_cache_config_file) ) { get_wpcachehome(); $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php'; @@ -82,9 +95,11 @@ if ( class_exists( 'WP_REST_Controller' ) ) { } function wp_super_cache_init_action() { + load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' ); wpsc_register_post_hooks(); + } add_action( 'init', 'wp_super_cache_init_action' ); @@ -222,7 +237,7 @@ function wp_cache_manager_error_checks() { return false; if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) ) { - echo '<div class="notice notice-error"><h3>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h3><p>' . + echo '<div class="notice notice-error"><h4>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h4><p>' . __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . '<br />'; @@ -236,20 +251,26 @@ function wp_cache_manager_error_checks() { } if ( '' == get_option( 'permalink_structure' ) ) { - echo '<div class="notice notice-error"><h3>' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '</h3>'; + echo '<div class="notice notice-error"><h4>' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '</h4>'; echo "<p>" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the <a href="options-permalink.php">Permalinks Options Page</a> to configure your permalinks.', 'wp-super-cache' ) . "</p>"; echo '</div>'; return false; } - if( $wp_cache_debug || !$wp_cache_cron_check ) { - if( function_exists( "wp_remote_get" ) == false ) { + if ( $wp_cache_debug || ! $wp_cache_cron_check ) { + if ( defined( 'DISABLE_WP_CRON' ) && constant( 'DISABLE_WP_CRON' ) ) { + ?> + <div class="notice notice-error"><h4><?php _e( 'CRON System Disabled', 'wp-super-cache' ); ?></h4> + <p><?php _e( 'The WordPress CRON jobs system is disabled. This means the garbage collection system will not work unless you run the CRON system manually.', 'wp-super-cache' ); ?></p> + </div> + <?php + } elseif ( function_exists( "wp_remote_get" ) == false ) { $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) ); if( strpos( $hostname, '/' ) ) $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) ); $ip = gethostbyname( $hostname ); if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) { - ?><div class="notice notice-warning"><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3> + ?><div class="notice notice-warning"><h4><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h4> <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p> <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/faq/' ); ?></p> </div> @@ -263,7 +284,7 @@ function wp_cache_manager_error_checks() { $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true)); if( is_array( $cron ) ) { if( $cron[ 'response' ][ 'code' ] == '404' ) { - ?><div class="notice notice-error"><h3>Warning! wp-cron.php not found!</h3> + ?><div class="notice notice-error"><h4>Warning! wp-cron.php not found!</h4> <p><?php _e( 'Unfortunately, WordPress cannot find the file wp-cron.php. This script is required for the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p> <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/faq/' ); ?></p> </div> @@ -294,7 +315,7 @@ function wp_cache_manager_error_checks() { } if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { - ?><div class="notice notice-warning"><h3><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h3> + ?><div class="notice notice-warning"><h4><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h4> <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p></div><?php } @@ -305,14 +326,14 @@ function wp_cache_manager_error_checks() { ! got_mod_rewrite() && ! $is_nginx ) { - ?><div class="notice notice-warning"><h3><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h3> + ?><div class="notice notice-warning"><h4><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h4> <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn’t 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files in expert mode. You will still be able to simple mode.', 'wp-super-cache' ); ?></p></div><?php } if( !is_writeable_ACLSafe( $wp_cache_config_file ) ) { if ( !defined( 'SUBMITDISABLED' ) ) define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' ); - ?><div class="notice notice-error"><h3><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h3> + ?><div class="notice notice-error"><h4><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?></h4> <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 ); ?> <?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’s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p> <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> @@ -335,7 +356,7 @@ function wp_cache_manager_error_checks() { $gc_flag = get_gc_flag(); if ( $dismiss_gc_warning == 0 ) { if ( false == maybe_stop_gc( $gc_flag ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { - ?><div class="notice notice-warning"><h3><?php _e( 'Warning! Garbage collection is not scheduled!', 'wp-super-cache' ); ?></h3> + ?><div class="notice notice-warning"><h4><?php _e( 'Warning! Garbage collection is not scheduled!', 'wp-super-cache' ); ?></h4> <p><?php _e( 'Garbage collection by this plugin clears out expired and old cached pages on a regular basis. Use <a href="#expirytime">this form</a> to enable it.', 'wp-super-cache' ); ?> </p> <form action="" method="POST"> <input type="hidden" name="action" value="dismiss_gc_warning" /> @@ -362,7 +383,7 @@ function wp_cache_manager_error_checks() { $wp_content_stat = stat(WP_CONTENT_DIR . '/'); $wp_content_mode = decoct( $wp_content_stat[ 'mode' ] & 0777 ); if( substr( $wp_content_mode, -2 ) == '77' ) { - ?><div class="notice notice-warning"><h3><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h3> + ?><div class="notice notice-warning"><h4><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h4> <p><?php printf( __( 'You should change the permissions on %s and make it more restrictive. Use your ftp client, or the following command to fix things:', 'wp-super-cache' ), WP_CONTENT_DIR ); ?> <code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p> <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> <form action="" method="POST"> @@ -385,14 +406,14 @@ function wp_cache_manager_error_checks() { } $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) ) ) { - echo '<div class="notice notice-warning"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>"; + echo '<div class="notice notice-warning"><h4>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h4>"; echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "2.0\ MMP|240x320" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></div>"; } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && ( ( '' != $wp_cache_mobile_prefixes && false === strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_prefixes ), ' ' ) ) ) || ( '' != $wp_cache_mobile_browsers && false === strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) ) ) ) ) { ?> - <div class="notice notice-warning"><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3> + <div class="notice notice-warning"><h4><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h4> <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?> <?php _e( 'Mobile support requires extra rules in your .htaccess file, or you can set the plugin to simple mode. Here are your options (in order of difficulty):', 'wp-super-cache' ); ?> <ol><li> <?php _e( 'Set the plugin to simple mode and enable mobile support.', 'wp-super-cache' ); ?></li> @@ -403,7 +424,7 @@ function wp_cache_manager_error_checks() { } if ( $cache_enabled && $super_cache_enabled && $wp_cache_mod_rewrite && $scrules == '' ) { - ?><div class='notice notice-warning'><h3><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h3> + ?><div class='notice notice-warning'><h4><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h4> <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></p></div><?php } @@ -418,8 +439,8 @@ function wp_cache_manager_error_checks() { } } if( isset( $missing_mods) && is_array( $missing_mods ) ) { - ?><div class='notice notice-warning'><h3><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h3> - <p><?php __( 'The following Apache modules are missing. The plugin will work in simple mode without them but in export mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ); ?></p><?php + ?><div class='notice notice-warning'><h4><?php _e( 'Missing Apache Modules', 'wp-super-cache' ); ?></h4> + <p><?php __( 'The following Apache modules are missing. The plugin will work in simple mode without them but in expert mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ); ?></p><?php echo "<ul>"; foreach( $missing_mods as $req => $desc ) { echo "<li> $req - $desc</li>"; @@ -438,7 +459,7 @@ function wp_cache_manager_error_checks() { if ( isset( $disable_supercache_htaccess_warning ) == false ) $disable_supercache_htaccess_warning = false; if ( ! $is_nginx && $dismiss_htaccess_warning == 0 && $wp_cache_mod_rewrite && $super_cache_enabled && $disable_supercache_htaccess_warning == false && get_option( 'siteurl' ) != get_option( 'home' ) ) { - ?><div class="notice notice-info"><h3><?php _e( '.htaccess file may need to be moved', 'wp-super-cache' ); ?></h3> + ?><div class="notice notice-info"><h4><?php _e( '.htaccess file may need to be moved', 'wp-super-cache' ); ?></h4> <p><?php _e( 'It appears you have WordPress installed in a sub directory as described <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">here</a>. Unfortunately, WordPress writes to the .htaccess in the install directory, not where your site is served from.<br />When you update the rewrite rules in this plugin you will have to copy the file to where your site is hosted. This will be fixed in the future.', 'wp-super-cache' ); ?></p> <form action="" method="POST"> <input type="hidden" name="action" value="dismiss_htaccess_warning" /> @@ -455,26 +476,40 @@ function wp_cache_manager_error_checks() { } add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' ); +/** + * Delete cache for a specific page. + */ function admin_bar_delete_page() { - // Delete cache for a specific page - if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') ) + + if ( function_exists( 'current_user_can' ) && false == current_user_can( 'delete_others_posts' ) ) { return false; - if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' && ( isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'delete-cache' ) : false ) ) { - $path = realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $_GET[ 'path' ] ) ) ) ) . '/'; - if ( $path == '/' ) { - return false; // Directory not found. Probably not cached. - } - $supercachepath = realpath(get_supercache_dir()); + } + + $req_path = filter_input( INPUT_GET, 'path' ); + $referer = wp_get_referer(); + $valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false; + + $path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false; + + if ( $path ) { + $path = trailingslashit( $path ); + $supercachepath = realpath( get_supercache_dir() ); + if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( $supercachepath ) ) != $supercachepath ) { - die( "Could not delete directory" ); + wp_die( 'Could not delete directory' ); } + wpsc_delete_files( $path ); - wp_redirect( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_GET[ 'path' ] ) ); - die(); + } + + if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) { + wp_redirect( site_url( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $req_path ) ) ); + exit; } } -if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delcachepage' ) +if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) { add_action( 'admin_init', 'admin_bar_delete_page' ); +} function wp_cache_manager_updates() { 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; @@ -793,17 +828,17 @@ function toggleLayer( whichLayer ) { // --> //Clicking header opens fieldset options jQuery(document).ready(function(){ - jQuery("fieldset h3").css("cursor","pointer").click(function(){ + jQuery("fieldset h4").css("cursor","pointer").click(function(){ jQuery(this).parent("fieldset").find("p,form,ul,blockquote").toggle("slow"); }); }); </script> <style type='text/css'> -#nav h2 { +#nav h3 { border-bottom: 1px solid #ccc; padding-bottom: 0; - height: 2em; + height: 1.5em; } table.wpsc-settings-table { clear: both; @@ -812,7 +847,7 @@ table.wpsc-settings-table { <?php echo '<a name="top"></a>'; echo '<div class="wrap">'; - echo '<h2>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h2>'; + echo '<h3>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h3>'; // set a default if ( $cache_enabled == false && isset( $wp_cache_mod_rewrite ) == false ) { @@ -858,7 +893,7 @@ table.wpsc-settings-table { $msg .="<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>"; } if ( $msg != '' ) { - echo '<div class="notice notice-warning"><h3>' . __( 'Preload Active', 'wp-super-cache' ) . '</h3>' . $msg; + echo '<div class="notice notice-warning"><h4>' . __( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg; echo '<form name="do_preload" action="" method="POST">'; echo '<input type="hidden" name="action" value="preload" />'; echo '<input type="hidden" name="page" value="wpsupercache" />'; @@ -1078,7 +1113,7 @@ table.wpsc-settings-table { <label><input type='checkbox' name='wp_cache_mfunc_enabled' <?php if( $wp_cache_mfunc_enabled ) echo "checked"; ?> value='1' <?php if ( $wp_cache_mod_rewrite ) { echo "disabled='disabled'"; } ?>> <?php _e( 'Enable dynamic caching. (See <a href="https://wordpress.org/plugins/wp-super-cache/faq/">FAQ</a> or wp-super-cache/plugins/dynamic-cache-test.php for example code.)', 'wp-super-cache' ); ?></label><br /> <label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php _e( 'Mobile device support. (External plugin or theme required. See the <a href="https://wordpress.org/plugins/wp-super-cache/faq/">FAQ</a> for further details.)', 'wp-super-cache' ); ?></label><br /> <?php if ( $wp_cache_mobile_enabled ) { - echo '<blockquote><h4>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h4>' . esc_html( $wp_cache_mobile_browsers ) . "<br /><h4>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h4>" . esc_html( $wp_cache_mobile_prefixes ) . "<br /></blockquote>"; + echo '<blockquote><h5>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h5>' . esc_html( $wp_cache_mobile_browsers ) . "<br /><h5>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h5>" . esc_html( $wp_cache_mobile_prefixes ) . "<br /></blockquote>"; } ?> <label><input type='checkbox' name='wp_cache_disable_utf8' <?php if( $wp_cache_disable_utf8 ) echo "checked"; ?> value='1'> <?php _e( 'Remove UTF8/blog charset support from .htaccess file. Only necessary if you see odd characters or punctuation looks incorrect. Requires rewrite rules update.', 'wp-super-cache' ); ?></label><br /> <label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> <?php _e( 'Clear all cache files when a post or page is published or updated.', 'wp-super-cache' ); ?></label><br /> @@ -1127,7 +1162,7 @@ table.wpsc-settings-table { </td> </tr> </table> - <h3><?php _e( 'Note:', 'wp-super-cache' ); ?></h3> + <h4><?php _e( 'Note:', 'wp-super-cache' ); ?></h4> <ol> <li><?php _e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required, then simple instructions are provided.', 'wp-super-cache' ); ?></li> <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' ), WP_CONTENT_DIR ); ?></li> @@ -1142,7 +1177,7 @@ table.wpsc-settings-table { wp_cache_edit_max_time(); - echo '<a name="files"></a><fieldset class="options"><h3>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h3>'; + echo '<a name="files"></a><fieldset class="options"><h4>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h4>'; wp_cache_edit_rejected_pages(); echo "\n"; wp_cache_edit_rejected(); @@ -1182,7 +1217,7 @@ table.wpsc-settings-table { } echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . "' /></div></form>"; if ( $cache_enabled ) { - echo "<h3>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h3>"; + echo "<h4>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h4>"; echo '<p>' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>'; echo '<p>' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.<ol><li> If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.</li><li> Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.</li></ol>', 'wp-super-cache' ) . '</p>'; if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'test' && $valid_nonce ) { @@ -1253,7 +1288,7 @@ table.wpsc-settings-table { wp_nonce_field('wp-cache'); echo '</form>'; } - echo "<h3>" . __( "Delete Cached Pages", 'wp-super-cache' ) . "</h3>"; + echo "<h4>" . __( "Delete Cached Pages", 'wp-super-cache' ) . "</h4>"; echo "<p>" . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them, use the button below.", 'wp-super-cache' ) . "</p>"; echo '<form name="wp_cache_content_delete" action="?page=wpsupercache&tab=contents" method="post">'; echo '<input type="hidden" name="wp_delete_cache" />'; @@ -1269,7 +1304,7 @@ table.wpsc-settings-table { echo "</form><br />\n"; } ?> - <h3 class="clear"><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h3> + <h4 class="clear"><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h4> <p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p> <ul style="list-style: square; margin-left: 2em;"> <li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li> @@ -1287,19 +1322,19 @@ table.wpsc-settings-table { </fieldset> </td><td valign='top' style='width: 300px'> <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 3px 15px'> - <h3><?php _e( 'More Site Speed Tools', 'wp-super-cache' ); ?></h3> + <h4><?php _e( 'More Site Speed Tools', 'wp-super-cache' ); ?></h4> <ul style="list-style: square; margin-left: 2em;"> <li><a href="https://jetpack.com/redirect/?source=jitm-wpsc-generic"><?php _e( 'Speed up images and photos (free)', 'wp-super-cache' ); ?></a></li> <li><a href="https://jetpack.com/redirect/?source=jitm-wpsc-premium"><?php _e( 'Fast video hosting (paid)', 'wp-super-cache' ); ?></a></li> </ul> - <h3><?php _e( 'Need Help?', 'wp-super-cache' ); ?></h3> + <h4><?php _e( 'Need Help?', 'wp-super-cache' ); ?></h4> <ol> <li><?php printf( __( 'Use the <a href="%1$s">Debug tab</a> for diagnostics.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache&tab=debug' ) ); ?></li> <li><?php printf( __( 'Check out the <a href="%1$s">support forum</a> and <a href="%2$s">FAQ</a>.', 'wp-super-cache' ), 'https://wordpress.org/support/plugin/wp-super-cache', 'https://wordpress.org/plugins/wp-super-cache/#faq' ); ?></li> <li><?php printf( __( 'Visit the <a href="%1$s">plugin homepage</a>.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/' ); ?></li> <li><?php printf( __( 'Try out the <a href="%1$s">development version</a> for the latest fixes (<a href="%2$s">changelog</a>).', 'wp-super-cache' ), 'https://odd.blog/y/2o', 'https://plugins.trac.wordpress.org/log/wp-super-cache/' ); ?></li> </ol> - <h3><?php _e( 'Rate This Plugin', 'wp-super-cache' ); ?></h3> + <h4><?php _e( 'Rate This Plugin', 'wp-super-cache' ); ?></h4> <p><?php printf( __( 'Please <a href="%s">rate us</a> and give feedback.', 'wp-super-cache' ), 'https://wordpress.org/support/plugin/wp-super-cache/reviews?rate=5#new-post' ); ?></p> <?php @@ -1345,7 +1380,7 @@ function wpsc_plugins_tab() { $out = ob_get_contents(); ob_end_clean(); if( SUBMITDISABLED == ' ' && $out != '' ) { - echo '<h3>' . __( 'Available Plugins', 'wp-super-cache' ) . '</h3>'; + echo '<h4>' . __( 'Available Plugins', 'wp-super-cache' ) . '</h4>'; echo "<ol>"; echo $out; echo "</ol>"; @@ -1372,9 +1407,9 @@ function wpsc_admin_tabs( $current = 0 ) { } } if ( $wp_db_version >= 15477 ) { - echo '<div id="nav"><h2 class="themes-php">'; + echo '<div id="nav"><h3 class="themes-php">'; echo implode( "", $links ); - echo '</div></h2>'; + echo '</div></h3>'; } else { echo implode( " | ", $links ); } @@ -1397,7 +1432,7 @@ function wsc_mod_rewrite() { ?> <a name="modrewrite"></a><fieldset class="options"> - <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3> + <h4><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h4> <p><?php _e( 'When Expert cache delivery is enabled a file called <em>.htaccess</em> is modified. It should probably be in the same directory as your wp-config.php. This file has special rules that serve the cached files very quickly to visitors without ever executing PHP. The .htaccess file can be updated automatically, but if that fails, the rules will be displayed here and it can be edited by you. You will not need to update the rules unless a warning shows here.', 'wp-super-cache' ); ?></p> <?php @@ -1416,11 +1451,11 @@ function wsc_mod_rewrite() { } } elseif ( $valid_nonce && isset( $_POST[ 'updatehtaccess' ] ) ) { if ( add_mod_rewrite_rules() ) { - echo "<h4>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h4>"; + echo "<h5>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h5>"; echo "<p><strong>" . sprintf( __( '%s.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:', 'wp-super-cache' ), $home_path ) . "</strong></p>\n"; } else { global $update_mod_rewrite_rules_error; - echo "<h4>" . __( 'Mod Rewrite rules must be updated!', 'wp-super-cache' ) . "</h4>"; + echo "<h5>" . __( 'Mod Rewrite rules must be updated!', 'wp-super-cache' ) . "</h5>"; echo "<p>" . sprintf( __( 'The plugin could not update %1$s.htaccess file: %2$s.<br /> The new rules go above the regular WordPress rules as shown in the code below:', 'wp-super-cache' ), $home_path, "<strong>" . $update_mod_rewrite_rules_error . "</strong>" ) . "</p>\n"; } echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>"; @@ -1447,7 +1482,7 @@ function wsc_mod_rewrite() { } function wp_cache_restore() { - echo '<fieldset class="options"><h3>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h3>'; + echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>'; echo '<form name="wp_restore" action="#top" method="post">'; echo '<input type="hidden" name="wp_restore_config" />'; echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>'; @@ -1565,7 +1600,7 @@ function wp_lock_down() { ?><a name='lockdown'></a> <fieldset class="options"> - <h3><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h3> + <h4><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h4> <p><?php _e( 'Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.', 'wp-super-cache' ); ?></p> <p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?> <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) { @@ -1589,7 +1624,7 @@ function wp_lock_down() { if( $cache_enabled == true && $super_cache_enabled == true ) { ?><a name='direct'></a> <fieldset class="options"> - <h3><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h3><?php + <h4><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h4><?php $cached_direct_pages = wpsc_update_direct_pages(); @@ -1740,7 +1775,7 @@ function wp_cache_edit_max_time() { ?><fieldset class="options"> <a name='expirytime'></a> - <h3><?php _e( 'Expiry Time & Garbage Collection', 'wp-super-cache' ); ?></h3><?php + <h4><?php _e( 'Expiry Time & Garbage Collection', 'wp-super-cache' ); ?></h4><?php ?><span id="utc-time"><?php printf( __( '<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>', 'wp-super-cache' ), date_i18n( $timezone_format, false, 'gmt' ) ); ?></span><?php $current_offset = get_option('gmt_offset'); @@ -1788,7 +1823,7 @@ function wp_cache_edit_max_time() { echo '<tr><td><label for="cache_gc_email_me"><strong>' . __( 'Notification Emails', 'wp-super-cache' ) . '</strong></label></td>'; echo "<td><input type='checkbox' id='cache_gc_email_me' name='cache_gc_email_me' " . checked( $cache_gc_email_me, 1, false ) . " /> " . __( 'Email me when the garbage collection runs.', 'wp-super-cache' ) . "</td></tr>\n"; echo "</table>\n"; - echo "<h4>" . __( 'Garbage Collection', 'wp-super-cache' ) . "</h4>"; + echo "<h5>" . __( 'Garbage Collection', 'wp-super-cache' ) . "</h5>"; echo "<ol><li>" . __( '<em>Garbage collection</em> is the simple act of throwing out your garbage. For this plugin that would be old or <em>stale</em> cached files that may be out of date. New cached files are described as <em>fresh</em>.', 'wp-super-cache' ) . "</li>\n"; echo "<li>" . __( 'Cached files are fresh for a limited length of time. You can set that time in the <em>Cache Timeout</em> text box on this page.', 'wp-super-cache' ) . "</li>\n"; echo "<li>" . __( 'Stale cached files are not removed as soon as they become stale. They have to be removed by the garbage collecter. That is why you have to tell the plugin when the garbage collector should run.', 'wp-super-cache' ) . "</li>\n"; @@ -1819,21 +1854,6 @@ function wp_cache_sanitize_value($text, & $array) { return $text; } -// from tehjosh at gamingg dot net http://uk2.php.net/manual/en/function.apache-request-headers.php#73964 -// fixed bug in second substr() -if( !function_exists('apache_request_headers') ) { - function apache_request_headers() { - $headers = array(); - foreach(array_keys($_SERVER) as $skey) { - if(substr($skey, 0, 5) == "HTTP_") { - $headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 5))))); - $headers[$headername] = $_SERVER[$skey]; - } - } - return $headers; - } -} - function wp_cache_update_rejected_ua() { global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce; @@ -1857,7 +1877,7 @@ function wp_cache_edit_rejected_ua() { wp_cache_update_rejected_ua(); - echo '<a name="useragents"></a><fieldset class="options"><h3>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h3>'; + echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>'; echo "<p>" . __( 'Strings in the HTTP ’User Agent’ header that prevent WP-Cache from caching bot, spiders, and crawlers’ requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n"; echo '<form name="wp_edit_rejected_user_agent" action="#useragents" method="post">'; echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">'; @@ -2100,7 +2120,7 @@ function wp_cache_debug_settings() { <!-- super cache --></pre></td></tr>"; echo "</table>\n"; if ( isset( $wp_super_cache_advanced_debug ) ) { - echo "<h4>" . __( 'Advanced', 'wp-super-cache' ) . "</h4><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>'; + echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>'; echo "<p>" . __( 'I’m 99% certain that they aren’t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you’re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>"; echo "<table class='form-table'>"; echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>"; @@ -2253,13 +2273,13 @@ function wp_cache_index_notice() { if ( get_site_option( 'wp_super_cache_index_detected' ) == 2 ) { update_site_option( 'wp_super_cache_index_detected', 3 ); echo "<div class='error' style='padding: 10px 10px 50px 10px'>"; - echo "<h1>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h1>'; + echo "<h2>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h2>'; echo '<p>' . __( 'All users of this site have been logged out to refresh their login cookies.', 'wp-super-cache' ) . '</p>'; echo '</div>'; return false; } elseif ( get_site_option( 'wp_super_cache_index_detected' ) != 3 ) { echo "<div id='wpsc-index-warning' class='error notice' style='padding: 10px 10px 50px 10px'>"; - echo "<h1>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h1>'; + echo "<h2>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h2>'; echo '<p>' . __( 'Your server is configured to show files and directories, which may expose sensitive data such as login cookies to attackers in the cache directories. That has been fixed by adding a file named index.html to each directory. If you use simple caching, consider moving the location of the cache directory on the Advanced Settings page.', 'wp-super-cache' ) . '</p>'; echo "<p><strong>"; _e( 'If you just installed WP Super Cache for the first time, you can dismiss this message. Otherwise, you should probably refresh the login cookies of all logged in WordPress users here by clicking the logout link below.', 'wp-super-cache' ); @@ -2493,12 +2513,12 @@ function wp_cache_create_advanced_cache() { $line = 'define( \'WPCACHEHOME\', \'' . dirname( __FILE__ ) . '/\' );'; if ( ! apply_filters( 'wpsc_enable_wp_config_edit', true ) ) { - 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>"; + echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! " . sprintf( __( 'Not allowed to edit %s per configuration.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>"; return false; } if ( !is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\( *\'WPCACHEHOME\'', $line, $global_config_file ) ) { - 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>"; + echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>"; return false; } $ret = true; @@ -2534,7 +2554,7 @@ function wp_cache_check_link() { } if( false == $ret ) { - echo '<div class="notice notice-error"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( '%s/advanced-cache.php</em> does not exist or cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</h3>"; + echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( '%s/advanced-cache.php</em> does not exist or cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</h4>"; echo "<p><ol><li>" . __( 'If it already exists, please delete the file first.', 'wp-super-cache' ) . "</li>"; echo "<li>" . sprintf( __( 'Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you’ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li>"; echo "<li>" . sprintf( __( 'Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ol>"; @@ -2563,14 +2583,14 @@ function wp_cache_check_global_config() { $line = 'define(\'WP_CACHE\', true);'; if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\( *\'WP_CACHE\'', $line, $global) ) { if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) { - echo '<div class="notice notice-error">' . __( "<h3>WP_CACHE constant set to false</h3><p>The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>"; + echo '<div class="notice notice-error">' . __( "<h4>WP_CACHE constant set to false</h4><p>The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>"; } else { echo '<div class="notice notice-error"><p>' . __( "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn’t modify it.", 'wp-super-cache' ) . "</p>"; echo "<p>" . sprintf( __( "Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by WordPress core. ", 'wp-super-cache' ), $global ) . "</p></div>"; } return false; } else { - echo "<div class='notice notice-warning'>" . __( '<h3>WP_CACHE constant added to wp-config.php</h3><p>If you continue to see this warning message please see point 5 of the <a href="https://wordpress.org/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>"; + echo "<div class='notice notice-warning'>" . __( '<h4>WP_CACHE constant added to wp-config.php</h4><p>If you continue to see this warning message please see point 5 of the <a href="https://wordpress.org/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>"; } return true; } @@ -2664,7 +2684,7 @@ function wp_cache_files() { } } echo "<a name='listfiles'></a>"; - echo '<fieldset class="options" id="show-this-fieldset"><h3>' . __( 'Cache Contents', 'wp-super-cache' ) . '</h3>'; + echo '<fieldset class="options" id="show-this-fieldset"><h4>' . __( 'Cache Contents', 'wp-super-cache' ) . '</h4>'; if ( $wp_cache_object_cache ) { echo "<p>" . __( "Object cache in use. No cache listing available.", 'wp-super-cache' ) . "</p>"; @@ -2785,7 +2805,7 @@ function wp_cache_files() { continue; foreach( array( 'cached_list' => 'Fresh', 'expired_list' => 'Stale' ) as $list => $description ) { if ( is_array( $details[ $list ] ) & !empty( $details[ $list ] ) ) { - echo "<h4>" . sprintf( __( '%s %s Files', 'wp-super-cache' ), $description, $cache_description[ $type ] ) . "</h4>"; + echo "<h5>" . sprintf( __( '%s %s Files', 'wp-super-cache' ), $description, $cache_description[ $type ] ) . "</h5>"; echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Files', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>"; $c = 1; $flip = 1; @@ -2846,6 +2866,10 @@ function wp_cache_delete_buttons() { } function delete_cache_dashboard() { + if ( function_exists( '_deprecated_function' ) ) { + _deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.4' ); + } + if ( false == wpsupercache_site_admin() ) return false; @@ -2854,7 +2878,7 @@ function delete_cache_dashboard() { echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1', 'wp-cache' ) . "' target='_blank' title='" . __( 'Delete Super Cache cached files (opens in new window)', 'wp-super-cache' ) . "'>" . __( 'Delete Cache', 'wp-super-cache' ) . "</a></li>"; } -add_action( 'dashmenu', 'delete_cache_dashboard' ); +//add_action( 'dashmenu', 'delete_cache_dashboard' ); function wpsc_dirsize($directory, $sizes) { global $cache_max_time, $cache_path, $valid_nonce, $wp_cache_preload_on, $file_prefix; @@ -3082,6 +3106,10 @@ function wp_cache_catch_404() { //add_action( 'template_redirect', 'wp_cache_catch_404' ); function wp_cache_favorite_action( $actions ) { + if ( function_exists( '_deprecated_function' ) ) { + _deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.4' ); + } + if ( false == wpsupercache_site_admin() ) return $actions; @@ -3092,7 +3120,7 @@ function wp_cache_favorite_action( $actions ) { return $actions; } -add_filter( 'favorite_actions', 'wp_cache_favorite_action' ); +//add_filter( 'favorite_actions', 'wp_cache_favorite_action' ); function wp_cache_plugin_notice( $plugin ) { global $cache_enabled; @@ -3192,7 +3220,7 @@ function wpsc_update_htaccess_form( $short_form = true ) { extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) { - echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>"; + echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>"; echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>"; } else { if ( $short_form == false ) { @@ -3202,7 +3230,7 @@ function wpsc_update_htaccess_form( $short_form = true ) { echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>"; echo "<pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>"; echo "</div>"; - echo "<h4>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</h4>"; + echo "<h5>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</h5>"; echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>"; echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>"; echo "</div>"; @@ -3289,7 +3317,7 @@ function wpsc_get_htaccess_info() { } $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST"; $condition_rules[] = "RewriteCond %{QUERY_STRING} ^$"; - $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . "|wp-postpass_).*$"; + $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . wpsc_get_extra_cookies() . "|wp-postpass_).*$"; $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]"; $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]"; if ( $wp_cache_mobile_enabled ) { @@ -3371,8 +3399,13 @@ function clear_post_supercache( $post_id ) { if ( false == @is_dir( $dir ) ) return false; - wp_cache_debug( "clear_post_supercache: deleting files in $dir", 2 ); - if ( get_post_type( $post_id ) != 'page' ) { // don't delete child pages if they exist + if ( get_supercache_dir() == $dir ) { + wp_cache_debug( "clear_post_supercache: not deleting post_id $post_id as it points at homepage: $dir" ); + return false; + } + + wp_cache_debug( "clear_post_supercache: post_id: $post_id. deleting files in $dir" ); + if ( get_post_type( $post_id ) != 'page') { // don't delete child pages if they exist prune_super_cache( $dir, true ); } else { wpsc_delete_files( $dir ); @@ -3545,6 +3578,7 @@ function wp_cron_preload_cache() { wp_cache_debug( 'wp_cron_preload_cache: scheduling the next preload in 30 seconds.', 5 ); wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' ); } + wpsc_delete_files( get_supercache_dir() ); } else { $msg = ''; update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); @@ -3562,8 +3596,10 @@ function wp_cron_preload_cache() { } if ( $wp_cache_preload_email_me ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Cache Preload Completed', 'wp-super-cache' ), home_url() ), __( "Cleaning up old supercache files.", 'wp-super-cache' ) . "\n" . $msg ); - wp_cache_debug( "wp_cron_preload_cache: clean expired cache files older than $cache_max_time seconds.", 5 ); - wp_cache_phase2_clean_expired( $file_prefix, true ); // force cleanup of old files. + if ( $cache_max_time > 0 ) { // GC is NOT disabled + wp_cache_debug( "wp_cron_preload_cache: clean expired cache files older than $cache_max_time seconds.", 5 ); + wp_cache_phase2_clean_expired( $file_prefix, true ); // force cleanup of old files. + } } @unlink( $mutex ); } @@ -3696,22 +3732,49 @@ function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual } function supercache_admin_bar_render() { - global $wp_admin_bar, $wp_cache_not_logged_in; - if ( !is_user_logged_in() || !$wp_cache_not_logged_in ) - return false; + global $wp_admin_bar; - if ( function_exists('current_user_can') && false == current_user_can('delete_others_posts') ) + if ( function_exists( '_deprecated_function' ) ) { + _deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.4' ); + } + + wpsc_admin_bar_render( $wp_admin_bar ); +} + +/** + * Adds "Delete Cache" button in WP Admin Bar. + */ +function wpsc_admin_bar_render( $wp_admin_bar ) { + + if ( ! function_exists( 'current_user_can' ) || ! is_user_logged_in() ) { return false; + } + + if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) { + $site_regex = preg_quote( rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' ), '`' ); + $req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] ); + $path = preg_replace( '`^' . $site_regex . '`', '', $req_uri ); + + $wp_admin_bar->add_menu( array( + 'parent' => '', + 'id' => 'delete-cache', + 'title' => __( 'Delete Cache', 'wp-super-cache' ), + 'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ), + 'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . urlencode( $path ) ), 'delete-cache' ) + ) ); + } - $wp_admin_bar->add_menu( array( - 'parent' => '', - 'id' => 'delete-cache', - 'title' => __( 'Delete Cache', 'wp-super-cache' ), - 'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ), - 'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . urlencode( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] ) ) ), 'delete-cache' ) - ) ); + if ( is_admin() && wpsupercache_site_admin() && current_user_can( 'manage_options' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => '', + 'id' => 'delete-cache', + 'title' => __( 'Delete Cache', 'wp-super-cache' ), + 'meta' => array( 'title' => __( 'Delete Super Cache cached files (opens in new window)', 'wp-super-cache' ), 'target' => '_blank' ), + 'href' => wp_nonce_url( admin_url( 'options-general.php?page=wpsupercache&tab=contents&wp_delete_cache=1' ), 'wp-cache' ) + ) ); + } } -add_action( 'wp_before_admin_bar_render', 'supercache_admin_bar_render' ); +add_action( 'admin_bar_menu', 'wpsc_admin_bar_render', 99 ); function wpsc_cancel_preload() { global $cache_path; @@ -4047,3 +4110,87 @@ function wpsc_update_plugin_list( $update ) { } } } + +function wpsc_add_plugin( $file ) { + global $wpsc_plugins; + if ( substr( $file, 0, strlen( ABSPATH ) ) == ABSPATH ) { + $file = substr( $file, strlen( ABSPATH ) ); // remove ABSPATH + } + if ( + ! isset( $wpsc_plugins ) || + ! is_array( $wpsc_plugins ) || + ! in_array( $file, $wpsc_plugins ) + ) { + $wpsc_plugins[] = $file; + wp_cache_setting( 'wpsc_plugins', $wpsc_plugins ); + } + return $file; +} +add_action( 'wpsc_add_plugin', 'wpsc_add_plugin' ); + +function wpsc_delete_plugin( $file ) { + global $wpsc_plugins; + if ( substr( $file, 0, strlen( ABSPATH ) ) == ABSPATH ) { + $file = substr( $file, strlen( ABSPATH ) ); // remove ABSPATH + } + if ( + isset( $wpsc_plugins ) && + is_array( $wpsc_plugins ) && + in_array( $file, $wpsc_plugins ) + ) { + unset( $wpsc_plugins[ array_search( $file, $wpsc_plugins ) ] ); + wp_cache_setting( 'wpsc_plugins', $wpsc_plugins ); + } + return $file; +} +add_action( 'wpsc_delete_plugin', 'wpsc_delete_plugin' ); + +function wpsc_get_plugins() { + global $wpsc_plugins; + return $wpsc_plugins; +} + +function wpsc_add_cookie( $name ) { + global $wpsc_cookies; + if ( + ! isset( $wpsc_cookies ) || + ! is_array( $wpsc_cookies ) || + ! in_array( $name, $wpsc_cookies ) + ) { + $wpsc_cookies[] = $name; + wp_cache_setting( 'wpsc_cookies', $wpsc_cookies ); + } + return $name; +} +add_action( 'wpsc_add_cookie', 'wpsc_add_cookie' ); + +function wpsc_delete_cookie( $name ) { + global $wpsc_cookies; + if ( + isset( $wpsc_cookies ) && + is_array( $wpsc_cookies ) && + in_array( $name, $wpsc_cookies ) + ) { + unset( $wpsc_cookies[ array_search( $name, $wpsc_cookies ) ] ); + wp_cache_setting( 'wpsc_cookies', $wpsc_cookies ); + } + return $name; +} +add_action( 'wpsc_delete_cookie', 'wpsc_delete_cookie' ); + +function wpsc_get_cookies() { + global $wpsc_cookies; + return $wpsc_cookies; +} + +function wpsc_get_extra_cookies() { + global $wpsc_cookies; + if ( + is_array( $wpsc_cookies ) && + ! empty( $wpsc_cookies ) + ) { + return '|' . implode( '|', $wpsc_cookies ); + } else { + return ''; + } +}