Skip to content

Commit

Permalink
Removes deprecated multisite code and perfomance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
stodorovic committed Aug 16, 2018
1 parent d679dc8 commit 26b4074
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugins/multisite.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) === true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
if ( is_multisite() ) {
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
}

Expand Down
11 changes: 5 additions & 6 deletions wp-cache-phase1.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,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' );
}

Expand All @@ -126,11 +129,7 @@
}

// WordPress 4.6 introduces action ms_loaded.
if ( is_multisite() &&
empty( $wp_super_cache_late_init ) &&
version_compare( $wp_version, '4.6', '>=' ) &&
function_exists( 'add_action' )
) {
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 ) ) {
Expand Down
9 changes: 6 additions & 3 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ function toggleLayer( whichLayer ) {
wp_nonce_field('wp-cache');
echo "</form>\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 '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
echo '<input type="hidden" name="wp_delete_all_cache" />';
echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
Expand Down Expand Up @@ -2844,7 +2844,7 @@ function wp_cache_delete_buttons() {
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>';
wp_nonce_field('wp-cache');
echo "</form>\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 '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
echo '<input type="hidden" name="wp_delete_all_cache" />';
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>';
Expand Down Expand Up @@ -2976,6 +2976,8 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
return false;

if ( $handle = @opendir( $dir ) ) {
$curr_blog_id = is_multisite() ? get_current_blog_id() : false;

while ( false !== ( $file = readdir( $handle ) ) ) {
if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
continue;
Expand All @@ -2988,8 +2990,9 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
} else {
$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && $meta[ 'blog_id' ] != $wpdb->blogid )
if ( $curr_blog_id && $curr_blog_id !== (int) $meta['blog_id'] ) {
continue;
}
@unlink( $dir . $file);
@unlink( $dir . 'meta/' . $file);
}
Expand Down

0 comments on commit 26b4074

Please sign in to comment.