Ticket #21364: 21364.2.diff
File 21364.2.diff, 898 bytes (added by , 12 years ago) |
---|
-
wp-includes/user.php
148 148 * @uses $wpdb WordPress database object for queries. 149 149 * 150 150 * @param int $userid User ID. 151 * @param string|array $post_type Optional. Post type to check. Defaults to post. 151 152 * @return int Amount of posts user has written. 152 153 */ 153 function count_user_posts( $userid) {154 function count_user_posts( $userid, $post_type = 'post' ) { 154 155 global $wpdb; 155 156 156 $where = get_posts_by_author_sql( 'post', true, $userid);157 $where = get_posts_by_author_sql( $post_type, true, $userid ); 157 158 158 159 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); 159 160 160 return apply_filters( 'get_usernumposts', $count, $userid);161 return apply_filters( 'get_usernumposts', $count, $userid, $post_type ); 161 162 } 162 163 163 164 /**