Ticket #32243: user.diff
File user.diff, 1.4 KB (added by , 10 years ago) |
---|
-
user.php
254 254 * 255 255 * @global wpdb $wpdb WordPress database object for queries. 256 256 * 257 * @param int $useridUser ID.258 * @param string $post_type Optional. Post typeto count the number of posts for. Default 'post'.257 * @param int $userid User ID. 258 * @param array/string $post_types Optional. Post type(s) to count the number of posts for. Default 'post'. 259 259 * @return int Number of posts the user has written in this post type. 260 260 */ 261 function count_user_posts( $userid, $post_type = 'post' ) {261 function count_user_posts( $userid, $post_types = 'post' ) { 262 262 global $wpdb; 263 264 if ( is_string( $post_types ) ) $post_types = explode(',', $post_types); 263 265 264 $where = get_posts_by_author_sql( $post_type , true, $userid );266 $where = get_posts_by_author_sql( $post_types, true, $userid ); 265 267 266 268 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); 267 269 … … 273 275 * 274 276 * @param int $count The user's post count. 275 277 * @param int $userid User ID. 276 * @param string $post_type Post typeto count the number of posts for.278 * @param array $post_types Post types to count the number of posts for. 277 279 */ 278 return apply_filters( 'get_usernumposts', $count, $userid, $post_type );280 return apply_filters( 'get_usernumposts', $count, $userid, $post_types ); 279 281 } 280 282 281 283 /**