| 1 | Index: wp-includes/user.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/user.php (revision 21992) |
|---|
| 4 | +++ wp-includes/user.php (working copy) |
|---|
| 5 | @@ -314,6 +314,15 @@ |
|---|
| 6 | class WP_User_Query { |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | + * Query vars, after parsing |
|---|
| 10 | + * |
|---|
| 11 | + * @since 3.5.0 |
|---|
| 12 | + * @access public |
|---|
| 13 | + * @var array |
|---|
| 14 | + */ |
|---|
| 15 | + var $query_vars = array(); |
|---|
| 16 | + |
|---|
| 17 | + /** |
|---|
| 18 | * List of found user ids |
|---|
| 19 | * |
|---|
| 20 | * @since 3.1.0 |
|---|
| 21 | @@ -381,7 +390,7 @@ |
|---|
| 22 | function prepare_query() { |
|---|
| 23 | global $wpdb; |
|---|
| 24 | |
|---|
| 25 | - $qv = &$this->query_vars; |
|---|
| 26 | + $qv =& $this->query_vars; |
|---|
| 27 | |
|---|
| 28 | if ( is_array( $qv['fields'] ) ) { |
|---|
| 29 | $qv['fields'] = array_unique( $qv['fields'] ); |
|---|
| 30 | @@ -396,7 +405,7 @@ |
|---|
| 31 | $this->query_fields = "$wpdb->users.ID"; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | - if ( $this->query_vars['count_total'] ) |
|---|
| 35 | + if ( $qv['count_total'] ) |
|---|
| 36 | $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; |
|---|
| 37 | |
|---|
| 38 | $this->query_from = "FROM $wpdb->users"; |
|---|
| 39 | @@ -528,29 +537,60 @@ |
|---|
| 40 | function query() { |
|---|
| 41 | global $wpdb; |
|---|
| 42 | |
|---|
| 43 | - if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) { |
|---|
| 44 | + $qv =& $this->query_vars; |
|---|
| 45 | + |
|---|
| 46 | + if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { |
|---|
| 47 | $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); |
|---|
| 48 | } else { |
|---|
| 49 | $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | - if ( $this->query_vars['count_total'] ) |
|---|
| 53 | + if ( $qv['count_total'] ) |
|---|
| 54 | $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); |
|---|
| 55 | |
|---|
| 56 | if ( !$this->results ) |
|---|
| 57 | return; |
|---|
| 58 | |
|---|
| 59 | - if ( 'all_with_meta' == $this->query_vars['fields'] ) { |
|---|
| 60 | + if ( 'all_with_meta' == $qv['fields'] ) { |
|---|
| 61 | cache_users( $this->results ); |
|---|
| 62 | |
|---|
| 63 | $r = array(); |
|---|
| 64 | foreach ( $this->results as $userid ) |
|---|
| 65 | - $r[ $userid ] = new WP_User( $userid, '', $this->query_vars['blog_id'] ); |
|---|
| 66 | + $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); |
|---|
| 67 | |
|---|
| 68 | $this->results = $r; |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | + /** |
|---|
| 73 | + * Retrieve query variable. |
|---|
| 74 | + * |
|---|
| 75 | + * @since 3.5.0 |
|---|
| 76 | + * @access public |
|---|
| 77 | + * |
|---|
| 78 | + * @param string $query_var Query variable key. |
|---|
| 79 | + * @return mixed |
|---|
| 80 | + */ |
|---|
| 81 | + function get( $query_var ) { |
|---|
| 82 | + if ( isset( $this->query_vars[$query_var] ) ) |
|---|
| 83 | + return $this->query_vars[$query_var]; |
|---|
| 84 | + |
|---|
| 85 | + return null; |
|---|
| 86 | + } |
|---|
| 87 | + |
|---|
| 88 | + /** |
|---|
| 89 | + * Set query variable. |
|---|
| 90 | + * |
|---|
| 91 | + * @since 3.5.0 |
|---|
| 92 | + * @access public |
|---|
| 93 | + * |
|---|
| 94 | + * @param string $query_var Query variable key. |
|---|
| 95 | + * @param mixed $value Query variable value. |
|---|
| 96 | + */ |
|---|
| 97 | + function set( $query_var, $value ) { |
|---|
| 98 | + $this->query_vars[$query_var] = $value; |
|---|
| 99 | + } |
|---|
| 100 | + |
|---|
| 101 | /* |
|---|
| 102 | * Used internally to generate an SQL string for searching across multiple columns |
|---|
| 103 | * |
|---|