Add feed and feed_image options to wp_list_cats() and wp_list_authors().

git-svn-id: http://svn.automattic.com/wordpress/trunk@987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-03-23 04:45:27 +00:00
parent 2458274082
commit 346990432c
2 changed files with 81 additions and 8 deletions

View File

@ -106,11 +106,13 @@ function wp_list_authors($args = '') {
if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true;
if (!isset($r['show_fullname'])) $r['show_fullname'] = false;
if (!isset($r['hide_empty'])) $r['hide_empty'] = true;
if (!isset($r['feed'])) $r['feed'] = '';
if (!isset($r['feed_image'])) $r['feed_image'] = '';
list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r[hide_empty]);
list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r[hide_empty], $r['feed'], $r['feed_image']);
}
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true) {
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
global $tableusers, $wpdb, $blogfilename;
$query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $tableusers " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
@ -128,9 +130,46 @@ function list_authors($optioncount = false, $exclude_admin = true, $show_fullnam
if ($posts == 0) {
if (! $hide_empty) echo $name;
} else {
echo '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="Posts by ' . $author->user_nickname . '">' . $name . ($optioncount ? " ($posts)" : '')."</a>";
$link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="Posts by ' . htmlspecialchars($author->user_nickname) . '">' . stripslashes($name) . '</a>';
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
if (empty($feed_image)) {
$link .= '(';
}
if (! ($posts == 0 && $hide_empty)) echo "</li>";
$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
if (! empty($feed)) {
$title = ' title="' . stripslashes($feed) . '"';
$alt = ' alt="' . stripslashes($feed) . '"';
$name = stripslashes($feed);
$link .= $title;
}
$link .= '>';
if (! empty($feed_image)) {
$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
} else {
$link .= $name;
}
$link .= '</a>';
if (empty($feed_image)) {
$link .= ')';
}
}
if ($optioncount) {
$link .= ' ('. $posts . ')';
}
}
if (! ($posts == 0 && $hide_empty)) echo "$link</li>";
}
}

View File

@ -247,12 +247,13 @@ function wp_list_cats($args = '') {
if (!isset($r['child_of'])) $r['child_of'] = 0;
if (!isset($r['categories'])) $r['categories'] = 0;
if (!isset($r['recurse'])) $r['recurse'] = 0;
list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'],
$r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'],
$r['children'], $r['child_of'], $r['categories'], $r['recurse']);
if (!isset($r['feed'])) $r['feed'] = '';
if (!isset($r['feed_image'])) $r['feed_image'] = '';
list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image']);
}
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0) {
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '') {
global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
@ -318,6 +319,39 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
}
$link .= '>';
$link .= stripslashes($category->cat_name).'</a>';
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
if (empty($feed_image)) {
$link .= '(';
}
$link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
if (! empty($feed)) {
$title = ' title="' . stripslashes($feed) . '"';
$alt = ' alt="' . stripslashes($feed) . '"';
$name = stripslashes($feed);
$link .= $title;
}
$link .= '>';
if (! empty($feed_image)) {
$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
} else {
$link .= $name;
}
$link .= '</a>';
if (empty($feed_image)) {
$link .= ')';
}
}
if (intval($optioncount) == 1) {
$link .= ' ('.intval($category_posts["$category->cat_ID"]).')';
}