Multisite: Add $network_id
parameter to wp_update_network_counts()
.
After the `$network_id` parameter has been introduced for `wp_update_network_site_counts()` in [40484] and `wp_update_network_user_counts()` in [40485], the new parameter can now also be used on the wrapping function. Fixes #40386. See #38699. git-svn-id: https://develop.svn.wordpress.org/trunk@40486 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d6297c051e
commit
7966b89e29
@ -2274,10 +2274,13 @@ function wp_schedule_update_network_counts() {
|
|||||||
* Update the network-wide counts for the current network.
|
* Update the network-wide counts for the current network.
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
|
* @since 4.8.0 The $network_id parameter has been added.
|
||||||
|
*
|
||||||
|
* @param int|null $network_id ID of the network. Default is the current network.
|
||||||
*/
|
*/
|
||||||
function wp_update_network_counts() {
|
function wp_update_network_counts( $network_id = null ) {
|
||||||
wp_update_network_user_counts();
|
wp_update_network_user_counts( $network_id );
|
||||||
wp_update_network_site_counts();
|
wp_update_network_site_counts( $network_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,6 +440,36 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
|
|||||||
$result = get_user_count( self::$different_network_id );
|
$result = get_user_count( self::$different_network_id );
|
||||||
$this->assertEquals( $expected, $result );
|
$this->assertEquals( $expected, $result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 40386
|
||||||
|
*/
|
||||||
|
public function test_wp_update_network_counts() {
|
||||||
|
delete_network_option( null, 'site_count' );
|
||||||
|
delete_network_option( null, 'user_count' );
|
||||||
|
|
||||||
|
wp_update_network_counts();
|
||||||
|
|
||||||
|
$site_count = (int) get_blog_count();
|
||||||
|
$user_count = (int) get_user_count();
|
||||||
|
|
||||||
|
$this->assertTrue( $site_count > 0 && $user_count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 40386
|
||||||
|
*/
|
||||||
|
public function test_wp_update_network_counts_on_different_network() {
|
||||||
|
delete_network_option( self::$different_network_id, 'site_count' );
|
||||||
|
delete_network_option( self::$different_network_id, 'user_count' );
|
||||||
|
|
||||||
|
wp_update_network_counts( self::$different_network_id );
|
||||||
|
|
||||||
|
$site_count = (int) get_blog_count( self::$different_network_id );
|
||||||
|
$user_count = (int) get_user_count( self::$different_network_id );
|
||||||
|
|
||||||
|
$this->assertTrue( $site_count > 0 && $user_count > 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
Loading…
Reference in New Issue
Block a user