Make WordPress Core

Ticket #21426: 21426.diff

File 21426.diff, 2.7 KB (added by nacin, 13 years ago)
  • wp-includes/user.php

     
    314314class WP_User_Query {
    315315
    316316        /**
     317         * Query vars, after parsing
     318         *
     319         * @since 3.5.0
     320         * @access public
     321         * @var array
     322         */
     323        var $query_vars = array();
     324
     325        /**
    317326         * List of found user ids
    318327         *
    319328         * @since 3.1.0
     
    381390        function prepare_query() {
    382391                global $wpdb;
    383392
    384                 $qv = &$this->query_vars;
     393                $qv =& $this->query_vars;
    385394
    386395                if ( is_array( $qv['fields'] ) ) {
    387396                        $qv['fields'] = array_unique( $qv['fields'] );
     
    396405                        $this->query_fields = "$wpdb->users.ID";
    397406                }
    398407
    399                 if ( $this->query_vars['count_total'] )
     408                if ( $qv['count_total'] )
    400409                        $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
    401410
    402411                $this->query_from = "FROM $wpdb->users";
     
    528537        function query() {
    529538                global $wpdb;
    530539
    531                 if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) {
     540                $qv =& $this->query_vars;
     541
     542                if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
    532543                        $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
    533544                } else {
    534545                        $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
    535546                }
    536547
    537                 if ( $this->query_vars['count_total'] )
     548                if ( $qv['count_total'] )
    538549                        $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
    539550
    540551                if ( !$this->results )
    541552                        return;
    542553
    543                 if ( 'all_with_meta' == $this->query_vars['fields'] ) {
     554                if ( 'all_with_meta' == $qv['fields'] ) {
    544555                        cache_users( $this->results );
    545556
    546557                        $r = array();
    547558                        foreach ( $this->results as $userid )
    548                                 $r[ $userid ] = new WP_User( $userid, '', $this->query_vars['blog_id'] );
     559                                $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] );
    549560
    550561                        $this->results = $r;
    551562                }
    552563        }
    553564
     565        /**
     566         * Retrieve query variable.
     567         *
     568         * @since 3.5.0
     569         * @access public
     570         *
     571         * @param string $query_var Query variable key.
     572         * @return mixed
     573         */
     574        function get( $query_var ) {
     575                if ( isset( $this->query_vars[$query_var] ) )
     576                        return $this->query_vars[$query_var];
     577
     578                return null;
     579        }
     580
     581        /**
     582         * Set query variable.
     583         *
     584         * @since 3.5.0
     585         * @access public
     586         *
     587         * @param string $query_var Query variable key.
     588         * @param mixed $value Query variable value.
     589         */
     590        function set( $query_var, $value ) {
     591                $this->query_vars[$query_var] = $value;
     592        }
     593
    554594        /*
    555595         * Used internally to generate an SQL string for searching across multiple columns
    556596         *