diff --git a/includes/pre-wp-functions.php b/includes/pre-wp-functions.php new file mode 100644 index 00000000..2535e343 --- /dev/null +++ b/includes/pre-wp-functions.php @@ -0,0 +1,16 @@ +

' . esc_html__( 'Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '

'; } } diff --git a/plugins/multisite.php b/plugins/multisite.php index df71f9ac..cf4f056d 100644 --- a/plugins/multisite.php +++ b/plugins/multisite.php @@ -47,14 +47,13 @@ function wp_super_cache_multisite_notice() { } function wp_super_cache_override_on_flag() { - global $cache_enabled, $super_cache_enabled; - if ( true !== $cache_enabled ) { + if ( true !== $GLOBALS['wpsc_config']['cache_enabled'] ) { return false; } if ( 1 === (int) get_option( 'wp_super_cache_disabled' ) ) { - $cache_enabled = false; - $super_cache_enabled = false; + $GLOBALS['wpsc_config']['cache_enabled'] = false; + $GLOBALS['wpsc_config']['super_cache_enabled'] = false; define( 'DONOTCACHEPAGE', 1 ); define( 'SUBMITDISABLED', 'disabled style="color: #aaa" ' ); if ( is_admin() ) { diff --git a/plugins/wptouch.php b/plugins/wptouch.php index 9f2209a6..e956c938 100644 --- a/plugins/wptouch.php +++ b/plugins/wptouch.php @@ -41,8 +41,7 @@ function wp_super_cache_wptouch_admin() { add_cacheaction( 'cache_admin_page', 'wp_super_cache_wptouch_admin' ); function wp_super_cache_wptouch_notice() { - global $cache_enabled; - if ( $cache_enabled ) { + if ( $GLOBALS['wpsc_config']['cache_enabled'] ) { echo '

' . __( 'WPTouch plugin detected! Please go to the Supercache plugins page and enable the WPTouch helper plugin.', 'wp-super-cache' ) . '

