Make WordPress Core

Ticket #17582: 17582.diff

File 17582.diff, 1.4 KB (added by scribu, 14 years ago)
  • wp-includes/user.php

     
    383383                                'search' => '',
    384384                                'orderby' => 'login',
    385385                                'order' => 'ASC',
    386                                 'offset' => '', 'number' => '',
     386                                'offset' => '',
     387                                'number' => '',
    387388                                'count_total' => true,
    388389                                'fields' => 'all',
     390                                'distinct' => false,
    389391                                'who' => ''
    390392                        ) );
    391393
     
    418420                        $this->query_fields = "$wpdb->users.ID";
    419421                }
    420422
     423                if ( $this->query_vars['distinct'] ) {
     424                        $this->query_fields = 'DISTINCT ' . $this->query_fields;
     425                }
     426
     427                if ( $this->query_vars['count_total'] ) {
     428                        $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
     429                }
     430
    421431                $this->query_from = "FROM $wpdb->users";
    422432                $this->query_where = "WHERE 1=1";
    423433
     
    545555                        $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
    546556                }
    547557
    548                 if ( $this->query_vars['count_total'] )
    549                         $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
     558                if ( $this->query_vars['count_total'] ) {
     559                        $found_users_query = apply_filters( 'found_users_query', "SELECT FOUND_ROWS()" );
     560                        $this->total_users = $wpdb->get_var( $found_users_query );
     561                }
    550562
    551563                if ( !$this->results )
    552564                        return;