Make WordPress Core

Ticket #21119: 21119.diff

File 21119.diff, 2.4 KB (added by scribu, 13 years ago)
  • wp-includes/user.php

    diff --git wp-includes/user.php wp-includes/user.php
    index 6b342c8..8e6b345 100644
    class WP_User_Query { 
    369369         */
    370370        function __construct( $query = null ) {
    371371                if ( !empty( $query ) ) {
    372                         $this->query_vars = wp_parse_args( $query, array(
    373                                 'blog_id' => $GLOBALS['blog_id'],
    374                                 'role' => '',
    375                                 'meta_key' => '',
    376                                 'meta_value' => '',
    377                                 'meta_compare' => '',
    378                                 'include' => array(),
    379                                 'exclude' => array(),
    380                                 'search' => '',
    381                                 'search_columns' => array(),
    382                                 'orderby' => 'login',
    383                                 'order' => 'ASC',
    384                                 'offset' => '',
    385                                 'number' => '',
    386                                 'count_total' => true,
    387                                 'fields' => 'all',
    388                                 'who' => ''
    389                         ) );
    390 
    391                         $this->prepare_query();
     372                        $this->prepare_query( $query );
    392373                        $this->query();
    393374                }
    394375        }
    class WP_User_Query { 
    397378         * Prepare the query variables
    398379         *
    399380         * @since 3.1.0
    400          * @access private
     381         *
     382         * @param string|array $args The query variables
    401383         */
    402         function prepare_query() {
     384        function prepare_query( $query ) {
    403385                global $wpdb;
    404386
     387                $this->query_vars = wp_parse_args( $query, array(
     388                        'blog_id' => $GLOBALS['blog_id'],
     389                        'role' => '',
     390                        'meta_key' => '',
     391                        'meta_value' => '',
     392                        'meta_compare' => '',
     393                        'include' => array(),
     394                        'exclude' => array(),
     395                        'search' => '',
     396                        'search_columns' => array(),
     397                        'orderby' => 'login',
     398                        'order' => 'ASC',
     399                        'offset' => '',
     400                        'number' => '',
     401                        'count_total' => true,
     402                        'fields' => 'all',
     403                        'who' => ''
     404                ) );
     405
    405406                $qv = &$this->query_vars;
    406407
    407408                if ( is_array( $qv['fields'] ) ) {
    class WP_User_Query { 
    544545         * Execute the query, with the current variables
    545546         *
    546547         * @since 3.1.0
    547          * @access private
    548548         */
    549549        function query() {
    550550                global $wpdb;
    551551
     552                $query = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
     553
    552554                if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) {
    553                         $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
     555                        $this->results = $wpdb->get_results( $query );
    554556                } else {
    555                         $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
     557                        $this->results = $wpdb->get_col( $query );
    556558                }
    557559
    558560                if ( $this->query_vars['count_total'] )