WordPress.org

Make WordPress Core

Ticket #9902: 9902.diff

File 9902.diff, 1.8 KB (added by ericmann, 6 years ago)

Adds "exclude" parameter to wp_list_authors() function. Accepts comma separated list of author IDs for exclusion.

  • wp-includes/author-template.php

     
    234234 * author's name.</li> 
    235235 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is 
    236236 * installed bydefault.</li> 
     237 * <li>exclude (string) (false): Exlude a list of authors based on user_ID.</li> 
    237238 * <li>show_fullname (boolean) (false): Show their full names.</li> 
    238239 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li> 
    239240 * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li> 
     
    259260                'optioncount' => false, 'exclude_admin' => true, 
    260261                'show_fullname' => false, 'hide_empty' => true, 
    261262                'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 
    262                 'style' => 'list', 'html' => true 
     263                'style' => 'list', 'html' => true, 'exclude' => false 
    263264        ); 
    264265 
    265266        $r = wp_parse_args( $args, $defaults ); 
     
    267268        $return = ''; 
    268269 
    269270        /** @todo Move select to get_authors(). */ 
    270         $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); 
     271        $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin && $exclude ? "WHERE user_login <> 'admin' AND ID NOT IN (" . $exclude . ") " : '') . ($exclude_admin && !$exclude ? "WHERE user_login <> 'admin' " : '') . (!$exclude_admin && $exclude ? "WHERE ID NOT IN (" . $exclude . ") " : '') . "ORDER BY display_name"); 
    271272 
    272273        $author_count = array(); 
    273274        foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) {