diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index fe6f185680..71dd25efd5 100644
|
a
|
b
|
function count_user_posts( $userid, $post_type = 'post', $public_only = false ) |
| 660 | 660 | function count_many_users_posts( $users, $post_type = 'post', $public_only = false ) { |
| 661 | 661 | global $wpdb; |
| 662 | 662 | |
| 663 | | $count = array(); |
| | 663 | /** |
| | 664 | * Short-circuit counting of users' posts. |
| | 665 | * |
| | 666 | * @since 6.8.0 |
| | 667 | * |
| | 668 | * @param bool $skip_count Whether to skip counting the users' posts. |
| | 669 | */ |
| | 670 | if ( apply_filters( 'skip_count_many_users_posts', false ) ) { |
| | 671 | return array(); |
| | 672 | } |
| | 673 | |
| 664 | 674 | if ( empty( $users ) || ! is_array( $users ) ) { |
| 665 | | return $count; |
| | 675 | return array(); |
| 666 | 676 | } |
| 667 | 677 | |
| 668 | | $userlist = implode( ',', array_map( 'absint', $users ) ); |
| | 678 | $userlist = implode( ',', wp_parse_id_list( $users ) ); |
| 669 | 679 | $where = get_posts_by_author_sql( $post_type, true, null, $public_only ); |
| 670 | 680 | |
| 671 | 681 | $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); |
| | 682 | |
| | 683 | $count = array_fill_keys( $userlist, 0 ); |
| 672 | 684 | foreach ( $result as $row ) { |
| 673 | 685 | $count[ $row[0] ] = $row[1]; |
| 674 | 686 | } |
| 675 | 687 | |
| 676 | | foreach ( $users as $id ) { |
| 677 | | if ( ! isset( $count[ $id ] ) ) { |
| 678 | | $count[ $id ] = 0; |
| 679 | | } |
| 680 | | } |
| 681 | | |
| 682 | 688 | return $count; |
| 683 | 689 | } |
| 684 | 690 | |