'; } } diff --git a/rest/class.wp-super-cache-rest-delete-cache.php b/rest/class.wp-super-cache-rest-delete-cache.php index 255458f2..40f6f6a1 100644 --- a/rest/class.wp-super-cache-rest-delete-cache.php +++ b/rest/class.wp-super-cache-rest-delete-cache.php @@ -15,19 +15,15 @@ public function callback( $request ) { wpsc_delete_post_cache( $params['id'] ); } elseif ( !empty( $params['expired'] ) ) { - global $file_prefix; - wp_cache_clean_expired( $file_prefix ); + wp_cache_clean_expired( $GLOBALS['wpsc_config']['file_prefix'] ); } elseif ( isset( $params['url'] ) ) { - global $cache_path; - - $directory = $cache_path . 'supercache/' . $params[ 'url' ]; + $directory = $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' . $params[ 'url' ]; wpsc_delete_files( $directory ); prune_super_cache( $directory . '/page', true ); } else { - global $file_prefix; - wp_cache_clean_cache( $file_prefix, !empty( $params['all'] ) ); + wp_cache_clean_cache( $GLOBALS['wpsc_config']['file_prefix'], !empty( $params['all'] ) ); } return rest_ensure_response( array( 'Cache Cleared' => true ) ); diff --git a/rest/class.wp-super-cache-rest-get-settings.php b/rest/class.wp-super-cache-rest-get-settings.php index af708f94..cda95e67 100644 --- a/rest/class.wp-super-cache-rest-get-settings.php +++ b/rest/class.wp-super-cache-rest-get-settings.php @@ -67,9 +67,7 @@ public function get_ossdl_off_blog_url() { * @return string */ public function get_cache_path_url() { - global $cache_path; - - return site_url( str_replace( ABSPATH, '', "{$cache_path}" ) ); + return site_url( str_replace( ABSPATH, '', "{$GLOBALS['wpsc_config']['cache_path']}" ) ); } /** diff --git a/rest/class.wp-super-cache-rest-get-status.php b/rest/class.wp-super-cache-rest-get-status.php index f0a4ae40..0c843b05 100644 --- a/rest/class.wp-super-cache-rest-get-status.php +++ b/rest/class.wp-super-cache-rest-get-status.php @@ -30,14 +30,13 @@ public function callback( $request ) { * @param array $status */ protected function add_preload_status( & $status ) { - global $wp_cache_config_file; - include( $wp_cache_config_file ); + wpsc_load_config(); - if ( false == $cache_enabled ) { + if ( false == $GLOBALS['wpsc_config']['cache_enabled'] ) { $status[ 'preload_disabled_cache_off' ] = true; } - if ( false == $super_cache_enabled ) { + if ( false == $GLOBALS['wpsc_config']['super_cache_enabled'] ) { $status[ 'preload_disabled_supercache_off' ] = true; } if ( true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) { @@ -49,11 +48,10 @@ protected function add_preload_status( & $status ) { * @param array $status */ protected function add_php_mod_rewrite_status( & $status ) { - global $wp_cache_config_file; - include( $wp_cache_config_file ); + wpsc_load_config(); - if ( $cache_enabled && !$wp_cache_mod_rewrite ) { + if ( $GLOBALS['wpsc_config']['cache_enabled'] && ! $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ) { $scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) ); if ( $scrules != '' ) { $status[ 'php_mod_rewrite' ] = true; @@ -87,12 +85,12 @@ protected function add_compression_status( & $status ) { * @param array $status */ protected function add_rewrite_status( & $status ) { - global $home_path, $wp_cache_config_file; + global $home_path; - include( $wp_cache_config_file ); + wpsc_load_config(); // Return if the rewrite caching is disabled. - if ( ! $cache_enabled || ! $super_cache_enabled || ! $wp_cache_mod_rewrite ) { + if ( ! $GLOBALS['wpsc_config']['cache_enabled'] || ! $GLOBALS['wpsc_config']['super_cache_enabled'] || ! $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ) { return; } @@ -103,7 +101,7 @@ protected function add_rewrite_status( & $status ) { $status[ 'mod_rewrite_rules' ] = true; } $got_rewrite = apache_mod_loaded( 'mod_rewrite', true ); - if ( $wp_cache_mod_rewrite && false == apply_filters( 'got_rewrite', $got_rewrite ) ) { + if ( $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] && false == apply_filters( 'got_rewrite', $got_rewrite ) ) { $status[ 'mod_rewrite_missing' ] = true; } diff --git a/rest/class.wp-super-cache-rest-test-cache.php b/rest/class.wp-super-cache-rest-test-cache.php index b79f621a..0625231c 100644 --- a/rest/class.wp-super-cache-rest-test-cache.php +++ b/rest/class.wp-super-cache-rest-test-cache.php @@ -9,8 +9,6 @@ class WP_Super_Cache_Rest_Test_Cache extends WP_REST_Controller { * @return WP_Error|WP_REST_Response */ public function callback( $request ) { - global $cache_path; - $url = trailingslashit( get_bloginfo( 'url' ) ); $response = array( 'status' => 'UNKNOWN' ); @@ -24,7 +22,7 @@ public function callback( $request ) { $page[ $c ] = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); if ( ! is_wp_error( $page[ $c ] ) ) { - $fp = fopen( $cache_path . $c . ".html", "w" ); + $fp = fopen( $GLOBALS['wpsc_config']['cache_path'] . $c . ".html", "w" ); fwrite( $fp, $page[ $c ][ 'body' ] ); fclose( $fp ); } diff --git a/rest/class.wp-super-cache-rest-update-settings.php b/rest/class.wp-super-cache-rest-update-settings.php index 7d4c9f8a..1adf6dd9 100644 --- a/rest/class.wp-super-cache-rest-update-settings.php +++ b/rest/class.wp-super-cache-rest-update-settings.php @@ -139,9 +139,7 @@ protected function set_global( $global_name, $value ) { * @param mixed $value */ protected function set_wp_cache_location( $value ) { - global $cache_path; - - if ( $value != '' && ( ! isset( $cache_path ) || $value != $cache_path ) ) { + if ( $value != '' && ( ! isset( $GLOBALS['wpsc_config']['cache_path'] ) || $value != $GLOBALS['wpsc_config']['cache_path'] ) ) { $dir = realpath( trailingslashit( dirname( $value ) ) ); if ( $dir == false ) { $dir = WP_CONTENT_DIR . '/cache/'; @@ -159,13 +157,13 @@ protected function set_wp_cache_location( $value ) { $new_cache_path = WP_CONTENT_DIR . '/cache/'; } - if ( $new_cache_path != $cache_path ) { + if ( $new_cache_path != $GLOBALS['wpsc_config']['cache_path'] ) { if ( file_exists( $new_cache_path ) == false ) { - rename( $cache_path, $new_cache_path ); + rename( $GLOBALS['wpsc_config']['cache_path'], $new_cache_path ); } - $cache_path = $new_cache_path; - wp_cache_setting( 'cache_path', $cache_path ); + $GLOBALS['wpsc_config']['cache_path'] = $new_cache_path; + wp_cache_setting( 'cache_path', $GLOBALS['wpsc_config']['cache_path'] ); } } @@ -194,7 +192,6 @@ protected function set_lock_down( $value ) { * @param mixed $value */ protected function set_super_cache_enabled( $value ) { - global $wp_cache_mod_rewrite; if ( is_numeric( $value ) == false ) { $types = array( 'wpcache' => 0, 'mod_rewrite' => 1, 'PHP' => 2 ); @@ -210,19 +207,19 @@ protected function set_super_cache_enabled( $value ) { } else { wp_super_cache_enable(); - $wp_cache_mod_rewrite = 0; // PHP recommended + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 0; // PHP recommended if ( $value == 1 ) { // mod_rewrite - $wp_cache_mod_rewrite = 1; + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 1; add_mod_rewrite_rules(); } elseif( $value == 2 ) { // PHP - $wp_cache_mod_rewrite = 0; + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 0; remove_mod_rewrite_rules(); } - wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite ); + wp_cache_setting( 'wp_cache_mod_rewrite', $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ); } return true; } @@ -231,11 +228,11 @@ protected function set_super_cache_enabled( $value ) { * @param mixed $value */ protected function set_wp_cache_not_logged_in( $value ) { - global $wp_cache_not_logged_in, $cache_path; + global $wp_cache_not_logged_in; if ( 0 != $value ) { if ( 0 == $wp_cache_not_logged_in && function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } $wp_cache_not_logged_in = (int) $value; @@ -251,11 +248,11 @@ protected function set_wp_cache_not_logged_in( $value ) { * @param mixed $value */ protected function set_wp_cache_make_known_anon( $value ) { - global $wp_cache_make_known_anon, $cache_path; + global $wp_cache_make_known_anon; if ( 1 == $value ) { if ( $wp_cache_make_known_anon == 0 && function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } $wp_cache_make_known_anon = 1; @@ -271,7 +268,7 @@ protected function set_wp_cache_make_known_anon( $value ) { * @param mixed $value */ protected function set_wp_cache_object_cache( $value ) { - global $_wp_using_ext_object_cache, $wp_cache_object_cache, $cache_path; + global $_wp_using_ext_object_cache, $wp_cache_object_cache; if ( ! $_wp_using_ext_object_cache ) { return; @@ -279,7 +276,7 @@ protected function set_wp_cache_object_cache( $value ) { if ( $value == 0 ) { if ( function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } $wp_cache_object_cache = 1; @@ -297,12 +294,10 @@ protected function set_wp_cache_object_cache( $value ) { * @return null|string */ protected function set_cache_compression( $value ) { - global $cache_compression, $cache_path; - $new_cache_compression = 0; if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) { - $cache_compression = 0; - wp_cache_setting( 'cache_compression', $cache_compression ); + $GLOBALS['wpsc_config']['cache_compression'] = 0; + wp_cache_setting( 'cache_compression', $GLOBALS['wpsc_config']['cache_compression'] ); } else { if ( 1 == $value ) { @@ -313,11 +308,11 @@ protected function set_cache_compression( $value ) { return __( "You attempted to enable compression but `zlib.output_compression` is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ); } - if ( $new_cache_compression != $cache_compression ) { - $cache_compression = $new_cache_compression; - wp_cache_setting( 'cache_compression', $cache_compression ); + if ( $new_cache_compression != $GLOBALS['wpsc_config']['cache_compression'] ) { + $GLOBALS['wpsc_config']['cache_compression'] = $new_cache_compression; + wp_cache_setting( 'cache_compression', $GLOBALS['wpsc_config']['cache_compression'] ); if ( function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } delete_option( 'super_cache_meta' ); @@ -447,7 +442,7 @@ protected function set_preload_setting( $value, $name ) { * @param bool $enabled */ protected function toggle_easy_caching( $enabled = true ) { - global $cache_path, $wp_cache_shutdown_gc, $cache_schedule_type; + global $cache_schedule_type; if ( $enabled ) { $settings = array( 'wp_cache_mobile_enabled' => 1, @@ -475,8 +470,8 @@ protected function toggle_easy_caching( $enabled = true ) { $this->set_value_by_key( $value, $key ); } - if ( $cache_path != WP_CONTENT_DIR . '/cache/' ) { - $this->set_value_by_key( $cache_path, 'wp_cache_location' ); + if ( $GLOBALS['wpsc_config']['cache_path'] != WP_CONTENT_DIR . '/cache/' ) { + $this->set_value_by_key( $GLOBALS['wpsc_config']['cache_path'], 'wp_cache_location' ); } $advanced_settings = array( diff --git a/wp-cache-base.php b/wp-cache-base.php index df65196c..36c7d9e1 100644 --- a/wp-cache-base.php +++ b/wp-cache-base.php @@ -1,5 +1,5 @@ 0 && ( filemtime( $file ) + $cache_max_time ) < time() ) { - wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $cache_max_time ) ); + } elseif ( $GLOBALS['wpsc_config']['cache_max_time'] > 0 && ( filemtime( $file ) + $GLOBALS['wpsc_config']['cache_max_time'] ) < time() ) { + wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $GLOBALS['wpsc_config']['cache_max_time'] ) ); return false; } if ( isset( $wp_cache_mfunc_enabled ) == false ) $wp_cache_mfunc_enabled = 0; - if ( false == isset( $wp_cache_home_path ) ) - $wp_cache_home_path = '/'; + if ( false == isset( $GLOBALS['wpsc_config']['wp_cache_home_path'] ) ) + $GLOBALS['wpsc_config']['wp_cache_home_path'] = '/'; // make sure ending slashes are ok - if ( $wp_cache_request_uri == $wp_cache_home_path || ( $wp_cache_slash_check && substr( $wp_cache_request_uri, -1 ) == '/' ) || ( $wp_cache_slash_check == 0 && substr( $wp_cache_request_uri, -1 ) != '/' ) ) { + if ( $wp_cache_request_uri == $GLOBALS['wpsc_config']['wp_cache_home_path'] || ( $wp_cache_slash_check && substr( $wp_cache_request_uri, -1 ) == '/' ) || ( $wp_cache_slash_check == 0 && substr( $wp_cache_request_uri, -1 ) != '/' ) ) { if ( $wp_cache_mfunc_enabled == 0 ) { // get data from file @@ -208,7 +207,7 @@ function wp_cache_serve_cache_file() { $cache_file = do_cacheaction( 'wp_cache_served_cache_file', $cache_file ); // Sometimes the gzip headers are lost. Make sure html returned isn't compressed! - if ( $cache_compression && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) { + if ( $GLOBALS['wpsc_config']['cache_compression'] && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) { $ungzip = true; wp_cache_debug( 'GZIP headers not found. Force uncompressed output.', 1 ); } else { @@ -265,12 +264,11 @@ function wp_cache_get_legacy_cache( $cache_file ) { } function wp_cache_postload() { - global $cache_enabled, $wp_super_cache_late_init; - - if ( !$cache_enabled ) + if ( ! $GLOBALS['wpsc_config']['cache_enabled'] ) { return true; + } - if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) { + if ( isset( $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) && true == $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) { wp_cache_debug( 'Supercache Late Init: add wp_cache_serve_cache_file to init', 3 ); add_action( 'init', 'wp_cache_late_loader', 9999 ); } else { @@ -525,7 +523,7 @@ function wp_cache_check_mobile( $cache_key ) { * @param $level int */ function wp_cache_debug( $message, $level = 1 ) { - global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug; + global $wp_cache_debug_ip; static $last_message = ''; if ( $last_message == $message ) { @@ -534,13 +532,11 @@ function wp_cache_debug( $message, $level = 1 ) { $last_message = $message; // If either of the debug or log globals aren't set, then we can stop - if ( !isset($wp_super_cache_debug) - || !isset($wp_cache_debug_log) ) + if ( ! isset( $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) || ! isset( $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) ) return false; // If either the debug or log globals are false or empty, we can stop - if ( $wp_super_cache_debug == false - || $wp_cache_debug_log == '' ) + if ( $GLOBALS['wpsc_config']['wp_super_cache_debug'] == false || $GLOBALS['wpsc_config']['wp_cache_debug_log'] == '' ) return false; // If the debug_ip has been set, but it doesn't match the ip of the requester @@ -553,15 +549,14 @@ function wp_cache_debug( $message, $level = 1 ) { // Log message: Date URI Message $log_message = date('H:i:s') . " " . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL; // path to the log file in the cache folder - $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log)); + $log_file = $GLOBALS['wpsc_config']['cache_path'] . str_replace( '/', '', str_replace( '..', '', $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) ); if ( ! file_exists( $log_file ) && function_exists( 'wpsc_create_debug_log' ) ) { - global $wp_cache_debug_username; - if ( ! isset( $wp_cache_debug_username ) ) { - $wp_cache_debug_username = ''; + if ( ! isset( $GLOBALS['wpsc_config']['wp_cache_debug_username'] ) ) { + $GLOBALS['wpsc_config']['wp_cache_debug_username'] = ''; } - wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ); + wpsc_create_debug_log( $GLOBALS['wpsc_config']['wp_cache_debug_log'], $GLOBALS['wpsc_config']['wp_cache_debug_username'] ); } error_log( $log_message, 3, $log_file ); @@ -610,16 +605,15 @@ function wpsc_is_backend() { } function get_supercache_dir( $blog_id = 0 ) { - global $cache_path; if ( $blog_id == 0 ) { $home = get_option( 'home' ); } else { $home = get_blog_option( $blog_id, 'home' ); } - return trailingslashit( apply_filters( 'wp_super_cache_supercachedir', $cache_path . 'supercache/' . trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', str_replace( 'https://', '', $home ) ) ) ) ) ) ); + return trailingslashit( apply_filters( 'wp_super_cache_supercachedir', $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' . trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', str_replace( 'https://', '', $home ) ) ) ) ) ) ); } function get_current_url_supercache_dir( $post_id = 0 ) { - global $cached_direct_pages, $cache_path, $wp_cache_request_uri, $WPSC_HTTP_HOST, $wp_cache_home_path; + global $cached_direct_pages, $wp_cache_request_uri, $WPSC_HTTP_HOST; static $saved_supercache_dir = array(); if ( isset( $saved_supercache_dir[ $post_id ] ) ) { @@ -651,8 +645,8 @@ function get_current_url_supercache_dir( $post_id = 0 ) { } } else { $uri = str_replace( $site_url, '', $permalink ); - if ( strpos( $uri, $wp_cache_home_path ) !== 0 ) - $uri = rtrim( $wp_cache_home_path, '/' ) . $uri; + if ( strpos( $uri, $GLOBALS['wpsc_config']['wp_cache_home_path'] ) !== 0 ) + $uri = rtrim( $GLOBALS['wpsc_config']['wp_cache_home_path'], '/' ) . $uri; } } else { $uri = strtolower( $wp_cache_request_uri ); @@ -669,7 +663,7 @@ function get_current_url_supercache_dir( $post_id = 0 ) { } else { $dir = do_cacheaction( 'supercache_dir', $dir ); } - $dir = $cache_path . 'supercache/' . $dir . '/'; + $dir = $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' . $dir . '/'; if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) { $dir = ABSPATH . $uri . '/'; } @@ -715,7 +709,6 @@ function wpsc_get_realpath( $directory ) { // return true if directory is in the cache directory function wpsc_is_in_cache_directory( $directory ) { - global $cache_path; static $rp_cache_path = ''; if ( $directory == '' ) { @@ -723,13 +716,13 @@ function wpsc_is_in_cache_directory( $directory ) { return false; } - if ( $cache_path == '' ) { + if ( $GLOBALS['wpsc_config']['cache_path'] == '' ) { wp_cache_debug( 'wpsc_is_in_cache_directory: exiting as cache_path is blank' ); return false; } if ( $rp_cache_path == '' ) { - $rp_cache_path = wpsc_get_realpath( $cache_path ); + $rp_cache_path = wpsc_get_realpath( $GLOBALS['wpsc_config']['cache_path'] ); } if ( ! $rp_cache_path ) { @@ -752,7 +745,6 @@ function wpsc_is_in_cache_directory( $directory ) { } function wpsc_delete_files( $dir, $delete = true ) { - global $cache_path; static $protected = ''; if ( $dir == '' ) { @@ -763,7 +755,7 @@ function wpsc_delete_files( $dir, $delete = true ) { // only do this once, this function will be called many times if ( $protected == '' ) { - $protected = array( $cache_path, $cache_path . "blogs/", $cache_path . 'supercache' ); + $protected = array( $GLOBALS['wpsc_config']['cache_path'], $GLOBALS['wpsc_config']['cache_path'] . "blogs/", $GLOBALS['wpsc_config']['cache_path'] . 'supercache' ); foreach( $protected as $id => $directory ) { $protected[ $id ] = trailingslashit( wpsc_get_realpath( $directory ) ); } @@ -813,7 +805,7 @@ function wpsc_delete_files( $dir, $delete = true ) { } function get_all_supercache_filenames( $dir = '' ) { - global $wp_cache_mobile_enabled, $cache_path; + global $wp_cache_mobile_enabled; $dir = wpsc_get_realpath( $dir ); if ( ! $dir ) { @@ -952,7 +944,7 @@ function wpsc_is_caching_user_disabled() { /* returns true/false depending on location of $dir. */ function wp_cache_confirm_delete( $dir ) { - global $cache_path, $blog_cache_dir; + global $blog_cache_dir; // don't allow cache_path, blog cache dir, blog meta dir, supercache. $dir = wpsc_get_realpath( $dir ); @@ -965,10 +957,10 @@ function wp_cache_confirm_delete( $dir ) { return false; } - $rp_cache_path = wpsc_get_realpath( $cache_path ); + $rp_cache_path = wpsc_get_realpath( $GLOBALS['wpsc_config']['cache_path'] ); if ( ! $rp_cache_path ) { - wp_cache_debug( "wp_cache_confirm_delete: cache_path does not exist: $cache_path" ); + wp_cache_debug( "wp_cache_confirm_delete: cache_path does not exist: " . $GLOBALS['wpsc_config']['cache_path'] ); return false; } @@ -977,7 +969,7 @@ function wp_cache_confirm_delete( $dir ) { $dir == $rp_cache_path || $dir == wpsc_get_realpath( $blog_cache_dir ) || $dir == wpsc_get_realpath( $blog_cache_dir . "meta/" ) || - $dir == wpsc_get_realpath( $cache_path . "supercache" ) + $dir == wpsc_get_realpath( $GLOBALS['wpsc_config']['cache_path'] . "supercache" ) ) { return false; } else { @@ -998,64 +990,62 @@ function wpsc_deep_replace( $search, $subject ) { } function wpsc_get_protected_directories() { - global $cache_path, $blog_cache_dir; + global $blog_cache_dir; return apply_filters( 'wpsc_protected_directories', array( - $cache_path . '.htaccess', - $cache_path . "index.html", + $GLOBALS['wpsc_config']['cache_path'] . '.htaccess', + $GLOBALS['wpsc_config']['cache_path'] . "index.html", $blog_cache_dir, $blog_cache_dir . "index.html", $blog_cache_dir . 'meta', $blog_cache_dir . 'meta/index.html', - $cache_path . 'supercache/index.html', - $cache_path . 'supercache' ) + $GLOBALS['wpsc_config']['cache_path'] . 'supercache/index.html', + $GLOBALS['wpsc_config']['cache_path'] . 'supercache' ) ); } function wpsc_debug_username() { - global $wp_cache_debug_username; - if ( ! isset( $wp_cache_debug_username ) || $wp_cache_debug_username == '' ) { - $wp_cache_debug_username = md5( time() + mt_rand() ); - wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username ); + if ( ! isset( $GLOBALS['wpsc_config']['wp_cache_debug_username'] ) || $GLOBALS['wpsc_config']['wp_cache_debug_username'] == '' ) { + $GLOBALS['wpsc_config']['wp_cache_debug_username'] = md5( time() + mt_rand() ); + wp_cache_setting( 'wp_cache_debug_username', $GLOBALS['wpsc_config']['wp_cache_debug_username'] ); } - return $wp_cache_debug_username; + return $GLOBALS['wpsc_config']['wp_cache_debug_username']; } function wpsc_create_debug_log( $filename = '', $username = '' ) { - global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log; if ( $filename != '' ) { - $wp_cache_debug_log = $filename; + $GLOBALS['wpsc_config']['wp_cache_debug_log'] = $filename; } else { - $wp_cache_debug_log = md5( time() + mt_rand() ) . ".php"; + $GLOBALS['wpsc_config']['wp_cache_debug_log'] = md5( time() + mt_rand() ) . ".php"; } if ( $username != '' ) { - $wp_cache_debug_username = $username; + $GLOBALS['wpsc_config']['wp_cache_debug_username'] = $username; } else { - $wp_cache_debug_username = wpsc_debug_username(); + $GLOBALS['wpsc_config']['wp_cache_debug_username'] = wpsc_debug_username(); } $msg = 'die( "Please use the viewer" );' . PHP_EOL; - $fp = fopen( $cache_path . $wp_cache_debug_log, 'w' ); + $fp = fopen( $GLOBALS['wpsc_config']['cache_path'] . $GLOBALS['wpsc_config']['wp_cache_debug_log'], 'w' ); if ( $fp ) { fwrite( $fp, '<' . "?php\n" ); fwrite( $fp, $msg ); fwrite( $fp, '?' . ">
" . PHP_EOL );
 		fwrite( $fp, '<' . '?php // END HEADER ?' . '>' . PHP_EOL );
 		fclose( $fp );
-		wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
-		wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
+		wp_cache_setting( 'wp_cache_debug_log', $GLOBALS['wpsc_config']['wp_cache_debug_log'] );
+		wp_cache_setting( 'wp_cache_debug_username', $GLOBALS['wpsc_config']['wp_cache_debug_username'] );
 	}
 
 	$msg = '
-if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) {
+if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $GLOBALS['wpsc_config']['wp_cache_debug_username'] . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $GLOBALS['wpsc_config']['wp_cache_debug_username'] . '" ) ) {
 	header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
 	header( $_SERVER[ "SERVER_PROTOCOL" ] . " 401 Unauthorized" );
 	echo "You must login to view the debug log";
 	exit;
 }' . PHP_EOL;
 
-	$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
+	$fp = fopen( $GLOBALS['wpsc_config']['cache_path'] . 'view_' . $GLOBALS['wpsc_config']['wp_cache_debug_log'], 'w' );
 	if ( $fp ) {
 		fwrite( $fp, '<' . "?php" . PHP_EOL );
-		$msg .= '$debug_log = file( "./' . $wp_cache_debug_log . '" );
+		$msg .= '$debug_log = file( "./' . $GLOBALS['wpsc_config']['wp_cache_debug_log'] . '" );
 $start_log = 1 + array_search( "<" . "?php // END HEADER ?" . ">" . PHP_EOL, $debug_log );
 if ( $start_log > 1 ) {
 	$debug_log = array_slice( $debug_log, $start_log );
@@ -1119,7 +1109,7 @@ function wpsc_create_debug_log( $filename = '', $username = '' ) {
 		fclose( $fp );
 	}
 
-	return array( 'wp_cache_debug_log' => $wp_cache_debug_log, 'wp_cache_debug_username' => $wp_cache_debug_username );
+	return array( 'wp_cache_debug_log' => $GLOBALS['wpsc_config']['wp_cache_debug_log'], 'wp_cache_debug_username' => $GLOBALS['wpsc_config']['wp_cache_debug_username'] );
 }
 
 function wpsc_delete_url_cache( $url ) {
@@ -1287,9 +1277,9 @@ function wpsc_shutdown_message() {
 }
 
 function wp_cache_phase2() {
-	global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
+	global $wp_cache_gzip_encoding, $wp_cache_gmt_offset, $wp_cache_blog_charset;
 
-	if ( $cache_enabled == false ) {
+	if ( $GLOBALS['wpsc_config']['cache_enabled'] == false ) {
 		wp_cache_debug( 'wp_cache_phase2: Caching disabled! Exit' );
 		define( 'WPSCSHUTDOWNMESSAGE', __( 'Caching disabled. Page not cached.', 'wp-super-cache' ) );
 		add_action( 'wp_footer', 'wpsc_shutdown_message' );
@@ -1327,7 +1317,7 @@ function wp_cache_phase2() {
 
 	if ( ! empty( $_GET ) ) {
 		wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . wpsc_dump_get_request(), 5 );
-		$super_cache_enabled = false;
+		$GLOBALS['wpsc_config']['super_cache_enabled'] = false;
 	}
 
 	if ( defined( 'WPSC_VARY_HEADER' ) ) {
@@ -1342,7 +1332,7 @@ function wp_cache_phase2() {
 	wp_cache_debug( 'Created output buffer', 4 );
 
 	// restore old supercache file temporarily
-	if ( ( $_SERVER['REQUEST_METHOD'] !== 'POST' && empty( $_POST ) ) && $super_cache_enabled && $cache_rebuild_files ) {
+	if ( ( $_SERVER['REQUEST_METHOD'] !== 'POST' && empty( $_POST ) ) && $GLOBALS['wpsc_config']['super_cache_enabled'] && $GLOBALS['wpsc_config']['cache_rebuild_files'] ) {
 		$user_info = wp_cache_get_cookies_values();
 
 		if( empty( $user_info )
@@ -1398,7 +1388,7 @@ function wpsc_register_post_hooks() {
 }
 
 function wpcache_do_rebuild( $dir ) {
-	global $do_rebuild_list, $cache_path, $wpsc_file_mtimes;
+	global $do_rebuild_list, $wpsc_file_mtimes;
 	wp_cache_debug( "wpcache_do_rebuild: doing rebuild for $dir" );
 
 	if ( !is_dir( $dir ) ) {
@@ -1616,9 +1606,10 @@ function wp_cache_is_rejected($uri) {
 }
 
 function wp_cache_mutex_init() {
-	global $mutex, $wp_cache_mutex_disabled, $use_flock, $blog_cache_dir, $mutex_filename, $sem_id;
+	global $mutex, $use_flock, $blog_cache_dir;
+	$mutex_filename = 'wp_cache_mutex.lock';
 
-	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
+	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) && $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) )
 		return true;
 
 	if( !is_bool( $use_flock ) ) {
@@ -1634,15 +1625,15 @@ function wp_cache_mutex_init() {
 		wp_cache_debug( "Created mutex lock on filename: {$blog_cache_dir}{$mutex_filename}", 5 );
 		$mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
 	} else {
-		wp_cache_debug( "Created mutex lock on semaphore: {$sem_id}", 5 );
-		$mutex = @sem_get( $sem_id, 1, 0666, 1 );
+		wp_cache_debug( "Created mutex lock on semaphore: {$GLOBALS['wpsc_config']['sem_id']}", 5 );
+		$mutex = @sem_get( $GLOBALS['wpsc_config']['sem_id'], 1, 0666, 1 );
 	}
 }
 
 function wp_cache_writers_entry() {
-	global $mutex, $wp_cache_mutex_disabled, $use_flock;
+	global $mutex, $use_flock;
 
-	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
+	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) && $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) )
 		return true;
 
 	if( !$mutex ) {
@@ -1662,9 +1653,9 @@ function wp_cache_writers_entry() {
 }
 
 function wp_cache_writers_exit() {
-	global $mutex, $wp_cache_mutex_disabled, $use_flock;
+	global $mutex, $use_flock;
 
-	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
+	if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) && $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ) )
 		return true;
 
 	if( !$mutex ) {
@@ -1771,7 +1762,7 @@ function wpsc_is_fatal_error() {
 }
 
 function wp_cache_ob_callback( $buffer ) {
-	global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled;
+	global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers;
 	$script = basename( $_SERVER[ 'PHP_SELF' ] );
 
 	// All the things that can stop a page being cached
@@ -1866,7 +1857,7 @@ function wp_cache_ob_callback( $buffer ) {
 	}
 
 	if ( isset( $wpsc_save_headers ) && $wpsc_save_headers )
-		$super_cache_enabled = false; // use standard caching to record headers
+		$GLOBALS['wpsc_config']['super_cache_enabled'] = false; // use standard caching to record headers
 
 	if ( $cache_this_page ) {
 
@@ -1901,7 +1892,6 @@ function wp_cache_ob_callback( $buffer ) {
 
 function wp_cache_append_tag( &$buffer ) {
 	global $wp_cache_gmt_offset, $wp_super_cache_comments;
-	global $cache_enabled, $super_cache_enabled;
 
 	if ( false == isset( $wp_super_cache_comments ) )
 		$wp_super_cache_comments = 1;
@@ -1910,7 +1900,7 @@ function wp_cache_append_tag( &$buffer ) {
 		return false;
 
 	$timestamp = gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600)));
-	if ( $cache_enabled || $super_cache_enabled ) {
+	if ( $GLOBALS['wpsc_config']['cache_enabled'] || $GLOBALS['wpsc_config']['super_cache_enabled'] ) {
 		$msg = "Cached page generated by WP-Super-Cache on $timestamp";
 	} else {
 		$msg = "Live page served on $timestamp";
@@ -1958,12 +1948,12 @@ function wp_cache_maybe_dynamic( &$buffer ) {
 }
 
 function wp_cache_get_ob(&$buffer) {
-	global $cache_enabled, $cache_path, $cache_filename, $wp_start_time, $supercachedir;
-	global $new_cache, $wp_cache_meta, $cache_compression, $wp_super_cache_query;
-	global $wp_cache_gzip_encoding, $super_cache_enabled;
+	global $cache_filename, $wp_start_time, $supercachedir;
+	global $new_cache, $wp_cache_meta, $wp_super_cache_query;
+	global $wp_cache_gzip_encoding;
 	global $gzsize, $supercacheonly;
 	global $blog_cache_dir, $wp_supercache_cache_list;
-	global $wp_cache_not_logged_in, $cache_max_time;
+	global $wp_cache_not_logged_in;
 	global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
 
 	if ( isset( $wp_cache_mfunc_enabled ) == false )
@@ -1976,7 +1966,7 @@ function wp_cache_get_ob(&$buffer) {
 	 * we avoid caching incomplete files */
 	if ( $buffer == '' ) {
 		$new_cache = false;
-		if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
+		if ( isset( $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) && $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) {
 			wp_cache_debug( "Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2 );
 			wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins." );
 		}
@@ -1984,7 +1974,7 @@ function wp_cache_get_ob(&$buffer) {
 
 	if ( isset( $wp_super_cache_query[ 'is_404' ] ) && false == apply_filters( 'wpsupercache_404', false ) ) {
 		$new_cache = false;
-		if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
+		if ( isset( $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) && $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) {
 			wp_cache_debug( '404 file not found not cached', 2 );
 			wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. 404." );
 		}
@@ -1992,7 +1982,7 @@ function wp_cache_get_ob(&$buffer) {
 
 	if ( !preg_match( apply_filters( 'wp_cache_eof_tags', '/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i' ), $buffer ) ) {
 		$new_cache = false;
-		if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
+		if ( isset( $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) && $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) {
 			wp_cache_debug( 'No closing html tag. Not caching.', 2 );
 			wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
 		}
@@ -2019,13 +2009,13 @@ function wp_cache_get_ob(&$buffer) {
 	$home_url = parse_url( trailingslashit( get_bloginfo( 'url' ) ) );
 
 	$dir = get_current_url_supercache_dir();
-	$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '',  $home_url[ 'host' ]);
-	if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
+	$supercachedir = $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' . preg_replace('/:.*$/', '',  $home_url[ 'host' ]);
+	if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $GLOBALS['wpsc_config']['super_cache_enabled'] == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
 		wp_cache_debug( 'Supercache disabled: GET or feed detected or disabled by config.', 2 );
-		$super_cache_enabled = false;
+		$GLOBALS['wpsc_config']['super_cache_enabled'] = false;
 	}
 
-	$tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
+	$tmp_wpcache_filename = $GLOBALS['wpsc_config']['cache_path'] . uniqid( mt_rand(), true ) . '.tmp';
 
 	if ( defined( 'WPSC_SUPERCACHE_ONLY' ) ) {
 		$supercacheonly = true;
@@ -2034,7 +2024,7 @@ function wp_cache_get_ob(&$buffer) {
 		$supercacheonly = false;
 	}
 
-	if( $super_cache_enabled ) {
+	if( $GLOBALS['wpsc_config']['super_cache_enabled'] ) {
 		if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
 			wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
 			$supercacheonly = true;
@@ -2043,19 +2033,18 @@ function wp_cache_get_ob(&$buffer) {
 
 	$cache_error = '';
 	if ( wpsc_is_caching_user_disabled() ) {
-		$super_cache_enabled = false;
-		$cache_enabled = false;
+		$GLOBALS['wpsc_config']['super_cache_enabled'] = false;
+		$GLOBALS['wpsc_config']['cache_enabled'] = false;
 		$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
 		wp_cache_debug( 'Not caching for known user.', 5 );
 	}
 
-	if ( !$cache_enabled ) {
+	if ( ! $GLOBALS['wpsc_config']['cache_enabled'] ) {
 		wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
 		wp_cache_writers_exit();
 		wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Check your settings page. $cache_error" );
 		if ( $wp_cache_mfunc_enabled == 1 ) {
-			global $wp_super_cache_late_init;
-			if ( false == isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init == 0 ) )
+			if ( false == isset( $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) || ( isset( $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) && $GLOBALS['wpsc_config']['wp_super_cache_late_init'] == 0 ) )
 				wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details.' );
 		}
 
@@ -2083,8 +2072,8 @@ function wp_cache_get_ob(&$buffer) {
 	if ( ! $supercacheonly ) {
 		$fr = @fopen( $tmp_wpcache_filename, 'w' );
 		if ( ! $fr ) {
-			wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
-			wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
+			wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $GLOBALS['wpsc_config']['cache_path'] ) . $cache_filename, 1 );
+			wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $GLOBALS['wpsc_config']['cache_path'] ) . $cache_filename );
 			wp_cache_writers_exit();
 			return wp_cache_maybe_dynamic( $buffer );
 		}
@@ -2092,7 +2081,7 @@ function wp_cache_get_ob(&$buffer) {
 		$user_info = wp_cache_get_cookies_values();
 		$do_cache = apply_filters( 'do_createsupercache', $user_info );
 		if (
-			$super_cache_enabled &&
+			$GLOBALS['wpsc_config']['super_cache_enabled'] &&
 			(
 				$user_info == '' ||
 				$do_cache === true
@@ -2109,7 +2098,7 @@ function wp_cache_get_ob(&$buffer) {
 				wp_cache_writers_exit();
 				return wp_cache_maybe_dynamic( $buffer );
 			} elseif (
-				$cache_compression &&
+				$GLOBALS['wpsc_config']['cache_compression'] &&
 				(
 					! isset( $wp_cache_mfunc_enabled ) ||
 					$wp_cache_mfunc_enabled == 0
@@ -2145,8 +2134,7 @@ function wp_cache_get_ob(&$buffer) {
 			wp_cache_add_to_buffer( $buffer, "Warning! Obsolete mfunc/mclude/dynamic-cached-content tags found. Please update your theme. See http://ocaoimh.ie/y/5b for more information." );
 		}
 
-		global $wp_super_cache_late_init;
-		if ( false == isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init == 0 ) )
+		if ( false == isset( $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) || ( isset( $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ) && $GLOBALS['wpsc_config']['wp_super_cache_late_init'] == 0 ) )
 			wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.' );
 
 		if ( $fr ) { // wpcache caching
@@ -2163,7 +2151,7 @@ function wp_cache_get_ob(&$buffer) {
 			$buffer = do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
 		}
 
-		if ( $cache_compression && $wp_cache_gzip_encoding ) {
+		if ( $GLOBALS['wpsc_config']['cache_compression'] && $wp_cache_gzip_encoding ) {
 			wp_cache_debug( 'Gzipping dynamic buffer for display.', 5 );
 			wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
 			$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
@@ -2300,7 +2288,7 @@ function wp_cache_get_ob(&$buffer) {
 	}
 }
 
-function wp_cache_phase2_clean_cache($file_prefix) {
+function wp_cache_phase2_clean_cache( $file_prefix ) {
 	global $wpdb, $blog_cache_dir;
 
 	if( !wp_cache_writers_entry() )
@@ -2337,7 +2325,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 		return false;
 	}
 
-	global $cache_max_time, $cache_path, $blog_cache_dir;
+	global $blog_cache_dir;
 	static $log = 0;
 	static $protected_directories = '';
 
@@ -2356,8 +2344,8 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 		wp_cache_debug( "prune_super_cache: exiting as file/dir does not exist: $directory" );
 		return $log;
 	}
-	if( !isset( $cache_max_time ) )
-		$cache_max_time = 3600;
+	if( !isset( $GLOBALS['wpsc_config']['cache_max_time'] ) )
+		$GLOBALS['wpsc_config']['cache_max_time'] = 3600;
 
 	$now = time();
 
@@ -2374,7 +2362,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 				$entry = $directory . $entry;
 				prune_super_cache( $entry, $force, $rename );
 				// If entry is a directory, AND it's not a protected one, AND we're either forcing the delete, OR the file is out of date,
-				if( is_dir( $entry ) && !in_array( $entry, $protected_directories ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
+				if( is_dir( $entry ) && !in_array( $entry, $protected_directories ) && ( $force || @filemtime( $entry ) + $GLOBALS['wpsc_config']['cache_max_time'] <= $now ) ) {
 					// if the directory isn't empty can't delete it
 					if( $handle = @opendir( $entry ) ) {
 						$donotdelete = false;
@@ -2394,7 +2382,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 						if ( $force ) {
 							wp_cache_debug( "gc: deleted $entry, forced delete", 2 );
 						} else {
-							wp_cache_debug( "gc: deleted $entry, older than $cache_max_time seconds", 2 );
+							wp_cache_debug( "gc: deleted $entry, older than {$GLOBALS['wpsc_config']['cache_max_time']} seconds", 2 );
 						}
 					}
 				} elseif ( in_array( $entry, $protected_directories ) ) {
@@ -2403,7 +2391,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 			}
 			closedir($dh);
 		}
-	} elseif( is_file($directory) && ($force || @filemtime( $directory ) + $cache_max_time <= $now ) ) {
+	} elseif ( is_file($directory) && ($force || @filemtime( $directory ) + $GLOBALS['wpsc_config']['cache_max_time'] <= $now ) ) {
 		$oktodelete = true;
 		if ( in_array( $directory, $protected_directories ) ) {
 			wp_cache_debug( "gc: could not delete $directory as it's protected.", 2 );
@@ -2427,9 +2415,6 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
 }
 
 function wp_cache_rebuild_or_delete( $file ) {
-	global $cache_rebuild_files, $cache_path, $file_prefix;
-
-
 	if ( strpos( $file, '?' ) !== false )
 		$file = substr( $file, 0, strpos( $file, '?' ) );
 
@@ -2455,13 +2440,13 @@ function wp_cache_rebuild_or_delete( $file ) {
 		return false;
 	}
 
-	if ( substr( basename( $file ), 0, mb_strlen( $file_prefix ) ) == $file_prefix ) {
+	if ( substr( basename( $file ), 0, mb_strlen( $GLOBALS['wpsc_config']['file_prefix'] ) ) == $GLOBALS['wpsc_config']['file_prefix'] ) {
 		@unlink( $file );
 		wp_cache_debug( "rebuild_or_gc: deleted non-anonymous file: $file" );
 		return false;
 	}
 
-	if ( substr( basename( $file ), 0, 5 + mb_strlen( $file_prefix ) ) == 'meta-' . $file_prefix ) {
+	if ( substr( basename( $file ), 0, 5 + mb_strlen( $GLOBALS['wpsc_config']['file_prefix'] ) ) == 'meta-' . $GLOBALS['wpsc_config']['file_prefix'] ) {
 		@unlink( $file );
 		wp_cache_debug( "rebuild_or_gc: deleted meta file: $file" );
 		return false;
@@ -2471,7 +2456,7 @@ function wp_cache_rebuild_or_delete( $file ) {
 		wp_cache_debug( "rebuild_or_gc: file has disappeared: $file" );
 		return false;
 	}
-	if( $cache_rebuild_files && substr( $file, -14 ) != '.needs-rebuild' ) {
+	if ( $GLOBALS['wpsc_config']['cache_rebuild_files'] && substr( $file, -14 ) != '.needs-rebuild' ) {
 		if( @rename($file, $file . '.needs-rebuild') ) {
 			@touch( $file . '.needs-rebuild' );
 			wp_cache_debug( "rebuild_or_gc: rename file to {$file}.needs-rebuild", 2 );
@@ -2489,9 +2474,9 @@ 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;
+	global $blog_cache_dir, $wp_cache_preload_on;
 
-	if ( $cache_max_time == 0 ) {
+	if ( $GLOBALS['wpsc_config']['cache_max_time'] == 0 ) {
 		wp_cache_debug( "wp_cache_phase2_clean_expired: disabled because GC disabled.", 2 );
 		return false;
 	}
@@ -2505,25 +2490,25 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
 	if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
 		while ( false !== ($file = readdir($handle))) {
 			if ( preg_match("/^$file_prefix/", $file) &&
-				(@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now  ) {
+				(@filemtime( $blog_cache_dir . $file) + $GLOBALS['wpsc_config']['cache_max_time']) <= $now  ) {
 				@unlink( $blog_cache_dir . $file );
 				@unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
 				wp_cache_debug( "wp_cache_phase2_clean_expired: Deleting obsolete wpcache cache+meta files: $file" );
 				continue;
 			}
 			if($file != '.' && $file != '..') {
-				if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now  ) {
+				if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $GLOBALS['wpsc_config']['cache_max_time']) <= $now  ) {
 					if ( substr( $file, -9 ) != '.htaccess' && $file != 'index.html' ) {
 						@unlink($blog_cache_dir . $file);
-						wp_cache_debug( "Deleting $blog_cache_dir{$file}, older than $cache_max_time seconds", 5 );
+						wp_cache_debug( "Deleting $blog_cache_dir{$file}, older than {$GLOBALS['wpsc_config']['cache_max_time']} seconds", 5 );
 					}
 				}
 			}
 		}
 		closedir($handle);
 		if ( false == $wp_cache_preload_on || true == $force ) {
-			wp_cache_debug( "Doing GC on supercache dir: {$cache_path}supercache", 2 );
-			$deleted = prune_super_cache( $cache_path . 'supercache', false, false );
+			wp_cache_debug( "Doing GC on supercache dir: {$GLOBALS['wpsc_config']['cache_path']}supercache", 2 );
+			$deleted = prune_super_cache( $GLOBALS['wpsc_config']['cache_path'] . 'supercache', false, false );
 		}
 	}
 
@@ -2532,8 +2517,8 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
 }
 
 function wp_cache_shutdown_callback() {
-	global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
-	global $wp_cache_request_uri, $wp_cache_key, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
+	global $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
+	global $wp_cache_request_uri, $wp_cache_key, $wp_cache_blog_charset, $wp_cache_not_logged_in;
 	global $WPSC_HTTP_HOST, $wp_super_cache_query;
 
 	if ( ! function_exists( 'wpsc_init' ) ) {
@@ -2619,7 +2604,7 @@ function wp_cache_shutdown_callback() {
 		$wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
 	}
 
-	if ( $cache_enabled && !$supercacheonly && $new_cache ) {
+	if ( $GLOBALS['wpsc_config']['cache_enabled'] && ! $supercacheonly && $new_cache ) {
 		if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
 			wp_cache_debug( 'Sending gzip headers.', 2 );
 			$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
@@ -2686,7 +2671,7 @@ function wp_cache_no_postid($id) {
 }
 
 function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
-	global $super_cache_enabled, $wp_cache_request_uri;
+	global $wp_cache_request_uri;
 
 	if ( defined( 'DONOTDELETECACHE' ) ) {
 		return;
@@ -2728,7 +2713,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
 		} elseif( $comment['comment_approved'] == '0' ) {
 			if ( $comment[ 'comment_type' ] == '' ) {
 				wp_cache_debug( "Moderated comment. Don't delete supercache file until comment approved.", 4 );
-				$super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
+				$GLOBALS['wpsc_config']['super_cache_enabled'] = false; // don't remove the super cache static file until comment is approved
 				define( 'DONOTDELETECACHE', 1 );
 			} else {
 				wp_cache_debug( 'Moderated ping or trackback. Not deleting cache files..', 4 );
@@ -2757,16 +2742,14 @@ function wp_cache_clear_cache_on_menu() {
 
 /* Clear out the cache directory. */
 function wp_cache_clear_cache( $blog_id = 0 ) {
-	global $cache_path;
-
 	if ( $blog_id == 0 ) {
 		wp_cache_debug( 'Clearing all cached files in wp_cache_clear_cache()', 4 );
-		prune_super_cache( $cache_path . 'supercache/', true );
-		prune_super_cache( $cache_path, true );
+		prune_super_cache( $GLOBALS['wpsc_config']['cache_path'] . 'supercache/', true );
+		prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true );
 	} else {
 		wp_cache_debug( "Clearing all cached files for blog $blog_id in wp_cache_clear_cache()", 4 );
 		prune_super_cache( get_supercache_dir( $blog_id ), true );
-		prune_super_cache( $cache_path . 'blogs/', true );
+		prune_super_cache( $GLOBALS['wpsc_config']['cache_path'] . 'blogs/', true );
 	}
 
 	do_action( 'wp_cache_cleared' );
@@ -2882,7 +2865,7 @@ function wpsc_post_transition( $new_status, $old_status, $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 ) {
-	global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
+	global $wp_cache_clear_on_post_edit, $blog_cache_dir;
 	static $last_post_edited = -1;
 
 	if ( $post_id == $last_post_edited ) {
@@ -2906,7 +2889,7 @@ function wp_cache_post_edit( $post_id ) {
 	// we want to process the post again just in case it becomes published before the second time this function is called.
 	$last_post_edited = $post_id;
 	if( $wp_cache_clear_on_post_edit ) {
-		wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
+		wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$GLOBALS['wpsc_config']['cache_path']}supercache/ on post edit per config.", 2 );
 		prune_super_cache( $blog_cache_dir, true );
 		prune_super_cache( get_supercache_dir(), true );
 	} else {
@@ -2947,7 +2930,7 @@ function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
 }
 
 function wp_cache_post_change( $post_id ) {
-	global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $wp_cache_refresh_single_only;
+	global $blog_id, $blog_cache_dir, $wp_cache_refresh_single_only;
 	static $last_processed = -1;
 
 	if ( $post_id == $last_processed ) {
@@ -3034,7 +3017,7 @@ function wp_cache_post_change( $post_id ) {
 	$supercache_files_deleted = false;
 	if ( $handle = @opendir( $blog_cache_dir ) ) {
 		while ( false !== ($file = readdir($handle))) {
-			if ( strpos( $file, $file_prefix ) !== false ) {
+			if ( strpos( $file, $GLOBALS['wpsc_config']['file_prefix'] ) !== false ) {
 				if ( strpos( $file, '.html' ) ) {
 					// delete old wpcache files immediately
 					wp_cache_debug( "wp_cache_post_change: Deleting obsolete wpcache cache+meta files: $file" );
@@ -3055,7 +3038,7 @@ function wp_cache_post_change( $post_id ) {
 							wp_cache_debug( "Post change: deleting post wp-cache files for {$meta[ 'uri' ]}: $file", 4 );
 							@unlink( $blog_cache_dir . 'meta/' . $file );
 							@unlink( $blog_cache_dir . $file );
-							if ( false == $supercache_files_deleted && $super_cache_enabled == true ) {
+							if ( false == $supercache_files_deleted && $GLOBALS['wpsc_config']['super_cache_enabled'] == true ) {
 								wp_cache_debug( "Post change: deleting supercache files for {$permalink}" );
 								wpsc_rebuild_files( $dir . $permalink );
 								$supercache_files_deleted = true;
@@ -3066,7 +3049,7 @@ function wp_cache_post_change( $post_id ) {
 						wp_cache_debug( "Post change: deleting wp-cache files for {$meta[ 'uri' ]}: $file", 4 );
 						@unlink( $blog_cache_dir . 'meta/' . $file );
 						@unlink( $blog_cache_dir . $file );
-						if ( $super_cache_enabled == true ) {
+						if ( $GLOBALS['wpsc_config']['super_cache_enabled'] == true ) {
 							wp_cache_debug( "Post change: deleting supercache files for {$meta[ 'uri' ]}" );
 							wpsc_rebuild_files( $dir . $meta[ 'uri' ] );
 							do_action( 'gc_cache', 'rebuild', trailingslashit( $meta[ 'uri' ] ) );
@@ -3115,15 +3098,14 @@ function maybe_stop_gc( $flag ) {
 	}
 }
 function get_gc_flag() {
-	global $cache_path;
-	return $cache_path . strtolower( preg_replace( '!/:.*$!', '', str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'home' ) ) ) ) ) . "_wp_cache_gc.txt";
+	return $GLOBALS['wpsc_config']['cache_path'] . strtolower( preg_replace( '!/:.*$!', '', str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'home' ) ) ) ) ) . "_wp_cache_gc.txt";
 }
 
 function wp_cache_gc_cron() {
-	global $file_prefix, $cache_max_time, $cache_gc_email_me, $cache_time_interval;
+	global $cache_gc_email_me, $cache_time_interval;
 
 	$msg = '';
-	if ( $cache_max_time == 0 ) {
+	if ( $GLOBALS['wpsc_config']['cache_max_time'] == 0 ) {
 		wp_cache_debug( 'Cache garbage collection disabled because cache expiry time is zero.', 5 );
 		return false;
 	}
@@ -3141,12 +3123,12 @@ function wp_cache_gc_cron() {
 
 	wp_cache_debug( 'Cache garbage collection.', 5 );
 
-	if( !isset( $cache_max_time ) )
-		$cache_max_time = 600;
+	if( !isset( $GLOBALS['wpsc_config']['cache_max_time'] ) )
+		$GLOBALS['wpsc_config']['cache_max_time'] = 600;
 
 	$start = time();
 	$num = 0;
-	if( false === ( $num = wp_cache_phase2_clean_expired( $file_prefix ) ) ) {
+	if( false === ( $num = wp_cache_phase2_clean_expired( $GLOBALS['wpsc_config']['file_prefix'] ) ) ) {
 		wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.', 1 );
 		update_option( 'wpsupercache_gc_time', time() - ( $cache_time_interval - 10 ) ); // if GC failed then run it again in one minute
 		$msg .= __( 'Cache expiry cron job failed. Job will run again in 10 seconds.', 'wp-super-cache' ) . "\n";
@@ -3170,19 +3152,19 @@ function wp_cache_gc_cron() {
 }
 
 function schedule_wp_gc( $forced = 0 ) {
-	global $cache_schedule_type, $cache_max_time, $cache_time_interval, $cache_scheduled_time, $cache_schedule_interval;
+	global $cache_schedule_type, $cache_time_interval, $cache_scheduled_time, $cache_schedule_interval;
 
 	if ( false == isset( $cache_time_interval ) )
 		$cache_time_interval = 3600;
 
 	if ( false == isset( $cache_schedule_type ) ) {
 		$cache_schedule_type = 'interval';
-		$cache_schedule_interval = $cache_max_time;
+		$cache_schedule_interval = $GLOBALS['wpsc_config']['cache_max_time'];
 	}
 	if ( $cache_schedule_type == 'interval' ) {
-		if ( !isset( $cache_max_time ) )
-			$cache_max_time = 600;
-		if ( $cache_max_time == 0 )
+		if ( !isset( $GLOBALS['wpsc_config']['cache_max_time'] ) )
+			$GLOBALS['wpsc_config']['cache_max_time'] = 600;
+		if ( $GLOBALS['wpsc_config']['cache_max_time'] == 0 )
 			return false;
 		$last_gc = get_option( "wpsupercache_gc_time" );
 
@@ -3191,8 +3173,7 @@ function schedule_wp_gc( $forced = 0 ) {
 			$last_gc = get_option( "wpsupercache_gc_time" );
 		}
 		if ( $forced || ( $last_gc < ( time() - 60 ) ) ) { // Allow up to 60 seconds for the previous job to run
-			global $wp_cache_shutdown_gc;
-			if ( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) {
+			if ( !isset( $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] ) || $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] == 0 ) {
 				if ( !($t = wp_next_scheduled( 'wp_cache_gc' ) ) ) {
 					wp_clear_scheduled_hook( 'wp_cache_gc' );
 					wp_schedule_single_event( time() + $cache_time_interval, 'wp_cache_gc' );
diff --git a/wp-cache.php b/wp-cache.php
index d8c344ed..6c12667e 100644
--- a/wp-cache.php
+++ b/wp-cache.php
@@ -30,7 +30,7 @@
 */
 
 if ( ! function_exists( 'wp_cache_phase2' ) ) {
-	require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
+	require_once( dirname( __FILE__ ) . '/wp-cache-phase1.php');
 }
 
 if ( ! defined( 'PHP_VERSION_ID' ) ) {
@@ -72,11 +72,9 @@ function 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_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 $wpsc_config;
+global $wp_super_cache_advanced_debug, $wp_cache_debug_level, $wp_cache_debug_to_file;
+global $wp_cache_debug_ip, $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;
@@ -84,12 +82,12 @@ function wpsc_init() {
 global $wp_cache_config_file, $wp_cache_config_file_sample;
 
 // Check is cache config already loaded.
-if ( ! isset( $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite, $cache_path ) &&
+if ( ! isset( $GLOBALS['wpsc_config']['cache_enabled'], $GLOBALS['wpsc_config']['super_cache_enabled'], $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'], $GLOBALS['wpsc_config']['cache_path'] ) &&
 	empty( $wp_cache_phase1_loaded ) &&
 	// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
 	! @include( $wp_cache_config_file )
 ) {
-	@include $wp_cache_config_file_sample; // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
+	include_once './wp-cache-phase1.php';
 }
 
 include(WPCACHEHOME . 'wp-cache-base.php');
@@ -147,7 +145,7 @@ function wpsc_remove_advanced_cache() {
 }
 
 function wpsupercache_uninstall() {
-	global $wp_cache_config_file, $cache_path;
+	global $wp_cache_config_file;
 
 	wpsc_remove_advanced_cache();
 
@@ -157,10 +155,10 @@ function wpsupercache_uninstall() {
 
 	wp_cache_remove_index();
 
-	if ( ! empty( $cache_path ) ) {
-		@unlink( $cache_path . '.htaccess' );
-		@unlink( $cache_path . 'meta' );
-		@unlink( $cache_path . 'supercache' );
+	if ( ! empty( $GLOBALS['wpsc_config']['cache_path'] ) ) {
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . '.htaccess' );
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . 'meta' );
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . 'supercache' );
 	}
 
 	wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
@@ -174,16 +172,16 @@ function wpsupercache_uninstall() {
 }
 
 function wpsupercache_deactivate() {
-	global $wp_cache_config_file, $wpsc_advanced_cache_filename, $cache_path;
+	global $wp_cache_config_file, $wpsc_advanced_cache_filename;
 
 	wpsc_remove_advanced_cache();
 
-	if ( ! empty( $cache_path ) ) {
-		prune_super_cache( $cache_path, true );
+	if ( ! empty( $GLOBALS['wpsc_config']['cache_path'] ) ) {
+		prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true );
 		wp_cache_remove_index();
-		@unlink( $cache_path . '.htaccess' );
-		@unlink( $cache_path . 'meta' );
-		@unlink( $cache_path . 'supercache' );
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . '.htaccess' );
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . 'meta' );
+		@unlink( $GLOBALS['wpsc_config']['cache_path'] . 'supercache' );
 	}
 
 	wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
@@ -195,9 +193,8 @@ function wpsupercache_deactivate() {
 register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
 
 function wpsupercache_activate() {
-	global $cache_path;
-	if ( ! isset( $cache_path ) || $cache_path == '' )
-		$cache_path = WP_CONTENT_DIR . '/cache/'; // from sample config file
+	if ( ! isset( $GLOBALS['wpsc_config']['cache_path'] ) || $GLOBALS['wpsc_config']['cache_path'] == '' )
+		$GLOBALS['wpsc_config']['cache_path'] = WP_CONTENT_DIR . '/cache/'; // from sample config file
 
 	ob_start();
 	wpsc_init();
@@ -242,8 +239,8 @@ function wp_cache_network_pages() {
 add_action( 'network_admin_menu', 'wp_cache_network_pages' );
 
 function wp_cache_manager_error_checks() {
-	global $wp_cache_debug, $wp_cache_cron_check, $cache_enabled, $super_cache_enabled, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled, $wp_cache_mod_rewrite;
-	global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
+	global $wp_cache_debug, $wp_cache_cron_check, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled;
+	global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $is_nginx;
 	global $htaccess_path;
 
 	if ( ! wpsupercache_site_admin() ) {
@@ -336,9 +333,9 @@ function wp_cache_manager_error_checks() {
 	}
 
 	if (
-		$cache_enabled == true &&
-		$super_cache_enabled == true &&
-		$wp_cache_mod_rewrite &&
+		$GLOBALS['wpsc_config']['cache_enabled'] == true &&
+		$GLOBALS['wpsc_config']['super_cache_enabled'] == true &&
+		$GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] &&
 		! got_mod_rewrite() &&
 		! $is_nginx
 	) {
@@ -368,7 +365,7 @@ function wp_cache_manager_error_checks() {
 	} elseif ( !isset( $dismiss_gc_warning ) ) {
 		$dismiss_gc_warning = 0;
 	}
-	if ( $cache_enabled && ( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) && function_exists( 'get_gc_flag' ) ) {
+	if ( $GLOBALS['wpsc_config']['cache_enabled'] && ( ! isset( $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] ) || $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] == 0 ) && function_exists( 'get_gc_flag' ) ) {
 		$gc_flag = get_gc_flag();
 		if ( $dismiss_gc_warning == 0 ) {
 			if ( false == maybe_stop_gc( $gc_flag ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) {
@@ -421,10 +418,10 @@ function wp_cache_manager_error_checks() {
 		$home_path = $htaccess_path;
 	}
 	$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 ), ' ' ) ) ) {
+	if ( $GLOBALS['wpsc_config']['cache_enabled'] && $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
 		echo '

' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "

"; echo "

" . __( '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' ) . "

" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "

"; - } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && ( + } elseif ( $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] && $GLOBALS['wpsc_config']['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 ), ' ' ) ) ) ) ) { @@ -439,14 +436,14 @@ function wp_cache_manager_error_checks() {

Update Mod_Rewrite Rules button.', 'wp-super-cache' ); ?>

__( 'Required to serve compressed supercache files properly.', 'wp-super-cache' ), 'mod_headers' => __( 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'wp-super-cache' ), 'mod_expires' => __( 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.', 'wp-super-cache' ) ); foreach( $required_modules as $req => $desc ) { @@ -474,7 +471,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' ) ) { + if ( ! $is_nginx && $dismiss_htaccess_warning == 0 && $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] && $GLOBALS['wpsc_config']['super_cache_enabled'] && $disable_supercache_htaccess_warning == false && get_option( 'siteurl' ) != get_option( 'home' ) ) { ?>

here. Unfortunately, WordPress writes to the .htaccess in the install directory, not where your site is served from.
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' ); ?>

@@ -530,8 +527,8 @@ function 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_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get; - global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers; + global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_clear_on_post_edit, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_cache_refresh_single_only, $wp_supercache_304, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get; + global $cache_schedule_type, $cache_time_interval, $wpsc_save_headers; if ( !wpsupercache_site_admin() ) return false; @@ -552,18 +549,18 @@ function wp_cache_manager_updates() { $_POST[ 'super_cache_enabled' ] = 1; $_POST[ 'cache_rebuild_files' ] = 1; unset( $_POST[ 'cache_compression' ] ); - if ( $cache_path != WP_CONTENT_DIR . '/cache/' ) - $_POST[ 'wp_cache_location' ] = $cache_path; + if ( $GLOBALS['wpsc_config']['cache_path'] != WP_CONTENT_DIR . '/cache/' ) + $_POST[ 'wp_cache_location' ] = $GLOBALS['wpsc_config']['cache_path']; // // set up garbage collection with some default settings - if ( ( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { + if ( ( !isset( $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] ) || $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] == 0 ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { if ( false == isset( $cache_schedule_type ) ) { $cache_schedule_type = 'interval'; $cache_time_interval = 600; - $cache_max_time = 1800; + $GLOBALS['wpsc_config']['cache_max_time'] = 1800; wp_cache_replace_line('^ *\$cache_schedule_type', "\$cache_schedule_type = '$cache_schedule_type';", $wp_cache_config_file); wp_cache_replace_line('^ *\$cache_time_interval', "\$cache_time_interval = '$cache_time_interval';", $wp_cache_config_file); - wp_cache_replace_line('^ *\$cache_max_time', "\$cache_max_time = '$cache_max_time';", $wp_cache_config_file); + wp_cache_setting( 'cache_max_time', $GLOBALS['wpsc_config']['cache_max_time'] ); } wp_schedule_single_event( time() + 600, 'wp_cache_gc' ); } @@ -594,19 +591,19 @@ function wp_cache_manager_updates() { } else { $new_cache_path = WP_CONTENT_DIR . '/cache/'; } - if ( $new_cache_path != $cache_path ) { + if ( $new_cache_path != $GLOBALS['wpsc_config']['cache_path'] ) { if ( file_exists( $new_cache_path ) == false ) - rename( $cache_path, $new_cache_path ); - $cache_path = $new_cache_path; - wp_cache_replace_line('^ *\$cache_path', "\$cache_path = '" . $cache_path . "';", $wp_cache_config_file); + rename( $GLOBALS['wpsc_config']['cache_path'], $new_cache_path ); + $GLOBALS['wpsc_config']['cache_path'] = $new_cache_path; + wp_cache_setting( 'cache_path', $GLOBALS['wpsc_config']['cache_path'] ); } if( isset( $_POST[ 'wp_super_cache_late_init' ] ) ) { - $wp_super_cache_late_init = 1; + $GLOBALS['wpsc_config']['wp_super_cache_late_init'] = 1; } else { - $wp_super_cache_late_init = 0; + $GLOBALS['wpsc_config']['wp_super_cache_late_init'] = 0; } - wp_cache_replace_line('^ *\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file); + wp_cache_setting( 'wp_super_cache_late_init', $GLOBALS['wpsc_config']['wp_super_cache_late_init'] ); if( isset( $_POST[ 'wp_cache_disable_utf8' ] ) ) { $wp_cache_disable_utf8 = 1; @@ -662,22 +659,22 @@ function wp_cache_manager_updates() { if ( ! defined( 'DISABLE_SUPERCACHE' ) ) { wp_cache_debug( 'DISABLE_SUPERCACHE is not set, super_cache enabled.' ); wp_super_cache_enable(); - $super_cache_enabled = true; + $GLOBALS['wpsc_config']['super_cache_enabled'] = true; } } else { wp_cache_disable(); wp_super_cache_disable(); - $super_cache_enabled = false; + $GLOBALS['wpsc_config']['super_cache_enabled'] = false; } if ( isset( $_POST[ 'wp_cache_mod_rewrite' ] ) && $_POST[ 'wp_cache_mod_rewrite' ] == 1 ) { - $wp_cache_mod_rewrite = 1; + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 1; add_mod_rewrite_rules(); } else { - $wp_cache_mod_rewrite = 0; // cache files served by PHP + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 0; // cache files served by PHP remove_mod_rewrite_rules(); } - wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite ); + wp_cache_setting( 'wp_cache_mod_rewrite', $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ); if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) { $wp_cache_clear_on_post_edit = 1; @@ -687,11 +684,11 @@ function wp_cache_manager_updates() { wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file); if( isset( $_POST[ 'cache_rebuild_files' ] ) ) { - $cache_rebuild_files = 1; + $GLOBALS['wpsc_config']['cache_rebuild_files'] = 1; } else { - $cache_rebuild_files = 0; + $GLOBALS['wpsc_config']['cache_rebuild_files'] = 0; } - wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file); + wp_cache_setting( 'cache_rebuild_files', $GLOBALS['wpsc_config']['cache_rebuild_files'] ); if ( isset( $_POST[ 'wpsc_save_headers' ] ) ) { $wpsc_save_headers = 1; @@ -701,18 +698,18 @@ function wp_cache_manager_updates() { wp_cache_replace_line('^ *\$wpsc_save_headers', "\$wpsc_save_headers = " . $wpsc_save_headers . ";", $wp_cache_config_file); if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) { - $wp_cache_mutex_disabled = 0; + $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] = 0; } else { - $wp_cache_mutex_disabled = 1; + $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] = 1; } if( defined( 'WPSC_DISABLE_LOCKING' ) ) { - $wp_cache_mutex_disabled = 1; + $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] = 1; } - wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file); + wp_cache_setting( 'wp_cache_mutex_disabled', $GLOBALS['wpsc_config']['wp_cache_mutex_disabled'] ); if ( isset( $_POST['wp_cache_not_logged_in'] ) && $_POST['wp_cache_not_logged_in'] != 0 ) { if ( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } $wp_cache_not_logged_in = (int)$_POST['wp_cache_not_logged_in']; } else { @@ -722,7 +719,7 @@ function wp_cache_manager_updates() { if( isset( $_POST[ 'wp_cache_make_known_anon' ] ) ) { if( $wp_cache_make_known_anon == 0 && function_exists( 'prune_super_cache' ) ) - prune_super_cache ($cache_path, true); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); $wp_cache_make_known_anon = 1; } else { $wp_cache_make_known_anon = 0; @@ -737,8 +734,8 @@ function wp_cache_manager_updates() { wp_cache_setting( 'wp_cache_refresh_single_only', $wp_cache_refresh_single_only ); if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) { - $cache_compression = 0; - wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); + $GLOBALS['wpsc_config']['cache_compression'] = 0; + wp_cache_setting( 'cache_compression', 0 ); } else { if ( isset( $_POST[ 'cache_compression' ] ) ) { $new_cache_compression = 1; @@ -748,11 +745,11 @@ function wp_cache_manager_updates() { if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { echo '
' . __( "Warning! You attempted to enable compression but zlib.output_compression is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ) . '
'; } else { - if ( $new_cache_compression != $cache_compression ) { - $cache_compression = $new_cache_compression; - wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); + if ( $new_cache_compression != $GLOBALS['wpsc_config']['cache_compression'] ) { + $GLOBALS['wpsc_config']['cache_compression'] = $new_cache_compression; + wp_cache_setting( 'cache_compression', $GLOBALS['wpsc_config']['cache_compression'] ); if ( function_exists( 'prune_super_cache' ) ) - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); delete_option( 'super_cache_meta' ); } } @@ -763,12 +760,12 @@ function wp_cache_manager_updates() { add_action( 'admin_init', 'wp_cache_manager_updates' ); function wp_cache_manager() { - global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled; - global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get; + global $wp_cache_config_file, $valid_nonce, $supercachedir; + global $wp_cache_clear_on_post_edit, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get; global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret; global $wp_super_cache_front_page_check, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes; - global $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $wp_cache_disable_utf8, $wp_cache_mfunc_enabled; - global $wp_super_cache_comments, $wp_cache_home_path, $wpsc_save_headers, $is_nginx; + global $wp_supercache_304, $wp_cache_front_page_checks, $wp_cache_disable_utf8, $wp_cache_mfunc_enabled; + global $wp_super_cache_comments, $wpsc_save_headers, $is_nginx; if ( !wpsupercache_site_admin() ) return false; @@ -806,8 +803,8 @@ function wp_cache_manager() { $supercachedir = get_supercache_dir(); if( get_option( 'gzipcompression' ) == 1 ) update_option( 'gzipcompression', 0 ); - if( !isset( $cache_rebuild_files ) ) - $cache_rebuild_files = 0; + if( !isset( $GLOBALS['wpsc_config']['cache_rebuild_files'] ) ) + $GLOBALS['wpsc_config']['cache_rebuild_files'] = 0; $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; /* http://www.netlobo.com/div_hiding.html */ @@ -853,24 +850,24 @@ function toggleLayer( whichLayer ) { echo '

' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '

'; // Set a default. - if ( false === $cache_enabled && ! isset( $wp_cache_mod_rewrite ) ) { - $wp_cache_mod_rewrite = 0; - } elseif ( ! isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) { - $wp_cache_mod_rewrite = 1; + if ( false === $GLOBALS['wpsc_config']['cache_enabled'] && ! isset( $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ) ) { + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 0; + } elseif ( ! isset( $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ) && $GLOBALS['wpsc_config']['cache_enabled'] && $GLOBALS['wpsc_config']['super_cache_enabled'] ) { + $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] = 1; } $admin_url = admin_url( 'options-general.php?page=wpsupercache' ); $curr_tab = ! empty( $_GET['tab'] ) ? sanitize_text_field( stripslashes( $_GET['tab'] ) ) : ''; // WPCS: sanitization ok. if ( empty( $curr_tab ) ) { $curr_tab = 'easy'; - if ( $wp_cache_mod_rewrite ) { + if ( $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] ) { $curr_tab = 'settings'; echo '

' . __( 'Notice: Expert mode caching enabled. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '

'; } } if ( 'preload' === $curr_tab ) { - if ( true == $super_cache_enabled && ! defined( 'DISABLESUPERCACHEPRELOADING' ) ) { + if ( true == $GLOBALS['wpsc_config']['super_cache_enabled'] && ! defined( 'DISABLESUPERCACHEPRELOADING' ) ) { global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb; $count = wpsc_post_count(); if ( $count > 1000 ) { @@ -895,8 +892,8 @@ function toggleLayer( whichLayer ) { if ( is_array( $preload_counter ) && $preload_counter['c'] > 0 ) { $msg .= '

' . sprintf( esc_html__( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter['c'] - 100 ), $preload_counter['c'] ) . '

'; $currently_preloading = true; - if ( @file_exists( $cache_path . 'preload_permalink.txt' ) ) { - $url = file_get_contents( $cache_path . 'preload_permalink.txt' ); + if ( @file_exists( $GLOBALS['wpsc_config']['cache_path'] . 'preload_permalink.txt' ) ) { + $url = file_get_contents( $GLOBALS['wpsc_config']['cache_path'] . 'preload_permalink.txt' ); $msg .= '

' . sprintf( __( 'Page last cached: %s', 'wp-super-cache' ), $url ) . '

'; } if ( $msg != '' ) { @@ -935,11 +932,11 @@ function toggleLayer( whichLayer ) { } $home_path = parse_url( site_url() ); $home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path['path'] : '' ); - if ( ! isset( $wp_cache_home_path ) ) { - $wp_cache_home_path = '/'; + if ( ! isset( $GLOBALS['wpsc_config']['wp_cache_home_path'] ) ) { + $GLOBALS['wpsc_config']['wp_cache_home_path'] = '/'; wp_cache_setting( 'wp_cache_home_path', '/' ); } - if ( "$home_path" != "$wp_cache_home_path" ) { + if ( "$home_path" != $GLOBALS['wpsc_config']['wp_cache_home_path'] ) { wp_cache_setting( 'wp_cache_home_path', $home_path ); } @@ -961,11 +958,11 @@ function toggleLayer( whichLayer ) { wp_cache_files(); break; case 'preload': - if ( ! $cache_enabled ) { + if ( ! $GLOBALS['wpsc_config']['cache_enabled'] ) { wp_die( esc_html__( 'Caching must be enabled to use this feature', 'wp-super-cache' ) ); } echo ''; - if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) { + if ( $GLOBALS['wpsc_config']['super_cache_enabled'] == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) { echo '

' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '

'; echo '

' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '

'; echo '

' . __( 'In ’Preload Mode’ regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '

'; @@ -1062,7 +1059,7 @@ function toggleLayer( whichLayer ) {
-
@@ -1070,8 +1067,8 @@ function toggleLayer( whichLayer ) {
-
-
+
+
here but are not officially supported.', 'wp-super-cache' ), 'https://codex.wordpress.org/Nginx#WP_Super_Cache_Rules' ); ?> @@ -1093,20 +1090,20 @@ function toggleLayer( whichLayer ) {
-
+

-
- +
+


-
-
+
+
' . esc_html__( '304 support is disabled by default because some hosts have had problems with the headers used in the past.', 'wp-super-cache' ) . '
'; ?> -
+
@@ -1116,7 +1113,7 @@ function toggleLayer( whichLayer ) {
-
+

' . __( 'Mobile Browsers', 'wp-super-cache' ) . '
' . esc_html( $wp_cache_mobile_browsers ) . "
" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "
" . esc_html( $wp_cache_mobile_prefixes ) . "
"; @@ -1127,9 +1124,9 @@ function toggleLayer( whichLayer ) {

-
+
-
+
DO NOT CACHE PAGE secret key: %s', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
@@ -1139,15 +1136,15 @@ function toggleLayer( whichLayer ) {
- + ' />

  1. - strlen( ABSPATH ) && ABSPATH == substr( $cache_path, 0, strlen( ABSPATH ) ) ) { + strlen( ABSPATH ) && ABSPATH == substr( $GLOBALS['wpsc_config']['cache_path'], 0, strlen( ABSPATH ) ) ) { $msg = __( 'The plugin detected a bare directory index in your cache directory, which would let visitors see your cache files directly and might expose private posts.', 'wp-super-cache' ); - if ( ! $is_nginx && $super_cache_enabled && $wp_cache_mod_rewrite == 1 ) { + if ( ! $is_nginx && $GLOBALS['wpsc_config']['super_cache_enabled'] && $GLOBALS['wpsc_config']['wp_cache_mod_rewrite'] == 1 ) { $msg .= ' ' . __( 'You are using expert mode to serve cache files so the plugin has added Options -Indexes to the .htaccess file in the cache directory to disable indexes. However, if that does not work, you should contact your system administrator or support and ask for them to be disabled, or use simple mode and move the cache outside of the web root.', 'wp-super-cache' ); } else { $msg .= ' ' . sprintf( __( 'index.html files have been added in key directories, but unless directory indexes are disabled, it is probably better to store the cache files outside of the web root of %s', 'wp-super-cache' ), ABSPATH ) . ''; @@ -1156,7 +1153,7 @@ function toggleLayer( whichLayer ) { } ?> - +
  2. %s and update the mod_rewrite rules in the .htaccess file.', 'wp-super-cache' ), ABSPATH ); ?>
@@ -1209,8 +1206,8 @@ function toggleLayer( whichLayer ) {
-
-
+
+
@@ -1224,14 +1221,14 @@ function toggleLayer( whichLayer ) {

' . esc_html__( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '

'; } } echo '
'; - if ( $cache_enabled ) { + if ( $GLOBALS['wpsc_config']['cache_enabled'] ) { echo '

' . esc_html__( 'Cache Tester', 'wp-super-cache' ) . '

'; echo '

' . esc_html__( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '

'; echo '

' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.

  1. If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.
  2. Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.
', 'wp-super-cache' ) . '

'; @@ -1248,7 +1245,7 @@ function toggleLayer( whichLayer ) { echo '

' . sprintf( $message, $url ); $page[ $c ] = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) ); if ( ! is_wp_error( $page[ $c ] ) ) { - $fp = fopen( $cache_path . $c . '.html', 'w' ); + $fp = fopen( $GLOBALS['wpsc_config']['cache_path'] . $c . '.html', 'w' ); fwrite( $fp, $page[ $c ]['body'] ); fclose( $fp ); echo '' . esc_html__( 'OK', 'wp-super-cache' ) . " (" . $c . '.html)

'; @@ -1410,7 +1407,6 @@ function wpsc_plugins_tab() { } function wpsc_admin_tabs( $current = '' ) { - global $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite; if ( '' === $current ) { $current = ! empty( $_GET['tab'] ) ? stripslashes( $_GET['tab'] ) : ''; // WPCS: CSRF ok, sanitization ok. @@ -1441,7 +1437,7 @@ function wpsc_admin_tabs( $current = '' ) { } function wsc_mod_rewrite() { - global $valid_nonce, $cache_path; + global $valid_nonce; if ( $GLOBALS['is_nginx'] ) { return false; @@ -1525,7 +1521,7 @@ function comment_form_lockdown_message() { add_action( 'comment_form', 'comment_form_lockdown_message' ); function wp_update_lock_down() { - global $cache_path, $wp_cache_config_file, $valid_nonce; + global $wp_cache_config_file, $valid_nonce; if ( isset( $_POST[ 'wp_lock_down' ] ) && $valid_nonce ) { $wp_lock_down = $_POST[ 'wp_lock_down' ] == '1' ? '1' : '0'; @@ -1533,7 +1529,7 @@ function wp_update_lock_down() { if ( false == defined( 'WPLOCKDOWN' ) ) define( 'WPLOCKDOWN', $wp_lock_down ); if ( $wp_lock_down == '0' && function_exists( 'prune_super_cache' ) ) - prune_super_cache( $cache_path, true ); // clear the cache after lockdown + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); // clear the cache after lockdown return $wp_lock_down; } if ( defined( 'WPLOCKDOWN' ) ) @@ -1543,7 +1539,7 @@ function wp_update_lock_down() { } function wpsc_update_direct_pages() { - global $cached_direct_pages, $valid_nonce, $cache_path, $wp_cache_config_file; + global $cached_direct_pages, $valid_nonce, $wp_cache_config_file; if ( false == isset( $cached_direct_pages ) ) $cached_direct_pages = array(); @@ -1620,7 +1616,7 @@ function wpsc_update_direct_pages() { } function wp_lock_down() { - global $cached_direct_pages, $cache_enabled, $super_cache_enabled; + global $cached_direct_pages; $admin_url = admin_url( 'options-general.php?page=wpsupercache' ); $wp_lock_down = wp_update_lock_down(); @@ -1648,7 +1644,7 @@ function wp_lock_down() { echo ''; ?>

'; echo ''; echo ''; - echo "\n"; + echo "\n"; echo "\n"; echo '
" . __( "seconds", 'wp-super-cache' ) . "
" . __( "seconds", 'wp-super-cache' ) . "
" . __( 'How long should cached pages remain fresh? Set to 0 to disable garbage collection. A good starting point is 3600 seconds.', 'wp-super-cache' ) . "
' . __( 'Scheduler', 'wp-super-cache' ) . ''; echo ""; @@ -2031,9 +2028,8 @@ function wp_cache_edit_accepted() { } function wpsc_update_debug_settings() { - global $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $cache_path, $valid_nonce, $wp_cache_config_file, $wp_super_cache_comments; + global $wp_cache_debug_ip, $valid_nonce, $wp_cache_config_file, $wp_super_cache_comments; global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug; - global $wp_cache_debug_username; if ( ! isset( $wp_super_cache_comments ) ) { $wp_super_cache_comments = 1; // defaults to "enabled". @@ -2042,8 +2038,8 @@ function wpsc_update_debug_settings() { if ( false == $valid_nonce ) { return array ( - 'wp_super_cache_debug' => $wp_super_cache_debug, - 'wp_cache_debug_log' => $wp_cache_debug_log, + 'wp_super_cache_debug' => $GLOBALS['wpsc_config']['wp_super_cache_debug'], + 'wp_cache_debug_log' => $GLOBALS['wpsc_config']['wp_cache_debug_log'], 'wp_cache_debug_ip' => $wp_cache_debug_ip, 'wp_super_cache_comments' => $wp_super_cache_comments, 'wp_super_cache_front_page_check' => $wp_super_cache_front_page_check, @@ -2051,26 +2047,26 @@ function wpsc_update_debug_settings() { 'wp_super_cache_front_page_text' => $wp_super_cache_front_page_text, 'wp_super_cache_front_page_notification' => $wp_super_cache_front_page_notification, 'wp_super_cache_advanced_debug' => $wp_super_cache_advanced_debug, - 'wp_cache_debug_username' => $wp_cache_debug_username, + 'wp_cache_debug_username' => $GLOBALS['wpsc_config']['wp_cache_debug_username'], ); } - if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $_POST[ 'wpsc_delete_log' ] == 1 && $wp_cache_debug_log != '' ) { - @unlink( $cache_path . $wp_cache_debug_log ); - extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username + if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $_POST[ 'wpsc_delete_log' ] == 1 && $GLOBALS['wpsc_config']['wp_cache_debug_log'] != '' ) { + @unlink( $GLOBALS['wpsc_config']['cache_path'] . $GLOBALS['wpsc_config']['wp_cache_debug_log'] ); + wpsc_create_debug_log( $GLOBALS['wpsc_config']['wp_cache_debug_log'], $GLOBALS['wpsc_config']['wp_cache_debug_username'] ); } - if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) { - extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username - } elseif ( ! file_exists( $cache_path . $wp_cache_debug_log ) ) { // make sure debug log exists before toggling debugging - extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username + if ( ! isset( $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) || $GLOBALS['wpsc_config']['wp_cache_debug_log'] == '' ) { + wpsc_create_debug_log(); + } elseif ( ! file_exists( $GLOBALS['wpsc_config']['cache_path'] . $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) ) { // make sure debug log exists before toggling debugging + wpsc_create_debug_log( $GLOBALS['wpsc_config']['wp_cache_debug_log'], $GLOBALS['wpsc_config']['wp_cache_debug_username'] ); } - $wp_super_cache_debug = ( isset( $_POST[ 'wp_super_cache_debug' ] ) && $_POST[ 'wp_super_cache_debug' ] == 1 ) ? 1 : 0; - wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug ); + $GLOBALS['wpsc_config']['wp_super_cache_debug'] = ( isset( $_POST[ 'wp_super_cache_debug' ] ) && $_POST[ 'wp_super_cache_debug' ] == 1 ) ? 1 : 0; + wp_cache_setting( 'wp_super_cache_debug', $GLOBALS['wpsc_config']['wp_super_cache_debug'] ); if ( isset( $_POST[ 'wp_cache_debug' ] ) ) { - wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username ); - wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log ); + wp_cache_setting( 'wp_cache_debug_username', $GLOBALS['wpsc_config']['wp_cache_debug_username'] ); + wp_cache_setting( 'wp_cache_debug_log', $GLOBALS['wpsc_config']['wp_cache_debug_log'] ); $wp_super_cache_comments = isset( $_POST[ 'wp_super_cache_comments' ] ) ? 1 : 0; wp_cache_setting( 'wp_super_cache_comments', $wp_super_cache_comments ); if ( isset( $_POST[ 'wp_cache_debug_ip' ] ) ) { @@ -2098,8 +2094,8 @@ function wpsc_update_debug_settings() { } return array ( - 'wp_super_cache_debug' => $wp_super_cache_debug, - 'wp_cache_debug_log' => $wp_cache_debug_log, + 'wp_super_cache_debug' => $GLOBALS['wpsc_config']['wp_super_cache_debug'], + 'wp_cache_debug_log' => $GLOBALS['wpsc_config']['wp_cache_debug_log'], 'wp_cache_debug_ip' => $wp_cache_debug_ip, 'wp_super_cache_comments' => $wp_super_cache_comments, 'wp_super_cache_front_page_check' => $wp_super_cache_front_page_check, @@ -2107,14 +2103,13 @@ function wpsc_update_debug_settings() { 'wp_super_cache_front_page_text' => $wp_super_cache_front_page_text, 'wp_super_cache_front_page_notification' => $wp_super_cache_front_page_notification, 'wp_super_cache_advanced_debug' => $wp_super_cache_advanced_debug, - 'wp_cache_debug_username' => $wp_cache_debug_username, + 'wp_cache_debug_username' => $GLOBALS['wpsc_config']['wp_cache_debug_username'], ); } function wp_cache_debug_settings() { - global $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $cache_path, $valid_nonce, $wp_cache_config_file, $wp_super_cache_comments; + global $wp_cache_debug_log, $wp_cache_debug_ip, $valid_nonce, $wp_cache_config_file, $wp_super_cache_comments; global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug; - global $wp_cache_debug_username; extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username $admin_url = admin_url( 'options-general.php?page=wpsupercache' ); @@ -2122,18 +2117,18 @@ function wp_cache_debug_settings() { echo ''; echo '
'; echo '

' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '

'; - if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) { - extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username + if ( ! isset( $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) || $GLOBALS['wpsc_config']['wp_cache_debug_log'] == '' ) { + wpsc_create_debug_log(); } - $log_file_link = "$wp_cache_debug_log"; + $log_file_link = "{$GLOBALS['wpsc_config']['wp_cache_debug_log']}"; - if ( $wp_super_cache_debug == 1 ) { + if ( $GLOBALS['wpsc_config']['wp_super_cache_debug'] == 1 ) { echo "

" . sprintf( __( 'Currently logging to: %s', 'wp-super-cache' ), $log_file_link ) . "

"; } else { echo "

" . sprintf( __( 'Last Logged to: %s', 'wp-super-cache' ), $log_file_link ) . "

"; } - echo "

" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "

"; + echo "

" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $GLOBALS['wpsc_config']['wp_cache_debug_username'] ) . "

"; echo '
'; wp_nonce_field('wp-cache'); @@ -2142,7 +2137,7 @@ function wp_cache_debug_settings() { echo ""; echo '
'; - if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) { + if ( ! isset( $GLOBALS['wpsc_config']['wp_super_cache_debug'] ) || $GLOBALS['wpsc_config']['wp_super_cache_debug'] == 0 ) { $debug_status_message = __( 'Enable Logging', 'wp-super-cache' ); $not_status = 1; } else { @@ -2182,9 +2177,8 @@ function wp_cache_debug_settings() { } function wp_cache_enable() { - global $wp_cache_config_file, $cache_enabled; - if ( $cache_enabled ) { + if ( $GLOBALS['wpsc_config']['cache_enabled'] ) { wp_cache_debug( 'wp_cache_enable: already enabled' ); return true; } @@ -2192,7 +2186,7 @@ function wp_cache_enable() { wp_cache_setting( 'cache_enabled', true ); wp_cache_debug( 'wp_cache_enable: enable cache' ); - $cache_enabled = true; + $GLOBALS['wpsc_config']['cache_enabled'] = true; if ( wpsc_set_default_gc() ) { // gc might not be scheduled, check and schedule @@ -2204,9 +2198,8 @@ function wp_cache_enable() { } function wp_cache_disable() { - global $wp_cache_config_file, $cache_enabled; - if ( ! $cache_enabled ) { + if ( ! $GLOBALS['wpsc_config']['cache_enabled'] ) { wp_cache_debug( 'wp_cache_disable: already disabled' ); return true; } @@ -2214,7 +2207,7 @@ function wp_cache_disable() { wp_cache_setting( 'cache_enabled', false ); wp_cache_debug( 'wp_cache_disable: disable cache' ); - $cache_enabled = false; + $GLOBALS['wpsc_config']['cache_enabled'] = false; wp_clear_scheduled_hook( 'wp_cache_check_site_hook' ); wp_clear_scheduled_hook( 'wp_cache_gc' ); @@ -2222,9 +2215,9 @@ function wp_cache_disable() { } function wp_super_cache_enable() { - global $supercachedir, $wp_cache_config_file, $super_cache_enabled; + global $supercachedir, $wp_cache_config_file; - if ( $super_cache_enabled ) { + if ( $GLOBALS['wpsc_config']['super_cache_enabled'] ) { wp_cache_debug( 'wp_super_cache_enable: already enabled' ); return true; } @@ -2232,7 +2225,7 @@ function wp_super_cache_enable() { wp_cache_setting( 'super_cache_enabled', true ); wp_cache_debug( 'wp_super_cache_enable: enable cache' ); - $super_cache_enabled = true; + $GLOBALS['wpsc_config']['super_cache_enabled'] = true; if ( is_dir( $supercachedir . '.disabled' ) ) { if ( is_dir( $supercachedir ) ) { @@ -2245,9 +2238,9 @@ function wp_super_cache_enable() { } function wp_super_cache_disable() { - global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled; + global $supercachedir, $wp_cache_config_file; - if ( ! $super_cache_enabled ) { + if ( ! $GLOBALS['wpsc_config']['super_cache_enabled'] ) { wp_cache_debug( 'wp_super_cache_disable: already disabled' ); return true; } @@ -2255,14 +2248,14 @@ function wp_super_cache_disable() { wp_cache_setting( 'super_cache_enabled', false ); wp_cache_debug( 'wp_super_cache_disable: disable cache' ); - $super_cache_enabled = false; + $GLOBALS['wpsc_config']['super_cache_enabled'] = false; if ( is_dir( $supercachedir ) ) { @rename( $supercachedir, $supercachedir . '.disabled' ); } sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it if ( function_exists( 'prune_super_cache' ) && is_dir( $supercachedir ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); } if ( $GLOBALS['wp_cache_mod_rewrite'] === 1 ) { @@ -2289,23 +2282,22 @@ function wp_cache_is_enabled() { } function wp_cache_remove_index() { - global $cache_path; - if ( empty( $cache_path ) ) { + if ( empty( $GLOBALS['wpsc_config']['cache_path'] ) ) { return; } - @unlink( $cache_path . "index.html" ); - @unlink( $cache_path . "supercache/index.html" ); - @unlink( $cache_path . "blogs/index.html" ); - if ( is_dir( $cache_path . "blogs" ) ) { - $dir = new DirectoryIterator( $cache_path . "blogs" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "index.html" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "supercache/index.html" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "blogs/index.html" ); + if ( is_dir( $GLOBALS['wpsc_config']['cache_path'] . "blogs" ) ) { + $dir = new DirectoryIterator( $GLOBALS['wpsc_config']['cache_path'] . "blogs" ); foreach( $dir as $fileinfo ) { if ( $fileinfo->isDot() ) { continue; } if ( $fileinfo->isDir() ) { - $directory = $cache_path . "blogs/" . $fileinfo->getFilename(); + $directory = $GLOBALS['wpsc_config']['cache_path'] . "blogs/" . $fileinfo->getFilename(); if ( is_file( $directory . "/index.html" ) ) { unlink( $directory . "/index.html" ); } @@ -2320,15 +2312,15 @@ function wp_cache_remove_index() { } function wp_cache_index_notice() { - global $wp_version, $cache_path; + global $wp_version; if ( false == wpsupercache_site_admin() ) return false; if ( false == get_site_option( 'wp_super_cache_index_detected' ) ) return false; - if ( strlen( $cache_path ) < strlen( ABSPATH ) - || ABSPATH != substr( $cache_path, 0, strlen( ABSPATH ) ) ) + if ( strlen( $GLOBALS['wpsc_config']['cache_path'] ) < strlen( ABSPATH ) + || ABSPATH != substr( $GLOBALS['wpsc_config']['cache_path'], 0, strlen( ABSPATH ) ) ) return false; // cache stored outside web root if ( get_site_option( 'wp_super_cache_index_detected' ) == 2 ) { @@ -2425,9 +2417,9 @@ function wp_cache_logout_all() { add_action( 'admin_init', 'wp_cache_logout_all' ); function wp_cache_add_index_protection() { - global $cache_path, $blog_cache_dir; + global $blog_cache_dir; - if ( is_dir( $cache_path ) && false == is_file( "$cache_path/index.html" ) ) { + if ( is_dir( $GLOBALS['wpsc_config']['cache_path'] ) && false == is_file( $GLOBALS['wpsc_config']['cache_path'] . "/index.html" ) ) { $page = wp_remote_get( home_url( "/wp-content/cache/" ) ); if ( false == is_wp_error( $page ) ) { if ( false == get_site_option( 'wp_super_cache_index_detected' ) @@ -2439,10 +2431,10 @@ function wp_cache_add_index_protection() { if ( ! function_exists( 'insert_with_markers' ) ) { include_once( ABSPATH . 'wp-admin/includes/misc.php' ); } - insert_with_markers( $cache_path . '.htaccess', "INDEX", array( 'Options -Indexes' ) ); + insert_with_markers( $GLOBALS['wpsc_config']['cache_path'] . '.htaccess', "INDEX", array( 'Options -Indexes' ) ); } - $directories = array( $cache_path, $cache_path . '/supercache/', $cache_path . '/blogs/', $blog_cache_dir, $blog_cache_dir . "/meta" ); + $directories = array( $GLOBALS['wpsc_config']['cache_path'], $GLOBALS['wpsc_config']['cache_path'] . '/supercache/', $GLOBALS['wpsc_config']['cache_path'] . '/blogs/', $blog_cache_dir, $blog_cache_dir . "/meta" ); foreach( $directories as $dir ) { if ( false == is_dir( $dir ) ) @mkdir( $dir ); @@ -2455,18 +2447,16 @@ function wp_cache_add_index_protection() { } function wp_cache_add_site_cache_index() { - global $cache_path; - wp_cache_add_index_protection(); // root and supercache - if ( is_dir( $cache_path . "blogs" ) ) { - $dir = new DirectoryIterator( $cache_path . "blogs" ); + if ( is_dir( $GLOBALS['wpsc_config']['cache_path'] . "blogs" ) ) { + $dir = new DirectoryIterator( $GLOBALS['wpsc_config']['cache_path'] . "blogs" ); foreach( $dir as $fileinfo ) { if ( $fileinfo->isDot() ) { continue; } if ( $fileinfo->isDir() ) { - $directory = $cache_path . "blogs/" . $fileinfo->getFilename(); + $directory = $GLOBALS['wpsc_config']['cache_path'] . "blogs/" . $fileinfo->getFilename(); if ( false == is_file( $directory . "/index.html" ) ) { $fp = @fopen( $directory . "/index.html", 'w' ); if ( $fp ) @@ -2485,27 +2475,27 @@ function wp_cache_add_site_cache_index() { } function wp_cache_verify_cache_dir() { - global $cache_path, $blog_cache_dir; + global $blog_cache_dir; - $dir = dirname($cache_path); - if ( !file_exists($cache_path) ) { - if ( !is_writeable_ACLSafe( $dir ) || !($dir = mkdir( $cache_path ) ) ) { + $dir = dirname( $GLOBALS['wpsc_config']['cache_path'] ); + if ( ! file_exists( $GLOBALS['wpsc_config']['cache_path'] ) ) { + if ( ! is_writeable_ACLSafe( $dir ) || ! ( $dir = mkdir( $GLOBALS['wpsc_config']['cache_path'] ) ) ) { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your cache directory (%1$s) did not exist and couldn’t be created by the web server. Check %1$s permissions.', 'wp-super-cache' ), $dir ); return false; } } - if ( !is_writeable_ACLSafe($cache_path)) { - echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your cache directory (%1$s) or %2$s need to be writable for this plugin to work. Double-check it.', 'wp-super-cache' ), $cache_path, $dir ); + if ( ! is_writeable_ACLSafe( $GLOBALS['wpsc_config']['cache_path'] ) ) { + echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your cache directory (%1$s) or %2$s need to be writable for this plugin to work. Double-check it.', 'wp-super-cache' ), $GLOBALS['wpsc_config']['cache_path'], $dir ); return false; } - if ( '/' != substr($cache_path, -1)) { - $cache_path .= '/'; + if ( '/' != substr( $GLOBALS['wpsc_config']['cache_path'], -1 ) ) { + $GLOBALS['wpsc_config']['cache_path'] .= '/'; } - if( false == is_dir( $blog_cache_dir ) ) { - @mkdir( $cache_path . "blogs" ); - if( $blog_cache_dir != $cache_path . "blogs/" ) + if ( false == is_dir( $blog_cache_dir ) ) { + @mkdir( $GLOBALS['wpsc_config']['cache_path'] . "blogs" ); + if ( $blog_cache_dir != $GLOBALS['wpsc_config']['cache_path'] . "blogs/" ) @mkdir( $blog_cache_dir ); } @@ -2517,7 +2507,7 @@ function wp_cache_verify_cache_dir() { } function wp_cache_verify_config_file() { - global $wp_cache_config_file, $wp_cache_config_file_sample, $sem_id, $cache_path; + global $wp_cache_config_file, $wp_cache_config_file_sample; global $WPSC_HTTP_HOST; $new = false; @@ -2552,9 +2542,9 @@ function wp_cache_verify_config_file() { } $new = true; } - if ( $sem_id == 5419 && $cache_path != '' && $WPSC_HTTP_HOST != '' ) { - $sem_id = crc32( $WPSC_HTTP_HOST . $cache_path ) & 0x7fffffff; - wp_cache_replace_line('sem_id', '$sem_id = ' . $sem_id . ';', $wp_cache_config_file); + if ( $GLOBALS['wpsc_config']['sem_id'] == 5419 && $GLOBALS['wpsc_config']['cache_path'] != '' && $WPSC_HTTP_HOST != '' ) { + $GLOBALS['wpsc_config']['sem_id'] = crc32( $WPSC_HTTP_HOST . $GLOBALS['wpsc_config']['cache_path'] ) & 0x7fffffff; + wp_cache_setting( 'sem_id', $GLOBALS['wpsc_config']['sem_id'] ); } if ( $new ) { require($wp_cache_config_file); @@ -2709,7 +2699,7 @@ function wp_cache_format_fsize( $fsize ) { } function wp_cache_regenerate_cache_file_stats() { - global $cache_compression, $supercachedir, $file_prefix, $wp_cache_preload_on, $cache_max_time; + global $supercachedir, $wp_cache_preload_on; if ( $supercachedir == '' ) $supercachedir = get_supercache_dir(); @@ -2738,7 +2728,7 @@ function wp_cache_regenerate_cache_file_stats() { $sizes[ $cache_type ][ $status ] = $cached_list; } } - if ( $cache_compression ) { + if ( $GLOBALS['wpsc_config']['cache_compression'] ) { $sizes[ 'supercache' ][ 'cached' ] = intval( $sizes[ 'supercache' ][ 'cached' ] / 2 ); $sizes[ 'supercache' ][ 'expired' ] = intval( $sizes[ 'supercache' ][ 'expired' ] / 2 ); } @@ -2748,24 +2738,24 @@ function wp_cache_regenerate_cache_file_stats() { } function wp_cache_files() { - global $cache_path, $file_prefix, $cache_max_time, $valid_nonce, $supercachedir, $super_cache_enabled, $blog_cache_dir, $cache_compression; + global $valid_nonce, $supercachedir, $blog_cache_dir; global $wp_cache_preload_on; - if ( '/' != substr($cache_path, -1)) { - $cache_path .= '/'; + if ( '/' != substr($GLOBALS['wpsc_config']['cache_path'], -1)) { + $GLOBALS['wpsc_config']['cache_path'] .= '/'; } if ( $valid_nonce ) { if(isset($_REQUEST['wp_delete_cache'])) { - wp_cache_clean_cache($file_prefix); + wp_cache_clean_cache($GLOBALS['wpsc_config']['file_prefix']); $_GET[ 'action' ] = 'regenerate_cache_stats'; } if ( isset( $_REQUEST[ 'wp_delete_all_cache' ] ) ) { - wp_cache_clean_cache( $file_prefix, true ); + wp_cache_clean_cache( $GLOBALS['wpsc_config']['file_prefix'], true ); $_GET[ 'action' ] = 'regenerate_cache_stats'; } if(isset($_REQUEST['wp_delete_expired'])) { - wp_cache_clean_expired($file_prefix); + wp_cache_clean_expired($GLOBALS['wpsc_config']['file_prefix']); $_GET[ 'action' ] = 'regenerate_cache_stats'; } } @@ -2787,7 +2777,7 @@ function wp_cache_files() { if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletesupercache' ) { $supercacheuri = wpsc_deep_replace( array( '..', '\\', 'index.php' ), preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) ); - $supercacheuri = trailingslashit( realpath( $cache_path . 'supercache/' . $supercacheuri ) ); + $supercacheuri = trailingslashit( realpath( $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' . $supercacheuri ) ); if ( wp_cache_confirm_delete( $supercacheuri ) ) { printf( __( "Deleting supercache file: %s
", 'wp-super-cache' ), $supercacheuri ); wpsc_delete_files( $supercacheuri ); @@ -2798,7 +2788,7 @@ function wp_cache_files() { } } while( false !== ( $file = readdir( $handle ) ) ) { - if ( strpos( $file, $file_prefix ) !== false && substr( $file, -4 ) == '.php' ) { + if ( strpos( $file, $GLOBALS['wpsc_config']['file_prefix'] ) !== false && substr( $file, -4 ) == '.php' ) { if ( false == file_exists( $blog_cache_dir . 'meta/' . $file ) ) { @unlink( $blog_cache_dir . $file ); continue; // meta does not exist @@ -2820,14 +2810,14 @@ function wp_cache_files() { $meta[ 'age' ] = $age; foreach( $meta as $key => $val ) $meta[ $key ] = esc_html( $val ); - if ( $cache_max_time > 0 && $age > $cache_max_time ) { + if ( $GLOBALS['wpsc_config']['cache_max_time'] > 0 && $age > $GLOBALS['wpsc_config']['cache_max_time'] ) { $expired_list[ $age ][] = $meta; } else { $cached_list[ $age ][] = $meta; } } - if ( $cache_max_time > 0 && $age > $cache_max_time ) { + if ( $GLOBALS['wpsc_config']['cache_max_time'] > 0 && $age > $GLOBALS['wpsc_config']['cache_max_time'] ) { $expired++; } else { $count++; @@ -2912,8 +2902,8 @@ function wp_cache_files() { } else { echo "

'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "

"; } - if ( $cache_max_time > 0 ) - echo "

" . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $cache_max_time ) . "

"; + if ( $GLOBALS['wpsc_config']['cache_max_time'] > 0 ) + echo "

" . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $GLOBALS['wpsc_config']['cache_max_time'] ) . "

"; if ( $wp_cache_preload_on ) echo "

" . __( 'Preload mode is enabled. Supercache files will never be expired.', 'wp-super-cache' ) . "

"; } // cache_stats @@ -2962,7 +2952,7 @@ function 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; + global $valid_nonce, $wp_cache_preload_on; $now = time(); if (is_dir($directory)) { @@ -2975,8 +2965,8 @@ function wpsc_dirsize($directory, $sizes) { closedir($dh); } } else { - if ( is_file( $directory ) && strpos( $directory, 'meta-' . $file_prefix ) === false ) { - if ( strpos( $directory, '/' . $file_prefix ) !== false ) { + if ( is_file( $directory ) && strpos( $directory, 'meta-' . $GLOBALS['wpsc_config']['file_prefix'] ) === false ) { + if ( strpos( $directory, '/' . $GLOBALS['wpsc_config']['file_prefix'] ) !== false ) { $cache_type = 'wpcache'; } else { $cache_type = 'supercache'; @@ -2985,14 +2975,14 @@ function wpsc_dirsize($directory, $sizes) { if ( $cache_type == 'supercache' && $wp_cache_preload_on ) $keep_fresh = true; $filem = filemtime( $directory ); - if ( $keep_fresh == false && $cache_max_time > 0 && $filem + $cache_max_time <= $now ) { + if ( $keep_fresh == false && $GLOBALS['wpsc_config']['cache_max_time'] > 0 && $filem + $GLOBALS['wpsc_config']['cache_max_time'] <= $now ) { $cache_status = 'expired'; } else { $cache_status = 'cached'; } $sizes[ $cache_type ][ $cache_status ]+=1; if ( $valid_nonce && isset( $_GET[ 'listfiles' ] ) ) { - $dir = str_replace( $cache_path . 'supercache/' , '', dirname( $directory ) ); + $dir = str_replace( $GLOBALS['wpsc_config']['cache_path'] . 'supercache/' , '', dirname( $directory ) ); $age = $now - $filem; if ( false == isset( $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ] ) ) { $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ][ 'lower_age' ] = $age; @@ -3023,12 +3013,12 @@ function wpsc_dirsize($directory, $sizes) { } function wp_cache_clean_cache( $file_prefix, $all = false ) { - global $cache_path, $supercachedir, $blog_cache_dir; + global $supercachedir, $blog_cache_dir; do_action( 'wp_cache_cleared' ); if ( $all == true && wpsupercache_site_admin() && function_exists( 'prune_super_cache' ) ) { - prune_super_cache( $cache_path, true ); + prune_super_cache( $GLOBALS['wpsc_config']['cache_path'], true ); return true; } if ( $supercachedir == '' ) @@ -3046,7 +3036,7 @@ function wp_cache_clean_cache( $file_prefix, $all = false ) { } wp_cache_clean_legacy_files( $blog_cache_dir, $file_prefix ); - wp_cache_clean_legacy_files( $cache_path, $file_prefix ); + wp_cache_clean_legacy_files( $GLOBALS['wpsc_config']['cache_path'], $file_prefix ); } @@ -3096,10 +3086,10 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) { } } -function wp_cache_clean_expired($file_prefix) { - global $cache_max_time, $blog_cache_dir, $wp_cache_preload_on; +function wp_cache_clean_expired( $file_prefix ) { + global $blog_cache_dir, $wp_cache_preload_on; - if ( $cache_max_time == 0 ) { + if ( $GLOBALS['wpsc_config']['cache_max_time'] == 0 ) { return false; } @@ -3114,7 +3104,7 @@ function wp_cache_clean_expired($file_prefix) { } $_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats; } - return wp_cache_phase2_clean_expired($file_prefix); + return wp_cache_phase2_clean_expired( $file_prefix ); } $now = time(); @@ -3124,7 +3114,7 @@ function wp_cache_clean_expired($file_prefix) { if ( strpos( $file, '.html' ) ) { @unlink( $blog_cache_dir . $file); @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); - } elseif ( ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) { + } elseif ( ( filemtime( $blog_cache_dir . $file ) + $GLOBALS['wpsc_config']['cache_max_time'] ) <= $now ) { @unlink( $blog_cache_dir . $file ); @unlink( $blog_cache_dir . 'meta/' . $file ); } @@ -3198,8 +3188,7 @@ function wp_cache_favorite_action( $actions ) { //add_filter( 'favorite_actions', 'wp_cache_favorite_action' ); function wp_cache_plugin_notice( $plugin ) { - global $cache_enabled; - if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled && function_exists( 'admin_url' ) ) + if ( $plugin == 'wp-super-cache/wp-cache.php' && ! $GLOBALS['wpsc_config']['cache_enabled'] && function_exists( 'admin_url' ) ) echo '
'; } add_action( 'after_plugin_row', 'wp_cache_plugin_notice' ); @@ -3214,11 +3203,12 @@ function wp_cache_plugin_actions( $links, $file ) { add_filter( 'plugin_action_links', 'wp_cache_plugin_actions', 10, 2 ); function wp_cache_admin_notice() { - global $cache_enabled, $wp_cache_phase1_loaded; - if( substr( $_SERVER['PHP_SELF'], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( 'admin_url' ) ) + global $wp_cache_phase1_loaded; + if ( substr( $_SERVER['PHP_SELF'], -11 ) == 'plugins.php' && ! $GLOBALS['wpsc_config']['cache_enabled'] && function_exists( 'admin_url' ) ) { echo '

' . sprintf( __('WP Super Cache is disabled. Please go to the plugin admin page to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '

'; + } - if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) { + if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $GLOBALS['wpsc_config']['cache_enabled'] && false == isset( $wp_cache_phase1_loaded ) ) ) ) { if ( wp_cache_create_advanced_cache() ) { echo '

' . sprintf( __( 'Warning! WP Super Cache caching was broken but has been fixed! The script advanced-cache.php could not load wp-cache-phase1.php.

The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '

'; } @@ -3490,7 +3480,7 @@ function clear_post_supercache( $post_id ) { } function wp_cron_preload_cache() { - global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path, $wp_cache_preload_taxonomies; + global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_taxonomies; if ( get_option( 'preload_cache_stop' ) ) { delete_option( 'preload_cache_stop' ); @@ -3498,7 +3488,7 @@ function wp_cron_preload_cache() { return true; } - $mutex = $cache_path . "preload_mutex.tmp"; + $mutex = $GLOBALS['wpsc_config']['cache_path'] . "preload_mutex.tmp"; sleep( 3 + mt_rand( 1, 5 ) ); if ( @file_exists( $mutex ) ) { if ( @filemtime( $mutex ) > ( time() - 600 ) ) { @@ -3531,11 +3521,11 @@ function wp_cron_preload_cache() { if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) { wp_cache_debug( 'wp_cron_preload_cache: doing taxonomy preload.', 5 ); - $permalink_counter_msg = $cache_path . "preload_permalink.txt"; + $permalink_counter_msg = $GLOBALS['wpsc_config']['cache_path'] . "preload_permalink.txt"; if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) { $taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) ); foreach( $taxonomies as $taxonomy => $path ) { - $taxonomy_filename = $cache_path . "taxonomy_" . $taxonomy . ".txt"; + $taxonomy_filename = $GLOBALS['wpsc_config']['cache_path'] . "taxonomy_" . $taxonomy . ".txt"; if ( $c == 0 ) @unlink( $taxonomy_filename ); @@ -3574,10 +3564,10 @@ function wp_cron_preload_cache() { wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); wp_cache_debug( "wp_cron_preload_cache: fetched $url", 5 ); sleep( 1 ); - if ( @file_exists( $cache_path . "stop_preload.txt" ) ) { + if ( @file_exists( $GLOBALS['wpsc_config']['cache_path'] . "stop_preload.txt" ) ) { wp_cache_debug( 'wp_cron_preload_cache: cancelling preload. stop_preload.txt found.', 5 ); @unlink( $mutex ); - @unlink( $cache_path . "stop_preload.txt" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "stop_preload.txt" ); @unlink( $taxonomy_filename ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); if ( $wp_cache_preload_email_me ) @@ -3617,7 +3607,7 @@ function wp_cron_preload_cache() { wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache' ), home_url(), $c, ($c+100) ), ' ' ); $msg = ''; $count = $c + 1; - $permalink_counter_msg = $cache_path . "preload_permalink.txt"; + $permalink_counter_msg = $GLOBALS['wpsc_config']['cache_path'] . "preload_permalink.txt"; foreach( $posts as $post_id ) { set_time_limit( 60 ); if ( $page_on_front != 0 && ( $post_id == $page_on_front || $post_id == $page_for_posts ) ) @@ -3634,10 +3624,10 @@ function wp_cron_preload_cache() { @fwrite( $fp, $count . " " . $url ); @fclose( $fp ); } - if ( @file_exists( $cache_path . "stop_preload.txt" ) ) { + if ( @file_exists( $GLOBALS['wpsc_config']['cache_path'] . "stop_preload.txt" ) ) { wp_cache_debug( 'wp_cron_preload_cache: cancelling preload. stop_preload.txt found.', 5 ); @unlink( $mutex ); - @unlink( $cache_path . "stop_preload.txt" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "stop_preload.txt" ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); if ( $wp_cache_preload_email_me ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Stopped', 'wp-super-cache' ), home_url(), '' ), ' ' ); @@ -3665,17 +3655,16 @@ function wp_cron_preload_cache() { wp_cache_debug( "wp_cron_preload_cache: no more posts. scheduling next preload in $wp_cache_preload_interval minutes.", 5 ); wp_schedule_single_event( time() + ( (int)$wp_cache_preload_interval * 60 ), 'wp_cache_full_preload_hook' ); } - global $file_prefix, $cache_max_time; if ( $wp_cache_preload_interval > 0 ) { - $cache_max_time = (int)$wp_cache_preload_interval * 60; // fool the GC into expiring really old files + $GLOBALS['wpsc_config']['cache_max_time'] = (int)$wp_cache_preload_interval * 60; // fool the GC into expiring really old files } else { - $cache_max_time = 86400; // fool the GC into expiring really old files + $GLOBALS['wpsc_config']['cache_max_time'] = 86400; // fool the GC into expiring really old files } 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 ); - if ( $cache_max_time > 0 ) { // GC is NOT disabled + if ( $GLOBALS['wpsc_config']['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. + wp_cache_phase2_clean_expired( $GLOBALS['wpsc_config']['file_prefix'], true ); // force cleanup of old files. } } @unlink( $mutex ); @@ -3866,7 +3855,6 @@ function wpsc_admin_bar_render( $wp_admin_bar ) { add_action( 'admin_bar_menu', 'wpsc_admin_bar_render', 99 ); function wpsc_cancel_preload() { - global $cache_path; $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' ); if ( $next_preload ) { wp_cache_debug( 'wpsc_cancel_preload: unscheduling wp_cache_preload_hook' ); @@ -3880,14 +3868,12 @@ function wpsc_cancel_preload() { wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' ); } wp_cache_debug( 'wpsc_cancel_preload: creating stop_preload.txt' ); - $fp = @fopen( $cache_path . "stop_preload.txt", 'w' ); + $fp = @fopen( $GLOBALS['wpsc_config']['cache_path'] . "stop_preload.txt", 'w' ); @fclose( $fp ); } function wpsc_enable_preload() { - global $cache_path; - - @unlink( $cache_path . "preload_mutex.tmp" ); + @unlink( $GLOBALS['wpsc_config']['cache_path'] . "preload_mutex.tmp" ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); wp_schedule_single_event( time() + 10, 'wp_cache_full_preload_hook' ); } @@ -4007,9 +3993,9 @@ function wpsc_is_preloading() { } function wpsc_set_default_gc( $force = false ) { - global $cache_path, $wp_cache_shutdown_gc, $cache_schedule_type; + global $cache_schedule_type; - if ( isset( $wp_cache_shutdown_gc ) && $wp_cache_shutdown_gc == 1 ) { + if ( isset( $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] ) && $GLOBALS['wpsc_config']['wp_cache_shutdown_gc'] == 1 ) { return false; } @@ -4025,12 +4011,12 @@ function wpsc_set_default_gc( $force = false ) { if ( false == isset( $cache_schedule_type ) && false == wp_next_scheduled( 'wp_cache_gc' ) ) { $cache_schedule_type = 'interval'; $cache_time_interval = 600; - $cache_max_time = 1800; + $GLOBALS['wpsc_config']['cache_max_time'] = 1800; $cache_schedule_interval = 'hourly'; $cache_gc_email_me = 0; wp_cache_setting( 'cache_schedule_type', $cache_schedule_type ); wp_cache_setting( 'cache_time_interval', $cache_time_interval ); - wp_cache_setting( 'cache_max_time', $cache_max_time ); + wp_cache_setting( 'cache_max_time', $GLOBALS['wpsc_config']['cache_max_time'] ); wp_cache_setting( 'cache_schedule_interval', $cache_schedule_interval ); wp_cache_setting( 'cache_gc_email_me', $cache_gc_email_me ); @@ -4050,7 +4036,7 @@ function remove_mod_rewrite_rules() { } function update_mod_rewrite_rules( $add_rules = true ) { - global $cache_path, $update_mod_rewrite_rules_error; + global $update_mod_rewrite_rules_error; $update_mod_rewrite_rules_error = false; @@ -4111,12 +4097,12 @@ function update_mod_rewrite_rules( $add_rules = true ) { return false; } - $backup_filename = $cache_path . 'htaccess.' . mt_rand() . ".php"; + $backup_filename = $GLOBALS['wpsc_config']['cache_path'] . 'htaccess.' . mt_rand() . ".php"; $backup_file_contents = file_get_contents( $home_path . '.htaccess' ); file_put_contents( $backup_filename, "<" . "?php die(); ?" . ">" . $backup_file_contents ); - $existing_gzip_rules = implode( "\n", extract_from_markers( $cache_path . '.htaccess', 'supercache' ) ); + $existing_gzip_rules = implode( "\n", extract_from_markers( $GLOBALS['wpsc_config']['cache_path'] . '.htaccess', 'supercache' ) ); if ( $existing_gzip_rules != $generated_rules[ 'gziprules' ] ) { - insert_with_markers( $cache_path . '.htaccess', 'supercache', explode( "\n", $generated_rules[ 'gziprules' ] ) ); + insert_with_markers( $GLOBALS['wpsc_config']['cache_path'] . '.htaccess', 'supercache', explode( "\n", $generated_rules[ 'gziprules' ] ) ); } $wprules = extract_from_markers( $home_path . '.htaccess', 'WordPress' ); wpsc_remove_marker( $home_path . '.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top @@ -4130,11 +4116,11 @@ function update_mod_rewrite_rules( $add_rules = true ) { } elseif ( $new_page[ 'body' ] != $original_page[ 'body' ] ) { $restore_backup = true; $update_mod_rewrite_rules_error = "Page test failed as pages did not match with new .htaccess rules."; - wp_cache_debug( 'update_mod_rewrite_rules: failed to update rules. page test failed as pages did not match. Files dumped in ' . $cache_path . ' for inspection.' ); + wp_cache_debug( 'update_mod_rewrite_rules: failed to update rules. page test failed as pages did not match. Files dumped in ' . $GLOBALS['wpsc_config']['cache_path'] . ' for inspection.' ); wp_cache_debug( 'update_mod_rewrite_rules: original page: 1-' . md5( $original_page[ 'body' ] ) . '.txt' ); wp_cache_debug( 'update_mod_rewrite_rules: new page: 1-' . md5( $new_page[ 'body' ] ) . '.txt' ); - file_put_contents( $cache_path . '1-' . md5( $original_page[ 'body' ] ) . '.txt', $original_page[ 'body' ] ); - file_put_contents( $cache_path . '2-' . md5( $new_page[ 'body' ] ) . '.txt', $new_page[ 'body' ] ); + file_put_contents( $GLOBALS['wpsc_config']['cache_path'] . '1-' . md5( $original_page[ 'body' ] ) . '.txt', $original_page[ 'body' ] ); + file_put_contents( $GLOBALS['wpsc_config']['cache_path'] . '2-' . md5( $new_page[ 'body' ] ) . '.txt', $new_page[ 'body' ] ); } if ( $restore_backup ) { @@ -4292,8 +4278,8 @@ function wpsc_update_check() { $wpsc_version != 169 ) { wp_cache_setting( 'wpsc_version', 169 ); - global $wp_cache_debug_log, $cache_path; - $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log)); + global $wp_cache_debug_log; + $log_file = $GLOBALS['wpsc_config']['cache_path'] . str_replace( '/', '', str_replace( '..', '', $GLOBALS['wpsc_config']['wp_cache_debug_log'] ) ); if ( ! file_exists( $log_file ) ) { return false; }
" . __( "seconds", 'wp-super-cache' ) . '
' . __( 'Check for stale cached files every interval seconds.', 'wp-super-cache' ) . "
' . sprintf( __( 'WP Super Cache must be configured. Go to the admin page to enable and configure the plugin.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '