Skip to content

Commit eb66872

Browse files
stodorovicdonnchawp
authored andcommitted
Uses is_multisite() instead of constants (#600)
1 parent 74d679b commit eb66872

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

plugins/multisite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) === true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
3+
if ( is_multisite() ) {
44
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
55
}
66

wp-cache-base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
// We want to be able to identify each blog in a WordPress MU install
1414
$blogcacheid = '';
15-
if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
15+
if ( is_multisite() ) {
1616
$blogcacheid = 'blog'; // main blog
17-
if ( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
17+
if ( ( defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST == 'yes' ) ) {
1818
$blogcacheid = $WPSC_HTTP_HOST;
1919
} else {
2020
if ( isset( $base ) == false ) {

wp-cache.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ function toggleLayer( whichLayer ) {
12961296
wp_nonce_field('wp-cache');
12971297
echo "</form>\n";
12981298

1299-
if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
1299+
if ( is_multisite() && wpsupercache_site_admin() ) {
13001300
echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
13011301
echo '<input type="hidden" name="wp_delete_all_cache" />';
13021302
echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
@@ -2856,7 +2856,7 @@ function wp_cache_delete_buttons() {
28562856
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
28572857
wp_nonce_field('wp-cache');
28582858
echo "</form>\n";
2859-
if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
2859+
if ( is_multisite() && wpsupercache_site_admin() ) {
28602860
echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
28612861
echo '<input type="hidden" name="wp_delete_all_cache" />';
28622862
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
@@ -2992,6 +2992,8 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
29922992
return false;
29932993

29942994
if ( $handle = @opendir( $dir ) ) {
2995+
$curr_blog_id = is_multisite() ? get_current_blog_id() : false;
2996+
29952997
while ( false !== ( $file = readdir( $handle ) ) ) {
29962998
if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
29972999
continue;
@@ -3004,8 +3006,9 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
30043006
@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
30053007
} else {
30063008
$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
3007-
if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && $meta[ 'blog_id' ] != $wpdb->blogid )
3009+
if ( $curr_blog_id && $curr_blog_id !== (int)$meta['blog_id'] ) {
30083010
continue;
3011+
}
30093012
@unlink( $dir . $file);
30103013
@unlink( $dir . 'meta/' . $file);
30113014
}

0 commit comments

Comments
 (0)