| 1 | Index: wp-includes/user.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/user.php (revision 16942) |
|---|
| 4 | +++ wp-includes/user.php (working copy) |
|---|
| 5 | @@ -351,7 +351,8 @@ |
|---|
| 6 | */ |
|---|
| 7 | var $total_users = 0; |
|---|
| 8 | |
|---|
| 9 | - // SQL pieces |
|---|
| 10 | + // SQL clauses |
|---|
| 11 | + var $query_fields; |
|---|
| 12 | var $query_from; |
|---|
| 13 | var $query_where; |
|---|
| 14 | var $query_orderby; |
|---|
| 15 | @@ -406,6 +407,14 @@ |
|---|
| 16 | |
|---|
| 17 | $qv = &$this->query_vars; |
|---|
| 18 | |
|---|
| 19 | + if ( is_array( $qv['fields'] ) ) { |
|---|
| 20 | + $this->query_fields = array(); |
|---|
| 21 | + foreach ( $qv['fields'] as $field ) |
|---|
| 22 | + $this->query_fields[] = $wpdb->users . '.' . esc_sql( $field ); |
|---|
| 23 | + $this->query_fields = implode( ',', $this->query_fields ); |
|---|
| 24 | + } else { |
|---|
| 25 | + $this->query_fields = "$wpdb->users.ID"; |
|---|
| 26 | + } |
|---|
| 27 | $this->query_from = " FROM $wpdb->users"; |
|---|
| 28 | $this->query_where = " WHERE 1=1"; |
|---|
| 29 | |
|---|
| 30 | @@ -508,13 +517,17 @@ |
|---|
| 31 | function query() { |
|---|
| 32 | global $wpdb; |
|---|
| 33 | |
|---|
| 34 | - $this->results = $wpdb->get_col("SELECT $wpdb->users.ID" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); |
|---|
| 35 | + if ( is_array( $this->query_vars['fields'] ) ) { |
|---|
| 36 | + $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); |
|---|
| 37 | + } else { |
|---|
| 38 | + $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); |
|---|
| 39 | + } |
|---|
| 40 | |
|---|
| 41 | if ( !$this->results ) |
|---|
| 42 | return; |
|---|
| 43 | |
|---|
| 44 | if ( $this->query_vars['count_total'] ) |
|---|
| 45 | - $this->total_users = $wpdb->get_var("SELECT COUNT($wpdb->users.ID)" . $this->query_from . $this->query_where); |
|---|
| 46 | + $this->total_users = $wpdb->get_var("SELECT COUNT($wpdb->users.ID) $this->query_from $this->query_where $this->query_orderby $this->query_limit"); |
|---|
| 47 | |
|---|
| 48 | if ( 'all' == $this->query_vars['fields'] ) { |
|---|
| 49 | cache_users($this->results); |
|---|
| 50 | @@ -965,8 +978,11 @@ |
|---|
| 51 | $r = wp_parse_args( $args, $defaults ); |
|---|
| 52 | extract( $r, EXTR_SKIP ); |
|---|
| 53 | |
|---|
| 54 | - $users = get_users( wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) ) ); |
|---|
| 55 | + $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) ); |
|---|
| 56 | + $query_args['fields'] = array( 'ID', $show ); |
|---|
| 57 | |
|---|
| 58 | + $users = get_users( $query_args ); |
|---|
| 59 | + |
|---|
| 60 | $output = ''; |
|---|
| 61 | if ( !empty($users) ) { |
|---|
| 62 | $name = esc_attr( $name ); |
|---|