diff --git a/plugins/multisite.php b/plugins/multisite.php
index df71f9ac..ccc746a3 100644
--- a/plugins/multisite.php
+++ b/plugins/multisite.php
@@ -1,13 +1,28 @@
'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Enable', 'wp-super-cache' ) . '';
- } else {
- echo '' . __( 'Disable', 'wp-super-cache' ) . '';
- }
+ $cache_option = (int) get_blog_option( $blog_id, 'wp_super_cache_disabled' ) === 1;
+
+ $action_text = $cache_option ? __( 'Enable', 'wp-super-cache' ) : __( 'Disable', 'wp-super-cache' );
+ $action_args = array(
+ 'action' => $cache_option ? 'enable_cache' : 'disable_cache',
+ 'id' => $blog_id,
+ '_wpnonce' => wp_create_nonce( 'wp-cache' . $blog_id ),
+ );
+ printf( '%s', esc_url_raw( add_query_arg( $action_args ) ), esc_html( $action_text ) );
}
function wp_super_cache_multisite_notice() {
- if ( 'wpsupercache' === filter_input( INPUT_GET, 'page' ) ) {
- echo '
' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '
';
+ if ( filter_input( INPUT_GET, 'page' ) === 'wpsupercache' ) {
+ echo '' . esc_html__( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '
';
}
}
function wp_super_cache_override_on_flag() {
- global $cache_enabled, $super_cache_enabled;
- if ( true !== $cache_enabled ) {
+ global $cache_enabled, $super_cache_enabled, $cache_path, $blogcacheid, $blog_cache_dir, $current_blog;
+
+ if ( is_object( $current_blog ) ) {
+ $blogcacheid = trim( is_subdomain_install() ? $current_blog->domain : $current_blog->path, '/' );
+ $blog_cache_dir = $cache_path . 'blogs/' . $blogcacheid . '/';
+ }
+
+ if ( true !== $cache_enabled || (int) get_option( 'wp_super_cache_disabled' ) !== 1 ) {
return false;
}
- if ( 1 === (int) get_option( 'wp_super_cache_disabled' ) ) {
- $cache_enabled = false;
- $super_cache_enabled = false;
- define( 'DONOTCACHEPAGE', 1 );
+ $cache_enabled = false;
+ $super_cache_enabled = false;
+ defined( 'DONOTCACHEPAGE' ) || define( 'DONOTCACHEPAGE', 1 );
+
+ if ( is_admin() ) {
define( 'SUBMITDISABLED', 'disabled style="color: #aaa" ' );
- if ( is_admin() ) {
- add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
- }
+ add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
}
}
diff --git a/wp-cache-base.php b/wp-cache-base.php
index df65196c..935ec838 100644
--- a/wp-cache-base.php
+++ b/wp-cache-base.php
@@ -16,11 +16,8 @@
$blog_cache_dir = $cache_path;
if ( is_multisite() ) {
- global $current_blog;
- if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
- $blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
- } elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
+ if ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
$blogcacheid = $WPSC_HTTP_HOST;
} else {
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
diff --git a/wp-cache-phase1.php b/wp-cache-phase1.php
index 3a3e047f..3132b368 100644
--- a/wp-cache-phase1.php
+++ b/wp-cache-phase1.php
@@ -20,12 +20,6 @@
require WPCACHEHOME . 'wp-cache-base.php';
-if ( $blogcacheid != '' ) {
- $blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
-} else {
- $blog_cache_dir = $cache_path;
-}
-
$wp_cache_phase1_loaded = true;
$mutex_filename = 'wp_cache_mutex.lock';