Changeset 32523 for trunk/src/wp-includes/user.php
- Timestamp:
- 05/21/2015 06:42:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r32207 r32523 252 252 * @since 3.0.0 253 253 * @since 4.1.0 Added `$post_type` argument. 254 * @since 4.3.0 Added `$public_only` argument. 254 255 * 255 256 * @global wpdb $wpdb WordPress database object for queries. 256 257 * 257 * @param int $userid User ID. 258 * @param string $post_type Optional. Post type to count the number of posts for. Default 'post'. 258 * @param int $userid User ID. 259 * @param array|string $post_type Optional. Post type(s) to count the number of posts for. Default 'post'. 260 * @param bool $public_only Optional. Only return counts for public posts. Defaults to false. 259 261 * @return int Number of posts the user has written in this post type. 260 262 */ 261 function count_user_posts( $userid, $post_type = 'post' ) {263 function count_user_posts( $userid, $post_type = 'post', $public_only = false ) { 262 264 global $wpdb; 263 265 264 $where = get_posts_by_author_sql( $post_type, true, $userid );266 $where = get_posts_by_author_sql( $post_type, true, $userid, $public_only ); 265 267 266 268 $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); … … 271 273 * @since 2.7.0 272 274 * @since 4.1.0 Added `$post_type` argument. 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. 275 * @since 4.3.0 Added `$public_only` argument. 276 * 277 * @param int $count The user's post count. 278 * @param int $userid User ID. 279 * @param string|array $post_types Post types to count the number of posts for. 280 * @param bool $public_only Whether to limit counted posts to public posts. 277 281 */ 278 282 return apply_filters( 'get_usernumposts', $count, $userid, $post_type ); … … 284 288 * @since 3.0.0 285 289 * 286 * @param array $usersArray of user IDs.287 * @param string $post_type Optional. Post type to check. Defaults to post.288 * @param bool $public_only Optional. Only return counts for public posts. Defaults to false.290 * @param array $users Array of user IDs. 291 * @param string|array $post_type Optional. Array or comma-separated list of post types to check. Defaults to 'post'. 292 * @param bool $public_only Optional. Only return counts for public posts. Defaults to false. 289 293 * @return array Amount of posts each user has written. 290 294 */
Note: See TracChangeset
for help on using the changeset viewer.