WordPress.org

Make WordPress Core

Ticket #4420: 4420.r10258.diff

File 4420.r10258.diff, 3.2 KB (added by jacobsantos, 9 years ago)

Based off of r10258

  • author-template.php

     
    442442/**
    443443 * List all the authors of the blog, with several options available.
    444444 *
    445  * optioncount (boolean) (false): Show the count in parenthesis next to the
    446  *              author's name.
    447  * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by
    448  *              default.
    449  * show_fullname (boolean) (false): Show their full names.
    450  * hide_empty (boolean) (true): Don't show authors without any posts.
    451  * feed (string) (''): If isn't empty, show links to author's feeds.
    452  * feed_image (string) (''): If isn't empty, use this image to link to feeds.
    453  * echo (boolean) (true): Set to false to return the output, instead of echoing.
     445 * <ul>
     446 * <li>optioncount (boolean) (false): Show the count in parenthesis next to the
     447 * author's name.</li>
     448 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
     449 * installed bydefault.</li>
     450 * <li>show_fullname (boolean) (false): Show their full names.</li>
     451 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
     452 * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li>
     453 * <li>feed_image (string) (''): If isn't empty, use this image to link to
     454 * feeds.</li>
     455 * <li>echo (boolean) (true): Set to false to return the output, instead of
     456 * echoing.</li>
     457 * <li>style (string) ('list'): Whether to display list of authors in list form
     458 * or as a string.</li>
     459 * <li>html (bool) (true): Whether to list the items in html for or plaintext.
     460 * </li>
     461 * </ul>
    454462 *
    455463 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
    456464 * @since 1.2.0
     
    463471        $defaults = array(
    464472                'optioncount' => false, 'exclude_admin' => true,
    465473                'show_fullname' => false, 'hide_empty' => true,
    466                 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true
     474                'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
     475                'style' => 'list', 'html' => true
    467476        );
    468477
    469478        $r = wp_parse_args( $args, $defaults );
     
    487496                if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
    488497                        $name = "$author->first_name $author->last_name";
    489498
    490                 if ( !($posts == 0 && $hide_empty) )
     499                if( ! $html ) {
     500                        if ( $posts == 0 ) {
     501                                if ( ! $hide_empty )
     502                                        $return .= $name . ', ';
     503                        } else
     504                                $return .= $name . ', ';
     505
     506                        // No need to go further to process HTML.
     507                        continue;
     508                }
     509
     510                if ( !($posts == 0 && $hide_empty) && 'list' == $style )
    491511                        $return .= '<li>';
    492512                if ( $posts == 0 ) {
    493                         if ( !$hide_empty )
     513                        if ( ! $hide_empty )
    494514                                $link = $name;
    495515                } else {
    496516                        $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
     
    526546
    527547                }
    528548
    529                 if ( !($posts == 0 && $hide_empty) )
     549                if ( !($posts == 0 && $hide_empty) && 'list' == $style )
    530550                        $return .= $link . '</li>';
     551                else
     552                        $return .= $link . ', ';
    531553        }
    532         if ( !$echo )
     554
     555        $return = trim($return, ', ');
     556
     557        if ( ! $echo )
    533558                return $return;
    534559        echo $return;
    535560}