| 1 | Index: wp-includes/author-template.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/author-template.php (revision 5143) |
|---|
| 4 | +++ wp-includes/author-template.php (working copy) |
|---|
| 5 | @@ -180,8 +180,18 @@ |
|---|
| 6 | else |
|---|
| 7 | parse_str($args, $r); |
|---|
| 8 | |
|---|
| 9 | - $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, |
|---|
| 10 | - 'feed' => '', 'feed_image' => ''); |
|---|
| 11 | + $defaults = array( |
|---|
| 12 | + 'optioncount' => false, |
|---|
| 13 | + 'exclude_admin' => true, |
|---|
| 14 | + 'show_fullname' => false, |
|---|
| 15 | + 'hide_empty' => true, |
|---|
| 16 | + 'feed' => '', |
|---|
| 17 | + 'feed_image' => '', |
|---|
| 18 | + 'format' => 'html', |
|---|
| 19 | + 'before' => '', |
|---|
| 20 | + 'after' => '' |
|---|
| 21 | + ); |
|---|
| 22 | + |
|---|
| 23 | $r = array_merge($defaults, $r); |
|---|
| 24 | extract($r); |
|---|
| 25 | |
|---|
| 26 | @@ -192,57 +202,78 @@ |
|---|
| 27 | foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) { |
|---|
| 28 | $author_count[$row->post_author] = $row->count; |
|---|
| 29 | } |
|---|
| 30 | - |
|---|
| 31 | - foreach ( (array) $authors as $author ) { |
|---|
| 32 | - $author = get_userdata( $author->ID ); |
|---|
| 33 | + |
|---|
| 34 | + // Set up $output variable |
|---|
| 35 | + $output = ''; |
|---|
| 36 | + |
|---|
| 37 | + foreach ((array) $authors as $author) { |
|---|
| 38 | + // Set up some variables |
|---|
| 39 | + $author = get_userdata($author->ID); |
|---|
| 40 | $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; |
|---|
| 41 | $name = $author->nickname; |
|---|
| 42 | - |
|---|
| 43 | - if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) |
|---|
| 44 | - $name = "$author->first_name $author->last_name"; |
|---|
| 45 | - |
|---|
| 46 | - if ( !($posts == 0 && $hide_empty) ) |
|---|
| 47 | - echo "<li>"; |
|---|
| 48 | - if ( $posts == 0 ) { |
|---|
| 49 | - if ( !$hide_empty ) |
|---|
| 50 | - $link = $name; |
|---|
| 51 | + |
|---|
| 52 | + // Show their full name, and make sure first/last aren't blank |
|---|
| 53 | + if ($show_fullname && (!empty($author->first_name) && !empty($author->last_name))) { |
|---|
| 54 | + $name = $author->first_name . ' ' . $author->last_name; |
|---|
| 55 | + } |
|---|
| 56 | + |
|---|
| 57 | + // Skip "empty" users when we don't want to show them |
|---|
| 58 | + if ($hide_empty && $posts == 0) { |
|---|
| 59 | + continue; |
|---|
| 60 | + } |
|---|
| 61 | + |
|---|
| 62 | + $output .= "\t"; |
|---|
| 63 | + |
|---|
| 64 | + // Start out with different formats, depending on $format |
|---|
| 65 | + switch ($format) { |
|---|
| 66 | + case 'html': |
|---|
| 67 | + $output .= '<li>'; |
|---|
| 68 | + break; |
|---|
| 69 | + } |
|---|
| 70 | + |
|---|
| 71 | + // Put the before stuff on |
|---|
| 72 | + $output .= $before; |
|---|
| 73 | + |
|---|
| 74 | + // By now, we've skipped empty users if !$hide_empty |
|---|
| 75 | + // so just put in their name in place of a link |
|---|
| 76 | + if ($posts == 0) { |
|---|
| 77 | + $output .= $name; |
|---|
| 78 | + // Got posts, add on link |
|---|
| 79 | } else { |
|---|
| 80 | - $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>'; |
|---|
| 81 | - |
|---|
| 82 | - if ( (! empty($feed_image)) || (! empty($feed)) ) { |
|---|
| 83 | - $link .= ' '; |
|---|
| 84 | - if (empty($feed_image)) |
|---|
| 85 | - $link .= '('; |
|---|
| 86 | - $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"'; |
|---|
| 87 | - |
|---|
| 88 | - if ( !empty($feed) ) { |
|---|
| 89 | - $title = ' title="' . $feed . '"'; |
|---|
| 90 | - $alt = ' alt="' . $feed . '"'; |
|---|
| 91 | - $name = $feed; |
|---|
| 92 | - $link .= $title; |
|---|
| 93 | + // Add author's page link |
|---|
| 94 | + $output .= '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" ' |
|---|
| 95 | + . sprintf(__('Posts by %s'), attribute_escape($author->display_name)) . '">' . $name . '</a>'; |
|---|
| 96 | + |
|---|
| 97 | + // Either got a feed text or feed image |
|---|
| 98 | + if (!empty($feed) || !empty($feed_image)) { |
|---|
| 99 | + $output .= ' '; |
|---|
| 100 | + |
|---|
| 101 | + // If we're using text feed link |
|---|
| 102 | + if (empty($feed_image)) { |
|---|
| 103 | + $output .= '(<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '" title="' . attribute_escape($feed) . '">' . $feed . '</a>)'; |
|---|
| 104 | + // Okay, we're using an image link |
|---|
| 105 | + } else { |
|---|
| 106 | + $output .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '" title="' . attribute_escape($feed) . '"><img src="' . $feed_image . '" alt="' . $feed . '" title="' . $feed . '" /></a>'; |
|---|
| 107 | } |
|---|
| 108 | - |
|---|
| 109 | - $link .= '>'; |
|---|
| 110 | - |
|---|
| 111 | - if ( !empty($feed_image) ) |
|---|
| 112 | - $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />'; |
|---|
| 113 | - else |
|---|
| 114 | - $link .= $name; |
|---|
| 115 | - |
|---|
| 116 | - $link .= '</a>'; |
|---|
| 117 | - |
|---|
| 118 | - if ( empty($feed_image) ) |
|---|
| 119 | - $link .= ')'; |
|---|
| 120 | } |
|---|
| 121 | - |
|---|
| 122 | - if ( $optioncount ) |
|---|
| 123 | - $link .= ' ('. $posts . ')'; |
|---|
| 124 | - |
|---|
| 125 | } |
|---|
| 126 | - |
|---|
| 127 | - if ( !($posts == 0 && $hide_empty) ) |
|---|
| 128 | - echo "$link</li>"; |
|---|
| 129 | + |
|---|
| 130 | + // Put the after on the line |
|---|
| 131 | + $output .= $after; |
|---|
| 132 | + |
|---|
| 133 | + // Add the end tag, based on format |
|---|
| 134 | + switch ($format) { |
|---|
| 135 | + case 'html': |
|---|
| 136 | + $output .= '</li>'; |
|---|
| 137 | + break; |
|---|
| 138 | + } |
|---|
| 139 | + |
|---|
| 140 | + // Add a newline |
|---|
| 141 | + $output .= "\n"; |
|---|
| 142 | } |
|---|
| 143 | + |
|---|
| 144 | + // Echo our output |
|---|
| 145 | + echo $output; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | ?> |
|---|
| 149 | \ No newline at end of file |
|---|