diff --git src/wp-includes/author-template.php src/wp-includes/author-template.php
index 4ee210f555..e9dbf4ecd6 100644
|
|
function wp_list_authors( $args = '' ) { |
435 | 435 | |
436 | 436 | $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); |
437 | 437 | $query_args['fields'] = 'ids'; |
438 | | $authors = get_users( $query_args ); |
| 438 | |
| 439 | // @link https://core.trac.wordpress.org/ticket/23498 |
| 440 | if( true == $args['exclude_admin'] ) { |
| 441 | $exclude = get_users( array( 'role' => 'administrator' ) ); |
| 442 | foreach ( $exclude as $admin ) { |
| 443 | $exclude_ids[] = $admin->ID; |
| 444 | } |
| 445 | $query_args['exclude'] = $exclude_ids; |
| 446 | } |
| 447 | |
| 448 | $authors = get_users( $query_args ); |
439 | 449 | |
440 | 450 | $author_count = array(); |
441 | 451 | foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . ' GROUP BY post_author' ) as $row ) { |
… |
… |
function wp_list_authors( $args = '' ) { |
450 | 460 | |
451 | 461 | $author = get_userdata( $author_id ); |
452 | 462 | |
453 | | if ( $args['exclude_admin'] && 'admin' === $author->display_name ) { |
454 | | continue; |
455 | | } |
456 | | |
457 | 463 | if ( $args['show_fullname'] && $author->first_name && $author->last_name ) { |
458 | 464 | $name = "$author->first_name $author->last_name"; |
459 | 465 | } else { |
diff --git tests/phpunit/tests/user/listAuthors.php tests/phpunit/tests/user/listAuthors.php
index 8dcfad8935..216b3b9db6 100644
|
|
class Tests_User_ListAuthors extends WP_UnitTestCase { |
248 | 248 | ) |
249 | 249 | ); |
250 | 250 | } |
| 251 | |
| 252 | /** |
| 253 | * @ticket 23498 |
| 254 | **/ |
| 255 | function test_wp_list_authors_number() { |
| 256 | $expected['number'] = |
| 257 | '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li>' . |
| 258 | '<li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li>' . |
| 259 | '<li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>'; |
| 260 | $a = wp_list_authors( array( 'echo' => false ) ); |
| 261 | $this->AssertEquals( $expected['number'], $a ); |
| 262 | } |
| 263 | |
251 | 264 | } |