Skip to content

Commit

Permalink
run switch_to_blog to the main site if we're in multisite
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed May 9, 2023
1 parent b40dd82 commit 4e8500e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions php/commands/launchcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public function all($args, $assoc_args) {
// wp-config is going to be loaded again, and we need to avoid notices
@WP_CLI::get_runner()->load_wordpress();

// Check for multisite. If we're on multisite, switch to the main site.
if ( is_multisite() ) {
if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
switch_to_blog( BLOG_ID_CURRENT_SITE );
} else {
switch_to_blog( 1 );
}
\WP_CLI::log( sprintf( esc_html__( 'Multisite detected. Running checks on %s site.' ), get_bloginfo( 'name' ) ) );
}


// WordPress is now loaded, so other checks can run
$searcher = new \Pantheon\Filesearcher( WP_CONTENT_DIR );
$searcher->register( new \Pantheon\Checks\Sessions() );
Expand Down

0 comments on commit 4e8500e

Please sign in to comment.