Changes from branches/3.1/wp-includes/user.php at r17635 to trunk/wp-includes/user.php at r18178
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/user.php
r17635 r18178 166 166 * 167 167 * @since 3.0.0 168 * @param array $users User ID number list. 168 * @param array $user_ids Array of user IDs. 169 * @param string|array $post_type Optional. Post type to check. Defaults to post. 169 170 * @return array Amount of posts each user has written. 170 171 */ 171 function count_many_users_posts($users ) {172 function count_many_users_posts($users, $post_type = 'post' ) { 172 173 global $wpdb; 173 174 174 175 $count = array(); 175 if ( ! is_array($users) || empty( $users ) )176 if ( empty( $users ) || ! is_array( $users ) ) 176 177 return $count; 177 178 178 $userlist = implode( ',', $users);179 $where = get_posts_by_author_sql( 'post');179 $userlist = implode( ',', array_map( 'absint', $users ) ); 180 $where = get_posts_by_author_sql( $post_type ); 180 181 181 182 $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); … … 361 362 var $query_limit; 362 363 363 /**364 * PHP4 constructor365 */366 function WP_User_Query( $query = null ) {367 $this->__construct( $query );368 }369 364 370 365 /** … … 389 384 'orderby' => 'login', 390 385 'order' => 'ASC', 391 'offset' => '', 'number' => '', 386 'offset' => '', 387 'number' => '', 392 388 'count_total' => true, 393 389 'fields' => 'all', … … 423 419 $this->query_fields = "$wpdb->users.ID"; 424 420 } 421 422 if ( $this->query_vars['count_total'] ) 423 $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; 425 424 426 425 $this->query_from = "FROM $wpdb->users"; … … 497 496 if ( 'authors' == $qv['who'] && $blog_id ) { 498 497 $qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level'; 499 $qv['meta_value'] = '_wp_zero_value'; // Hack to pass '0'498 $qv['meta_value'] = 0; 500 499 $qv['meta_compare'] = '!='; 501 500 $qv['blog_id'] = $blog_id = 0; // Prevent extra meta query 502 501 } 503 504 _parse_meta_query( $qv );505 502 506 503 $role = trim( $qv['role'] ); … … 518 515 } 519 516 520 if ( !empty( $qv['meta_query'] ) ) { 521 $clauses = call_user_func_array( '_get_meta_sql', array( $qv['meta_query'], 'user', $wpdb->users, 'ID', &$this ) ); 517 $meta_query = new WP_Meta_Query(); 518 $meta_query->parse_query_vars( $qv ); 519 520 if ( !empty( $meta_query->queries ) ) { 521 $clauses = $meta_query->get_sql( 'user', $wpdb->users, 'ID', $this ); 522 522 $this->query_from .= $clauses['join']; 523 523 $this->query_where .= $clauses['where']; 524 525 if ( 'OR' == $meta_query->relation ) 526 $this->query_fields = 'DISTINCT ' . $this->query_fields; 524 527 } 525 528 … … 551 554 552 555 if ( $this->query_vars['count_total'] ) 553 $this->total_users = $wpdb->get_var( "SELECT COUNT(*) $this->query_from $this->query_where");556 $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); 554 557 555 558 if ( !$this->results ) … … 741 744 * Add meta data field to a user. 742 745 * 743 * Post meta data is called "Custom Fields" on the Administration Panels.746 * Post meta data is called "Custom Fields" on the Administration Screens. 744 747 * 745 748 * @since 3.0.0 … … 1356 1359 * 'user_email' - A string containing the user's email address. 1357 1360 * 'display_name' - A string that will be shown on the site. Defaults to user's 1358 * username. It is likely that you will want to change this, for both 1359 * appearance and security through obscurity (that is if you don't use and 1360 * delete the default 'admin' user). 1361 * username. It is likely that you will want to change this, for appearance. 1361 1362 * 'nickname' - The user's nickname, defaults to the user's username. 1362 1363 * 'first_name' - The user's first name.
Note: See TracChangeset
for help on using the changeset viewer.