From 039d49a68a819a494f926c254117d9e9c9ba5e1a Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Tue, 9 May 2017 15:51:47 +0000 Subject: [PATCH] Multisite: Add `$network_id` parameter to `wp_is_large_network()`. Now that `get_blog_count()` and `get_user_count()` both support passing a `$network_id` parameter (see [40370] and [40371]), similar functionality is now available for `wp_is_large_network()`. In addition, the filter `wp_is_large_network` now accepts the network ID as its fourth parameter. This changeset furthermore introduces unit tests for the `wp_is_large_network()` function and its filter. Fixes #40489. Built from https://develop.svn.wordpress.org/trunk@40590 git-svn-id: http://core.svn.wordpress.org/trunk@40460 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 22 ++++++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index ff639e30e1..edc85617ef 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2490,27 +2490,37 @@ function upload_size_limit_filter( $size ) { * Plugins can alter this criteria using the {@see 'wp_is_large_network'} filter. * * @since 3.3.0 - * @param string $using 'sites or 'users'. Default is 'sites'. + * @since 4.8.0 The $network_id parameter has been added. + * + * @param string $using 'sites or 'users'. Default is 'sites'. + * @param int|null $network_id ID of the network. Default is the current network. * @return bool True if the network meets the criteria for large. False otherwise. */ -function wp_is_large_network( $using = 'sites' ) { +function wp_is_large_network( $using = 'sites', $network_id = null ) { + $network_id = (int) $network_id; + if ( ! $network_id ) { + $network_id = get_current_network_id(); + } + if ( 'users' == $using ) { - $count = get_user_count(); + $count = get_user_count( $network_id ); /** * Filters whether the network is considered large. * * @since 3.3.0 + * @since 4.8.0 The $network_id parameter has been added. * * @param bool $is_large_network Whether the network has more than 10000 users or sites. * @param string $component The component to count. Accepts 'users', or 'sites'. * @param int $count The count of items for the component. + * @param int $network_id The ID of the network being checked. */ - return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count ); + return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id ); } - $count = get_blog_count(); + $count = get_blog_count( $network_id ); /** This filter is documented in wp-includes/ms-functions.php */ - return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); + return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 5b064fd282..6330803314 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40589'; +$wp_version = '4.8-alpha-40590'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.