Changeset 30322 for trunk/src/wp-includes/user.php
- Timestamp:
- 11/13/2014 02:18:30 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r30122 r30322 251 251 * 252 252 * @since 3.0.0 253 * @since 4.0.0 Added $post_type parameter. 253 254 * 254 255 * @global wpdb $wpdb WordPress database object for queries. 255 256 * 256 * @param int $userid User ID. 257 * @return int Amount of posts user has written. 258 */ 259 function count_user_posts($userid) { 257 * @param int $userid User ID. 258 * @param string $post_type Optional. Post type to count the number of posts for. Default 'post'. 259 * @return int Number of posts the user has written in this post type. 260 */ 261 function count_user_posts( $userid, $post_type = 'post' ) { 260 262 global $wpdb; 261 263 262 $where = get_posts_by_author_sql( 'post', true, $userid);264 $where = get_posts_by_author_sql( $post_type, true, $userid ); 263 265 264 266 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); … … 268 270 * 269 271 * @since 2.7.0 270 * 271 * @param int $count The user's post count. 272 * @param int $userid User ID. 273 */ 274 return apply_filters( 'get_usernumposts', $count, $userid ); 272 * @since 4.0.0 Added $post_type parameter. 273 * 274 * @param int $count The user's post count. 275 * @param int $userid User ID. 276 * @param string $post_type Post type to count the number of posts for. 277 */ 278 return apply_filters( 'get_usernumposts', $count, $userid, $post_type ); 275 279 } 276 280
Note: See TracChangeset
for help on using the changeset viewer.