Changeset 17742 for trunk/wp-includes/user.php
- Timestamp:
- 04/28/2011 11:27:39 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/user.php
r17699 r17742 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 );
Note: See TracChangeset
for help on using the changeset viewer.