protected function get_counts( $post_types ) {
		global $wpdb;

		if ( count( $post_types ) <= 0 ) {
			return [];
		}

		$query = $wpdb->prepare(
			"SELECT `post_type`, COUNT(*) AS `count`
			FROM $wpdb->posts
			WHERE `post_type` IN (" . implode( ',', array_fill( 0, count( $post_types ), '%s' ) ) . ')
			GROUP BY `post_type`',
			$post_types
		);
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $query is already prepared above.
		$counts = $wpdb->get_results( $query );

		// Make sure there's a count for every item.
		$counts = array_merge(
			array_fill_keys( $post_types, 0 ),
			wp_list_pluck( $counts, 'count', 'post_type' )
		);

		return $counts;
	}
protected function get_counts( $post_types ) {
		global $wpdb;

		if ( count( $post_types ) <= 0 ) {
			return [];
		}

		$query = $wpdb->prepare(
			"SELECT `post_type`, COUNT(*) AS `count`
			FROM $wpdb->posts
			WHERE `post_type` IN (" . implode( ',', array_fill( 0, count( $post_types ), '%s' ) ) . ')
			GROUP BY `post_type`',
			$post_types
		);
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $query is already prepared above.
		$counts = $wpdb->get_results( $query );

		// Make sure there's a count for every item.
		$counts = array_merge(
			array_fill_keys( $post_types, 0 ),
			wp_list_pluck( $counts, 'count', 'post_type' )
		);

		return $counts;
	}
protected function get_counts ( $ post_types ) { global $ wpdb ; if ( count ( $ post_types ) <= 0 ) { return [ ] ; } $ query = $ wpdb -> prepare ( "SELECT `post_type`, COUNT(*) AS `count`
			FROM $wpdb->posts
			WHERE `post_type` IN (" . implode ( ',' , array_fill ( 0 , count ( $ post_types ) , '%s' ) ) . ')
			GROUP BY `post_type`' , $ post_types ) ; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $query is already prepared above. $ counts = $ wpdb -> get_results ( $ query ) ; // Make sure there's a count for every item. $ counts = array_merge ( array_fill_keys ( $ post_types , 0 ) , wp_list_pluck ( $ counts , 'count' , 'post_type' ) ) ; return $ counts ; }
Gets the post counts for each supplied post type.

@param array $post_types Post types to fetch counts for.
@return array Associative array of post counts keyed by post type.
Gets the post counts for each supplied post type .