diff --git a/plugins/multisite.php b/plugins/multisite.php index 6306a160..df71f9ac 100644 --- a/plugins/multisite.php +++ b/plugins/multisite.php @@ -1,6 +1,6 @@ domain : trim( $current_blog->path, '/' ); + if ( empty( $blogcacheid ) ) { + $blogcacheid = 'blog'; + } + } elseif ( ( defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST == 'yes' ) ) { $blogcacheid = $WPSC_HTTP_HOST; } else { if ( isset( $base ) == false ) { @@ -36,4 +45,5 @@ } $blogcacheid = str_replace( '/', '', $blogcacheid ); } + $blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' ); } diff --git a/wp-cache-phase1.php b/wp-cache-phase1.php index 3a3e047f..d7547fb5 100644 --- a/wp-cache-phase1.php +++ b/wp-cache-phase1.php @@ -20,11 +20,12 @@ require WPCACHEHOME . 'wp-cache-base.php'; -if ( $blogcacheid != '' ) { +// Moved to 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; @@ -101,8 +102,11 @@ $wp_cache_gzip_encoding = gzip_accepted(); } +$wpsc_wp_gte_46 = function_exists( 'add_filter' ) && version_compare( $GLOBALS['wp_version'], '4.6', '>=' ); + add_cacheaction( 'supercache_filename_str', 'wp_cache_check_mobile' ); -if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6 +if ( $wpsc_wp_gte_46 ) { + // loaded since WordPress 4.6 add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' ); } @@ -125,6 +129,10 @@ return true; } -if ( ! isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) { +// WordPress 4.6 introduces action ms_loaded. +if ( is_multisite() && $wpsc_wp_gte_46 && empty( $wp_super_cache_late_init ) ) { + add_action( 'ms_loaded', 'wp_cache_serve_cache_file' ); +} +elseif ( ! isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) { wp_cache_serve_cache_file(); } diff --git a/wp-cache-phase2.php b/wp-cache-phase2.php index d81011bd..a11a4dc0 100644 --- a/wp-cache-phase2.php +++ b/wp-cache-phase2.php @@ -46,6 +46,12 @@ function wp_cache_serve_cache_file() { global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname, $wp_cache_gzip_encoding, $meta; global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get; global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled, $wpsc_served_header; + global $current_blog; + + // Fixes $blogcacheid and $blog_cache_dir if ms-settings.php is loaded. + if ( is_multisite() && is_object( $current_blog ) ) { + require WPCACHEHOME . 'wp-cache-base.php'; + } if ( wpsc_is_backend() ) { wp_cache_debug( 'Not serving wp-admin requests.', 5 ); diff --git a/wp-cache.php b/wp-cache.php index dd5f9599..a78559e2 100644 --- a/wp-cache.php +++ b/wp-cache.php @@ -1284,7 +1284,7 @@ function toggleLayer( whichLayer ) { wp_nonce_field('wp-cache'); echo "\n"; - if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) { + if ( is_multisite() && wpsupercache_site_admin() ) { echo '
\n"; - if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) { + if ( is_multisite() && wpsupercache_site_admin() ) { echo '