Ticket #17025: 17025.12.diff
File 17025.12.diff, 9.2 KB (added by , 2 years ago) |
---|
-
src/wp-includes/author-template.php
450 450 'include' => '', 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 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 461 472 $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 ) { 473 $rows = $wpdb->get_results( 474 "SELECT DISTINCT post_author, COUNT(ID) AS count 475 FROM $wpdb->posts 476 WHERE " . get_private_posts_cap_sql( 'post' ) . ' 477 GROUP BY post_author' 478 ); 479 480 foreach ( (array) $rows as $row ) { 463 481 $author_count[ $row->post_author ] = $row->count; 464 482 } 483 465 484 foreach ( $authors as $author_id ) { 466 485 $posts = isset( $author_count[ $author_id ] ) ? $author_count[ $author_id ] : 0; 467 486 468 if ( ! $posts && $ args['hide_empty'] ) {487 if ( ! $posts && $parsed_args['hide_empty'] ) { 469 488 continue; 470 489 } 471 490 472 491 $author = get_userdata( $author_id ); 473 492 474 if ( $ args['exclude_admin'] && 'admin' === $author->display_name ) {493 if ( $parsed_args['exclude_admin'] && 'admin' === $author->display_name ) { 475 494 continue; 476 495 } 477 496 478 if ( $args['show_fullname'] && $author->first_name && $author->last_name ) { 479 480 $full_name = $author->first_name . ' ' . $author->last_name; 481 482 /** 483 * Filters the author's full name. 484 * 485 * @since 6.1.0 486 * 487 * @param string $full_name Full Name of the author. Default: The author's first name 488 * and last name, separated by a space. 489 * @param object $author Author object. 490 */ 491 $name = apply_filters( 'wp_list_author_full_name', $full_name, $author ); 492 497 if ( $parsed_args['show_fullname'] && $author->first_name && $author->last_name ) { 498 $name = sprintf( 499 /* translators: 1: User's first name, 2: Last name. */ 500 _x( '%1$s %2$s', 'Display name based on first name and last name' ), 501 $author->first_name, 502 $author->last_name 503 ); 493 504 } else { 494 505 $name = $author->display_name; 495 506 } 496 507 497 if ( ! $ args['html'] ) {508 if ( ! $parsed_args['html'] ) { 498 509 $return .= $name . ', '; 499 510 500 511 continue; // No need to go further to process HTML. 501 512 } 502 513 503 if ( 'list' === $ args['style'] ) {514 if ( 'list' === $parsed_args['style'] ) { 504 515 $return .= '<li>'; 505 516 } 506 517 … … 512 523 $name 513 524 ); 514 525 515 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {526 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 516 527 $link .= ' '; 517 if ( empty( $ args['feed_image'] ) ) {528 if ( empty( $parsed_args['feed_image'] ) ) { 518 529 $link .= '('; 519 530 } 520 531 521 $link .= '<a href="' . get_author_feed_link( $author->ID, $ args['feed_type'] ) . '"';532 $link .= '<a href="' . get_author_feed_link( $author->ID, $parsed_args['feed_type'] ) . '"'; 522 533 523 534 $alt = ''; 524 if ( ! empty( $ args['feed'] ) ) {525 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';526 $name = $ args['feed'];535 if ( ! empty( $parsed_args['feed'] ) ) { 536 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 537 $name = $parsed_args['feed']; 527 538 } 528 539 529 540 $link .= '>'; 530 541 531 if ( ! empty( $ args['feed_image'] ) ) {532 $link .= '<img src="' . esc_url( $ args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';542 if ( ! empty( $parsed_args['feed_image'] ) ) { 543 $link .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; 533 544 } else { 534 545 $link .= $name; 535 546 } … … 536 547 537 548 $link .= '</a>'; 538 549 539 if ( empty( $ args['feed_image'] ) ) {550 if ( empty( $parsed_args['feed_image'] ) ) { 540 551 $link .= ')'; 541 552 } 542 553 } 543 554 544 if ( $ args['optioncount'] ) {555 if ( $parsed_args['optioncount'] ) { 545 556 $link .= ' (' . $posts . ')'; 546 557 } 547 558 548 559 $return .= $link; 549 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';560 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 550 561 } 551 562 552 563 $return = rtrim( $return, ', ' ); 553 564 554 if ( $ args['echo'] ) {565 if ( $parsed_args['echo'] ) { 555 566 echo $return; 556 567 } else { 557 568 return $return; -
src/wp-includes/user.php
811 811 'include' => '', 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 );821 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 ); 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 ) { 830 $name = "$user->first_name $user->last_name"; 840 if ( $parsed_args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) { 841 $name = sprintf( 842 /* translators: 1: User's first name, 2: Last name. */ 843 _x( '%1$s %2$s', 'Display name based on first name and last name' ), 844 $user->first_name, 845 $user->last_name 846 ); 831 847 } else { 832 848 $name = $user->display_name; 833 849 } 834 850 835 if ( ! $ args['html'] ) {851 if ( ! $parsed_args['html'] ) { 836 852 $return .= $name . ', '; 837 853 838 854 continue; // No need to go further to process HTML. 839 855 } 840 856 841 if ( 'list' === $ args['style'] ) {857 if ( 'list' === $parsed_args['style'] ) { 842 858 $return .= '<li>'; 843 859 } 844 860 845 861 $row = $name; 846 862 847 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {863 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 848 864 $row .= ' '; 849 if ( empty( $ args['feed_image'] ) ) {865 if ( empty( $parsed_args['feed_image'] ) ) { 850 866 $row .= '('; 851 867 } 852 868 853 $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'] ) . '"'; 854 870 855 871 $alt = ''; 856 if ( ! empty( $ args['feed'] ) ) {857 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';858 $name = $ args['feed'];872 if ( ! empty( $parsed_args['feed'] ) ) { 873 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 874 $name = $parsed_args['feed']; 859 875 } 860 876 861 877 $row .= '>'; 862 878 863 if ( ! empty( $ args['feed_image'] ) ) {864 $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 . ' />'; 865 881 } else { 866 882 $row .= $name; 867 883 } … … 868 884 869 885 $row .= '</a>'; 870 886 871 if ( empty( $ args['feed_image'] ) ) {887 if ( empty( $parsed_args['feed_image'] ) ) { 872 888 $row .= ')'; 873 889 } 874 890 } 875 891 876 892 $return .= $row; 877 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';893 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 878 894 } 879 895 880 896 $return = rtrim( $return, ', ' ); 881 897 882 if ( ! $ args['echo'] ) {898 if ( ! $parsed_args['echo'] ) { 883 899 return $return; 884 900 } 885 901 echo $return; … … 2242 2258 if ( $update ) { 2243 2259 $display_name = $user_login; 2244 2260 } elseif ( $meta['first_name'] && $meta['last_name'] ) { 2245 /* translators: 1: User's first name, 2: Last name. */ 2246 $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] ); 2261 $display_name = sprintf( 2262 /* translators: 1: User's first name, 2: Last name. */ 2263 _x( '%1$s %2$s', 'Display name based on first name and last name' ), 2264 $meta['first_name'], 2265 $meta['last_name'] 2266 ); 2247 2267 } elseif ( $meta['first_name'] ) { 2248 2268 $display_name = $meta['first_name']; 2249 2269 } elseif ( $meta['last_name'] ) {