Changeset 59900
- Timestamp:
- 03/02/2025 11:04:23 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r59828 r59900 661 661 global $wpdb; 662 662 663 $count = array();664 663 if ( empty( $users ) || ! is_array( $users ) ) { 665 return $count; 664 return array(); 665 } 666 667 /** 668 * Filters whether to short-circuit performing the post counts. 669 * 670 * When filtering, return an array of posts counts as strings, keyed 671 * by the user ID. 672 * 673 * @since 6.8.0 674 * 675 * @param string[]|null $count The post counts. Return a non-null value to short-circuit. 676 * @param int[] $users Array of user IDs. 677 * @param string|string[] $post_type Single post type or array of post types to check. 678 * @param bool $public_only Whether to only return counts for public posts. 679 */ 680 $pre = apply_filters( 'pre_count_many_users_posts', null, $users, $post_type, $public_only ); 681 if ( null !== $pre ) { 682 return $pre; 666 683 } 667 684 … … 670 687 671 688 $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); 689 690 $count = array_fill_keys( $users, 0 ); 672 691 foreach ( $result as $row ) { 673 692 $count[ $row[0] ] = $row[1]; 674 }675 676 foreach ( $users as $id ) {677 if ( ! isset( $count[ $id ] ) ) {678 $count[ $id ] = 0;679 }680 693 } 681 694
Note: See TracChangeset
for help on using the changeset viewer.