WordPress.org

Make WordPress Core

Ticket #18464: 18464.diff

File 18464.diff, 3.4 KB (added by PeteMall, 7 years ago)
  • wp-admin/includes/ms.php

     
    775775<?php
    776776}
    777777
     778/**
     779 * Whether or not we have a large network
     780 *
     781 * @since 3.3.0
     782 * @param string $using sites/users
     783 */
     784function wp_is_large_network( $using = 'sites' ) {
     785        if ( 'users' == $using ) {
     786                $count = get_user_count();
     787                return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
     788        }
     789
     790        $count = get_blog_count();
     791        return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
     792}
    778793?>
  • wp-admin/includes/class-wp-ms-sites-list-table.php

     
    3737
    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
    5149                $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
     
    104102                }
    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
    110108                $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
    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
    116114                $this->set_pagination_args( array(
     
    127125                $actions = array();
    128126                if ( current_user_can( 'delete_sites' ) )
    129127                        $actions['delete'] = __( 'Delete' );
     128                if ( current_user_can( 'promote_users' ) )
     129                        $actions['addusers'] = __( 'Add existing user' );
    130130                $actions['spam'] = _x( 'Mark as Spam', 'site' );
    131131                $actions['notspam'] = _x( 'Not Spam', 'site' );
    132132
  • wp-admin/includes/class-wp-ms-users-list-table.php

     
    3232                        'fields' => 'all_with_meta'
    3333                );
    3434
    35                 $args['search'] = ltrim($args['search'], '*');
     35                if ( wp_is_large_network( 'users' ) )
     36                        $args['search'] = ltrim( $args['search'], '*' );
     37                else
     38                        $args['search'] = '*' . $args['search'] . '*';
    3639
    3740                if ( $role == 'super' ) {
    3841                        $logins = implode( "', '", get_super_admins() );
     
    4144
    4245                // If the network is large and a search is not being performed, show only the latest users with no paging in order
    4346                // to avoid expensive count queries.
    44                 if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
     47                if ( !$usersearch && wp_is_large_network( 'users' ) ) {
    4548                        if ( !isset($_REQUEST['orderby']) )
    4649                                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
    4750                        if ( !isset($_REQUEST['order']) )