Changeset 54262
- Timestamp:
- 09/20/2022 04:24:56 PM (2 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 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 { -
trunk/src/wp-includes/user.php
r54182 r54262 812 812 ); 813 813 814 $ args = wp_parse_args( $args, $defaults );814 $parsed_args = wp_parse_args( $args, $defaults ); 815 815 816 816 $return = ''; 817 817 818 $query_args = wp_array_slice_assoc( $ args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );818 $query_args = wp_array_slice_assoc( $parsed_args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); 819 819 $query_args['fields'] = 'ids'; 820 $users = get_users( $query_args ); 820 821 /** 822 * Filters the query arguments for the list of all users of the site. 823 * 824 * @since 6.1.0 825 * 826 * @param array $query_args The query arguments for get_users(). 827 * @param array $parsed_args The arguments passed to wp_list_users() combined with the defaults. 828 */ 829 $query_args = apply_filters( 'wp_list_users_args', $query_args, $parsed_args ); 830 831 $users = get_users( $query_args ); 821 832 822 833 foreach ( $users as $user_id ) { 823 834 $user = get_userdata( $user_id ); 824 835 825 if ( $ args['exclude_admin'] && 'admin' === $user->display_name ) {836 if ( $parsed_args['exclude_admin'] && 'admin' === $user->display_name ) { 826 837 continue; 827 838 } 828 839 829 if ( $ args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) {840 if ( $parsed_args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) { 830 841 $name = sprintf( 831 842 /* translators: 1: User's first name, 2: Last name. */ … … 838 849 } 839 850 840 if ( ! $ args['html'] ) {851 if ( ! $parsed_args['html'] ) { 841 852 $return .= $name . ', '; 842 853 … … 844 855 } 845 856 846 if ( 'list' === $ args['style'] ) {857 if ( 'list' === $parsed_args['style'] ) { 847 858 $return .= '<li>'; 848 859 } … … 850 861 $row = $name; 851 862 852 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {863 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 853 864 $row .= ' '; 854 if ( empty( $ args['feed_image'] ) ) {865 if ( empty( $parsed_args['feed_image'] ) ) { 855 866 $row .= '('; 856 867 } 857 868 858 $row .= '<a href="' . get_author_feed_link( $user->ID, $ args['feed_type'] ) . '"';869 $row .= '<a href="' . get_author_feed_link( $user->ID, $parsed_args['feed_type'] ) . '"'; 859 870 860 871 $alt = ''; 861 if ( ! empty( $ args['feed'] ) ) {862 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';863 $name = $ args['feed'];872 if ( ! empty( $parsed_args['feed'] ) ) { 873 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 874 $name = $parsed_args['feed']; 864 875 } 865 876 866 877 $row .= '>'; 867 878 868 if ( ! empty( $ args['feed_image'] ) ) {869 $row .= '<img src="' . esc_url( $ args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';879 if ( ! empty( $parsed_args['feed_image'] ) ) { 880 $row .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; 870 881 } else { 871 882 $row .= $name; … … 874 885 $row .= '</a>'; 875 886 876 if ( empty( $ args['feed_image'] ) ) {887 if ( empty( $parsed_args['feed_image'] ) ) { 877 888 $row .= ')'; 878 889 } … … 880 891 881 892 $return .= $row; 882 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';893 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 883 894 } 884 895 885 896 $return = rtrim( $return, ', ' ); 886 897 887 if ( ! $ args['echo'] ) {898 if ( ! $parsed_args['echo'] ) { 888 899 return $return; 889 900 }
Note: See TracChangeset
for help on using the changeset viewer.