From 7fa610b34a900a9af8cca550b67559f4d3cc698e Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 20 Apr 2017 00:00:42 +0000 Subject: [PATCH] Multisite: Add `$network_id` parameter to `wp_update_network_site_counts()`. Using the new parameter, it is now possible to update the site counts on a network different from the current network. Props PieWP, johnjamesjacoby. Fixes #37528. See #38699. Built from https://develop.svn.wordpress.org/trunk@40484 git-svn-id: http://core.svn.wordpress.org/trunk@40360 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 14 +++++++++----- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 9df86cfbde..b2cbd63931 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2329,21 +2329,25 @@ function wp_maybe_update_network_user_counts() { * Update the network-wide site count. * * @since 3.7.0 + * @since 4.8.0 The $network_id parameter has been added. * - * @global wpdb $wpdb WordPress database abstraction object. + * @param int|null $network_id ID of the network. Default is the current network. */ -function wp_update_network_site_counts() { - global $wpdb; +function wp_update_network_site_counts( $network_id = null ) { + $network_id = (int) $network_id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); + } $count = get_sites( array( - 'network_id' => $wpdb->siteid, + 'network_id' => $network_id, 'spam' => 0, 'deleted' => 0, 'archived' => 0, 'count' => true, ) ); - update_site_option( 'blog_count', $count ); + update_network_option( $network_id, 'blog_count', $count ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index f9705a8a8f..3be5d05964 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40483'; +$wp_version = '4.8-alpha-40484'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.