Refactor: optimize multisite plugin output and reduce duplication#1022
Draft
kraftbj wants to merge 1 commit into
Draft
Refactor: optimize multisite plugin output and reduce duplication#1022kraftbj wants to merge 1 commit into
kraftbj wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the multisite “Cached” column action links in wp_super_cache_blogs_field() to reduce duplicated logic and make link generation/escaping more consistent, based on the still-applicable parts of closed PR #606.
Changes:
- Refactors Enable/Disable link output to a single
printf()usingesc_url()/esc_html(). - Avoids a duplicated
get_blog_option()call by introducing$cache_disabledand deriving action/text from it. - Adjusts nonce creation/verification and adds PHPCS suppressions around
$_GETaccess.
Comments suppressed due to low confidence (1)
plugins/multisite.php:32
filter_input( INPUT_GET, 'action' )is called twice in the same block. Assign it once to a local$actionvariable before the conditional chain to reduce duplication and make the control flow easier to follow.
if ( 'disable_cache' === filter_input( INPUT_GET, 'action' ) ) {
add_blog_option( $blog_id, 'wp_super_cache_disabled', 1 );
} elseif ( 'enable_cache' === filter_input( INPUT_GET, 'action' ) ) {
delete_blog_option( $blog_id, 'wp_super_cache_disabled' );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9781849 to
612cb29
Compare
eb1863d to
aa53690
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Manually cherry-picks the still-valid refactoring changes from closed PR #606 (which couldn't be reopened due to history divergence), adapted to the current trunk codebase.
Originally proposed by @stodorovic in #606.
Changes to
plugins/multisite.php:wp_super_cache_blogs_field()to use a singleprintf()withesc_url()andesc_html()instead of duplicatedecho+wp_nonce_url()calls$cache_disabledvariable to eliminate the duplicatedget_blog_option()callwp_create_nonce()directly in query args for cleaner, more explicit nonce handling$_GETaccessessanitize_text_field()andwp_unslash()See #606
Test plan