Ticket #17025: 17025.12.wp_list_authors_args.diff
File 17025.12.wp_list_authors_args.diff, 7.8 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 ) {497 if ( $parsed_args['show_fullname'] && $author->first_name && $author->last_name ) { 479 498 480 499 $full_name = $author->first_name . ' ' . $author->last_name; 481 500 … … 494 513 $name = $author->display_name; 495 514 } 496 515 497 if ( ! $ args['html'] ) {516 if ( ! $parsed_args['html'] ) { 498 517 $return .= $name . ', '; 499 518 500 519 continue; // No need to go further to process HTML. 501 520 } 502 521 503 if ( 'list' === $ args['style'] ) {522 if ( 'list' === $parsed_args['style'] ) { 504 523 $return .= '<li>'; 505 524 } 506 525 … … 512 531 $name 513 532 ); 514 533 515 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {534 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 516 535 $link .= ' '; 517 if ( empty( $ args['feed_image'] ) ) {536 if ( empty( $parsed_args['feed_image'] ) ) { 518 537 $link .= '('; 519 538 } 520 539 521 $link .= '<a href="' . get_author_feed_link( $author->ID, $ args['feed_type'] ) . '"';540 $link .= '<a href="' . get_author_feed_link( $author->ID, $parsed_args['feed_type'] ) . '"'; 522 541 523 542 $alt = ''; 524 if ( ! empty( $ args['feed'] ) ) {525 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';526 $name = $ args['feed'];543 if ( ! empty( $parsed_args['feed'] ) ) { 544 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 545 $name = $parsed_args['feed']; 527 546 } 528 547 529 548 $link .= '>'; 530 549 531 if ( ! empty( $ args['feed_image'] ) ) {532 $link .= '<img src="' . esc_url( $ args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';550 if ( ! empty( $parsed_args['feed_image'] ) ) { 551 $link .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; 533 552 } else { 534 553 $link .= $name; 535 554 } … … 536 555 537 556 $link .= '</a>'; 538 557 539 if ( empty( $ args['feed_image'] ) ) {558 if ( empty( $parsed_args['feed_image'] ) ) { 540 559 $link .= ')'; 541 560 } 542 561 } 543 562 544 if ( $ args['optioncount'] ) {563 if ( $parsed_args['optioncount'] ) { 545 564 $link .= ' (' . $posts . ')'; 546 565 } 547 566 548 567 $return .= $link; 549 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';568 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 550 569 } 551 570 552 571 $return = rtrim( $return, ', ' ); 553 572 554 if ( $ args['echo'] ) {573 if ( $parsed_args['echo'] ) { 555 574 echo $return; 556 575 } else { 557 576 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 ) {840 if ( $parsed_args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) { 830 841 $name = "$user->first_name $user->last_name"; 831 842 } else { 832 843 $name = $user->display_name; 833 844 } 834 845 835 if ( ! $ args['html'] ) {846 if ( ! $parsed_args['html'] ) { 836 847 $return .= $name . ', '; 837 848 838 849 continue; // No need to go further to process HTML. 839 850 } 840 851 841 if ( 'list' === $ args['style'] ) {852 if ( 'list' === $parsed_args['style'] ) { 842 853 $return .= '<li>'; 843 854 } 844 855 845 856 $row = $name; 846 857 847 if ( ! empty( $ args['feed_image'] ) || ! empty( $args['feed'] ) ) {858 if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { 848 859 $row .= ' '; 849 if ( empty( $ args['feed_image'] ) ) {860 if ( empty( $parsed_args['feed_image'] ) ) { 850 861 $row .= '('; 851 862 } 852 863 853 $row .= '<a href="' . get_author_feed_link( $user->ID, $ args['feed_type'] ) . '"';864 $row .= '<a href="' . get_author_feed_link( $user->ID, $parsed_args['feed_type'] ) . '"'; 854 865 855 866 $alt = ''; 856 if ( ! empty( $ args['feed'] ) ) {857 $alt = ' alt="' . esc_attr( $ args['feed'] ) . '"';858 $name = $ args['feed'];867 if ( ! empty( $parsed_args['feed'] ) ) { 868 $alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; 869 $name = $parsed_args['feed']; 859 870 } 860 871 861 872 $row .= '>'; 862 873 863 if ( ! empty( $ args['feed_image'] ) ) {864 $row .= '<img src="' . esc_url( $ args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';874 if ( ! empty( $parsed_args['feed_image'] ) ) { 875 $row .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; 865 876 } else { 866 877 $row .= $name; 867 878 } … … 868 879 869 880 $row .= '</a>'; 870 881 871 if ( empty( $ args['feed_image'] ) ) {882 if ( empty( $parsed_args['feed_image'] ) ) { 872 883 $row .= ')'; 873 884 } 874 885 } 875 886 876 887 $return .= $row; 877 $return .= ( 'list' === $ args['style'] ) ? '</li>' : ', ';888 $return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; 878 889 } 879 890 880 891 $return = rtrim( $return, ', ' ); 881 892 882 if ( ! $ args['echo'] ) {893 if ( ! $parsed_args['echo'] ) { 883 894 return $return; 884 895 } 885 896 echo $return;