Users: In `wp_list_authors()`, check for author's post count before getting author's metadata.
This significantly reduces the number of SQL queries when `wp_list_authors()` is called on a site where the majority of users don't have any posts, e.g. a membership site. Props billerickson, ianbelanger, dswebsme. Fixes #45105. Built from https://develop.svn.wordpress.org/trunk@45235 git-svn-id: http://core.svn.wordpress.org/trunk@45044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
23de32062e
commit
2e0e63f923
|
@ -442,15 +442,15 @@ function wp_list_authors( $args = '' ) {
|
||||||
$author_count[ $row->post_author ] = $row->count;
|
$author_count[ $row->post_author ] = $row->count;
|
||||||
}
|
}
|
||||||
foreach ( $authors as $author_id ) {
|
foreach ( $authors as $author_id ) {
|
||||||
$author = get_userdata( $author_id );
|
$posts = isset( $author_count[ $author_id ] ) ? $author_count[ $author_id ] : 0;
|
||||||
|
|
||||||
if ( $args['exclude_admin'] && 'admin' == $author->display_name ) {
|
if ( ! $posts && $args['hide_empty'] ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts = isset( $author_count[ $author->ID ] ) ? $author_count[ $author->ID ] : 0;
|
$author = get_userdata( $author_id );
|
||||||
|
|
||||||
if ( ! $posts && $args['hide_empty'] ) {
|
if ( $args['exclude_admin'] && 'admin' === $author->display_name ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.2-beta3-45234';
|
$wp_version = '5.2-beta3-45235';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue