Make WordPress Core

Changeset 10570


Ignore:
Timestamp:
02/15/2009 09:06:24 AM (16 years ago)
Author:
westi
Message:

Enhance wp_list_authors() to support more of the standard output options. Props jacobsantos see #4420.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/author-template.php

    r9590 r10570  
    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
     
    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 );
    470479    extract($r, EXTR_SKIP);
    471 
    472480    $return = '';
    473481
     
    488496            $name = "$author->first_name $author->last_name";
    489497
    490         if ( !($posts == 0 && $hide_empty) )
     498        if( !$html ) {
     499            if ( $posts == 0 ) {
     500                if ( ! $hide_empty )
     501                    $return .= $name . ', ';
     502            } else
     503                $return .= $name . ', ';
     504
     505            // No need to go further to process HTML.
     506            continue;
     507        }
     508
     509        if ( !($posts == 0 && $hide_empty) && 'list' == $style )
    491510            $return .= '<li>';
    492511        if ( $posts == 0 ) {
    493             if ( !$hide_empty )
     512            if ( ! $hide_empty )
    494513                $link = $name;
    495514        } else {
     
    527546        }
    528547
    529         if ( !($posts == 0 && $hide_empty) )
     548        if ( !($posts == 0 && $hide_empty) && 'list' == $style )
    530549            $return .= $link . '</li>';
     550        else
     551            $return .= $link . ', ';
    531552    }
    532     if ( !$echo )
     553
     554    $return = trim($return, ', ');
     555
     556    if ( ! $echo )
    533557        return $return;
    534558    echo $return;
Note: See TracChangeset for help on using the changeset viewer.