Skip to content

Commit

Permalink
Use get_main_site_id. (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey authored Sep 20, 2022
1 parent da32a1d commit 2967bac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions wp-multi-network/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function get_main_site_for_network( $network = null ) {
if ( ! empty( $network->blog_id ) ) {
$primary_id = $network->blog_id;
} else {
$primary_id = wp_cache_get( "network:{$network->id}:main_site", 'site-options' );
$primary_id = get_network_option( $network->id, 'main_site' );

if ( false === $primary_id ) {
$sites = get_sites( array(
Expand All @@ -147,7 +147,7 @@ function get_main_site_for_network( $network = null ) {
$primary_id = ! empty( $sites ) ? reset( $sites ) : 0;

if ( ! empty( $primary_id ) ) {
wp_cache_add( "network:{$network->id}:main_site", $primary_id, 'site-options' );
update_network_option( $network->id, 'main_site', $primary_id );
}
}
}
Expand All @@ -167,7 +167,7 @@ function get_main_site_for_network( $network = null ) {
*/
function is_main_site_for_network( $site_id ) {
$site = get_site( $site_id );
$main = get_main_site_for_network( $site->network_id );
$main = get_main_site_id( $site->network_id );

// Bail if no site or network was found.
if ( empty( $main ) ) {
Expand Down Expand Up @@ -254,7 +254,7 @@ function switch_to_network( $new_network = 0, $validate = false ) {

// Populate extra properties if not set already.
if ( ! isset( $current_site->blog_id ) ) {
$current_site->blog_id = get_main_site_for_network( $current_site );
$current_site->blog_id = get_main_site_id( $current_site->id );
}
if ( ! isset( $current_site->site_name ) ) {
$current_site->site_name = get_network_name();
Expand Down Expand Up @@ -701,7 +701,7 @@ function update_network( $id, $domain, $path = '' ) {
return new WP_Error( 'network_not_exist', __( 'Network does not exist.', 'wp-multi-network' ) );
}

$site_id = get_main_site_for_network( $id );
$site_id = get_main_site_id( $id );
$path = wp_sanitize_site_path( $path );

// Bail if site URL is invalid.
Expand Down

0 comments on commit 2967bac

Please sign in to comment.