Make WordPress Core


Ignore:
Timestamp:
05/09/2017 03:50:04 PM (7 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r40589 r40590  
    24912491 *
    24922492 * @since 3.3.0
    2493  * @param string $using 'sites or 'users'. Default is 'sites'.
     2493 * @since 4.8.0 The $network_id parameter has been added.
     2494 *
     2495 * @param string   $using      'sites or 'users'. Default is 'sites'.
     2496 * @param int|null $network_id ID of the network. Default is the current network.
    24942497 * @return bool True if the network meets the criteria for large. False otherwise.
    24952498 */
    2496 function wp_is_large_network( $using = 'sites' ) {
     2499function wp_is_large_network( $using = 'sites', $network_id = null ) {
     2500    $network_id = (int) $network_id;
     2501    if ( ! $network_id ) {
     2502        $network_id = get_current_network_id();
     2503    }
     2504
    24972505    if ( 'users' == $using ) {
    2498         $count = get_user_count();
     2506        $count = get_user_count( $network_id );
    24992507        /**
    25002508         * Filters whether the network is considered large.
    25012509         *
    25022510         * @since 3.3.0
     2511         * @since 4.8.0 The $network_id parameter has been added.
    25032512         *
    25042513         * @param bool   $is_large_network Whether the network has more than 10000 users or sites.
    25052514         * @param string $component        The component to count. Accepts 'users', or 'sites'.
    25062515         * @param int    $count            The count of items for the component.
     2516         * @param int    $network_id       The ID of the network being checked.
    25072517         */
    2508         return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
    2509     }
    2510 
    2511     $count = get_blog_count();
     2518        return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
     2519    }
     2520
     2521    $count = get_blog_count( $network_id );
    25122522    /** This filter is documented in wp-includes/ms-functions.php */
    2513     return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
     2523    return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id );
    25142524}
    25152525
Note: See TracChangeset for help on using the changeset viewer.