Changeset 54262 for trunk/src/wp-includes/author-template.php
- Timestamp:
- 09/20/2022 04:24:56 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/author-template.php
r53501 r54262 451 451 ); 452 452 453 $ args = wp_parse_args( $args, $defaults );453 $parsed_args = wp_parse_args( $args, $defaults ); 454 454 455 455 $return = ''; 456 456 457 $query_args = wp_array_slice_assoc( $ args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );457 $query_args = wp_array_slice_assoc( $parsed_args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); 458 458 $query_args['fields'] = 'ids'; 459 $authors = get_users( $query_args ); 460 461 $author_count = array(); 462 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 ) { 463 $author_count[ $row->post_author ] = $row->count; 464 } 459 460 /** 461 * Filters the query arguments for the list of all authors of the site. 462 * 463 * @since 6.1.0 464 * 465 * @param array $query_args The query arguments for get_users(). 466 * @param array $parsed_args The arguments passed to wp_list_authors() combined with the defaults. 467 */ 468 $query_args = apply_filters( 'wp_list_authors_args', $query_args, $parsed_args ); 469 470 $authors = get_users( $query_args ); 471 $post_counts = array(); 472 473 /** 474 * Filters whether to short-circuit performing the query for author post counts. 475 * 476 * @since 6.1.0 477 * 478 * @param int[]|false $post_counts Array of post counts, keyed by author ID. 479 * @param array $parsed_args The arguments passed to wp_list_authors() combined with the defaults. 480 */ 481 $post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args ); 482 483 if ( ! is_array( $post_counts ) ) { 484 $post_counts = $wpdb->get_results( 485 "SELECT DISTINCT post_author, COUNT(ID) AS count 486 FROM $wpdb->posts 487 WHERE " . get_private_posts_cap_sql( 'post' ) . ' 488 GROUP BY post_author' 489 ); 490 491 foreach ( (array) $post_counts as $row ) { 492 $post_counts[ $row->post_author ] = $row->count; 493 } 494 } 495 465 496 foreach ( $authors as $author_id ) { 466 $posts = isset( $ author_count[ $author_id ] ) ? $author_count[ $author_id ] : 0;467 468 if ( ! $posts && $ args['hide_empty'] ) {497 $posts = isset( $post_counts[ $author_id ] ) ? $post_counts[ $author_id ] : 0; 498 499 if ( ! $posts && $parsed_args['hide_empty'] ) { 469 500 continue; 470 501 } … … 472 503 $author = get_userdata( $author_id ); 473 504 474 if ( $ args['exclude_admin'] && 'admin' === $author->display_name ) {505 if ( $parsed_args['exclude_admin'] && 'admin' === $author->display_name ) { 475 506 continue; 476 507 } 477 508 478 if ( $ args['show_fullname'] && $author->first_name && $author->last_name ) {509 if ( $parsed_args['show_fullname'] && $author->first_name && $author->last_name ) { 479 510 $name = sprintf( 480 511 /* translators: 1: User's first name, 2: Last name. */ … … 487 518 } 488 519 489 if ( ! $ args['html'] ) {520 if ( ! $parsed_args['html'] ) { 490 521 $return .= $name . ', '; 491 522 … … 493 524 } 494 525 495 if ( 'list' === $ args['style'] ) {526 if ( 'list' === $parsed_args['style'] ) { 496 527 $return .= '<li>'; 497 528 } … … 505 536 ); 506 537 507 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {538 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 508 539 $link .= ' '; 509 if ( empty( $ args['feed_image'] ) ) {540 if ( empty( $parsed_args['feed_image'] ) ) { 510 541 $link .= '('; 511 542 } 512 543 513 $link .= '<a href="' . get_author_feed_link( $author->ID, $ args['feed_type'] ) . '"';544 $link .= '<a href="' . get_author_feed_link( $author->ID, $parsed_args['feed_type'] ) . '"'; 514 545 515 546 $alt = ''; 516 if ( ! empty( $ args['feed'] ) ) {517 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';518 $name = $ args['feed'];547 if ( ! empty( $parsed_args['feed'] ) ) { 548 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 549 $name = $parsed_args['feed']; 519 550 } 520 551 521 552 $link .= '>'; 522 553 523 if ( ! empty( $ args['feed_image'] ) ) {524 $link .= '<img src="' . esc_url( $ args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';554 if ( ! empty( $parsed_args['feed_image'] ) ) { 555 $link .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; 525 556 } else { 526 557 $link .= $name; … … 529 560 $link .= '</a>'; 530 561 531 if ( empty( $ args['feed_image'] ) ) {562 if ( empty( $parsed_args['feed_image'] ) ) { 532 563 $link .= ')'; 533 564 } 534 565 } 535 566 536 if ( $ args['optioncount'] ) {567 if ( $parsed_args['optioncount'] ) { 537 568 $link .= ' (' . $posts . ')'; 538 569 } 539 570 540 571 $return .= $link; 541 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';572 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 542 573 } 543 574 544 575 $return = rtrim( $return, ', ' ); 545 576 546 if ( $ args['echo'] ) {577 if ( $parsed_args['echo'] ) { 547 578 echo $return; 548 579 } else {
Note: See TracChangeset
for help on using the changeset viewer.