diff --git src/wp-includes/user.php src/wp-includes/user.php
index 9a685b9b36..82ad168063 100644
|
|
|
function count_user_posts( $userid, $post_type = 'post', $public_only = false ) |
| 381 | 381 | |
| 382 | 382 | $where = get_posts_by_author_sql( $post_type, true, $userid, $public_only ); |
| 383 | 383 | |
| 384 | | $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); |
| | 384 | $cache_key = "count_user_posts_$userid"; |
| | 385 | $count = wp_cache_get( $cache_key, 'user_posts_count' ); |
| | 386 | |
| | 387 | if ( false === $count ) { |
| | 388 | $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); |
| | 389 | wp_cache_add( $cache_key, $count, 'user_posts_count', 5 * MINUTE_IN_SECONDS ); |
| | 390 | } |
| 385 | 391 | |
| 386 | 392 | /** |
| 387 | 393 | * Filters the number of posts a user has written. |
| … |
… |
function count_many_users_posts( $users, $post_type = 'post', $public_only = fal |
| 418 | 424 | return $count; |
| 419 | 425 | } |
| 420 | 426 | |
| 421 | | $userlist = implode( ',', array_map( 'absint', $users ) ); |
| 422 | | $where = get_posts_by_author_sql( $post_type, true, null, $public_only ); |
| 423 | | |
| 424 | | $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); |
| 425 | | foreach ( $result as $row ) { |
| 426 | | $count[ $row[0] ] = $row[1]; |
| | 427 | foreach ( $users as $user_id ) { |
| | 428 | $count[ $user_id ] = count_user_posts( $user_id, $post_type, $public_only ); |
| 427 | 429 | } |
| 428 | 430 | |
| 429 | 431 | foreach ( $users as $id ) { |