WordPress.org

Make WordPress Core

Changeset 18871


Ignore:
Timestamp:
10/03/2011 04:30:07 PM (7 years ago)
Author:
ryan
Message:

Consolidate larg network criteria into wp_is_large_network(). Allow plugins to change this criteria via filter. Props PeteMall. fixes #18464

Location:
trunk/wp-admin/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-sites-list-table.php

    r18562 r18871  
    3838        $like_s = esc_sql( like_escape( $s ) );
    3939
    40         $large_network = false;
    4140        // If the network is large and a search is not being performed, show only the latest blogs with no paging in order
    4241        // to avoid expensive count queries.
    43         if ( !$s && ( get_blog_count() >= 10000 ) ) {
     42        if ( !$s && wp_is_large_network() ) {
    4443            if ( !isset($_REQUEST['orderby']) )
    4544                $_GET['orderby'] = $_REQUEST['orderby'] = '';
    4645            if ( !isset($_REQUEST['order']) )
    4746                $_GET['order'] = $_REQUEST['order'] = 'DESC';
    48             $large_network = true;
    4947        }
    5048
     
    105103
    106104        // Don't do an unbounded count on large networks
    107         if ( ! $large_network )
     105        if ( ! wp_is_large_network() )
    108106            $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
    109107
     
    111109        $this->items = $wpdb->get_results( $query, ARRAY_A );
    112110
    113         if ( $large_network )
     111        if ( wp_is_large_network() )
    114112            $total = count($this->items);
    115113
  • trunk/wp-admin/includes/class-wp-ms-users-list-table.php

    r18562 r18871  
    3333        );
    3434
    35         $args['search'] = ltrim($args['search'], '*');
     35        if ( wp_is_large_network( 'users' ) )
     36            $args['search'] = ltrim( $args['search'], '*' );
    3637
    3738        if ( $role == 'super' ) {
     
    4243        // If the network is large and a search is not being performed, show only the latest users with no paging in order
    4344        // to avoid expensive count queries.
    44         if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
     45        if ( !$usersearch && wp_is_large_network( 'users' ) ) {
    4546            if ( !isset($_REQUEST['orderby']) )
    4647                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
  • trunk/wp-admin/includes/ms.php

    r18504 r18871  
    776776}
    777777
     778/**
     779 * Whether or not we have a large network.
     780 *
     781 * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
     782 * Plugins can alter this criteria  using the 'wp_is_large_network' filter.
     783 *
     784 * @since 3.3.0
     785 * @param string $using 'sites or 'users'.  Default is 'sites'.
     786 * @return bool True if the network meets the criteria for large. False otherwise.
     787 */
     788function wp_is_large_network( $using = 'sites' ) {
     789    if ( 'users' == $using ) {
     790        $count = get_user_count();
     791        return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
     792    }
     793
     794    $count = get_blog_count();
     795    return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
     796}
    778797?>
Note: See TracChangeset for help on using the changeset viewer.