#1072 closed enhancement (wontfix)
list_cats() ignores 'optionall=1' option
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 1.5.2 |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description
Code was removed in DEC 2004 from the "templates-functions-category" that supported the 'optionall=1' argument. list-cats() no longer returns a link to retrieve all categories from the database. The removal of this option is a serious oversight and should be replaced.
Attachments (1)
Change History (10)
#2
@
20 years ago
- Resolution set to fixed
- Status changed from new to closed
- Version changed from 1.5.1 to 1.5.2
Here's some code which fixes this.
It adds 2 more SQL calls (which are only called if optionall=1) and also allows for optiondate, feed, feedimage with the 'All categories' link.
Scroll to this line in the file:
$num_found=0; $thelist = "";
Add this code straight afterwards:
if ( $optionall )
{
$link .= '<a href="' . $PHP_SELF . '" title="View all posts">' .
$all . '</a>';
// rss link
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
if (empty($feed_image)) {
$link .= '(';
}
$link .= '<a href="' . bloginfo('rss2_url') . '"';
if ( !empty($feed) ) {
$title = ' title="' . $feed . '"';
$alt = ' alt="' . $feed . '"';
$name = $feed;
$link .= $title;
}
$link .= '>';
if (! empty($feed_image)) {
$link .= "<img src='$feed_image' $alt$title" . ' />';
} else {
$link .= $name;
}
$link .= '</a>';
if (empty($feed_image)) {
$link .= ')';
}
}
// post count
if (intval($optioncount) == 1) {
$total_posts = $wpdb->get_results(" SELECT COUNT(ID) AS pc
FROM $wpdb->posts WHERE post_status = 'publish'
AND post_date_gmt < '$now' $exclusions");
$link .= ' ('. $total_posts[0]->pc .')';
}
// latest post date
if ( $optiondates ) {
$max_date = $wpdb->get_results(" SELECT UNIX_TIMESTAMP( MAX(post_date) ) AS ts
FROM $wpdb->posts
WHERE post_status = 'publish'
AND post_date_gmt < '$now' $exclusions");
if ( $optiondates == 1 ) $optiondates = 'Y-m-d';
$link .= ' ' . gmdate($optiondates, $max_date[0]->ts);
}
if ($list) {
$thelist .= "\t<li>$link\n";
} else {
$thelist .= "\t$link<br />\n";
}
}
I've attached the whole file as well (template-functions-category.php), just in case.
#3
@
20 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Here's some code which fixes this.
It adds 2 more SQL calls (which are only called if optionall=1) and also allows for optiondate, feed, feedimage with the 'All categories' link.
Scroll to this line in the file:
$num_found=0; $thelist = "";
Add this code straight afterwards:
if ( $optionall )
{
$link .= '<a href="' . $PHP_SELF . '" title="View all posts">' .
$all . '</a>';
// rss link
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
if (empty($feed_image)) {
$link .= '(';
}
$link .= '<a href="' . bloginfo('rss2_url') . '"';
if ( !empty($feed) ) {
$title = ' title="' . $feed . '"';
$alt = ' alt="' . $feed . '"';
$name = $feed;
$link .= $title;
}
$link .= '>';
if (! empty($feed_image)) {
$link .= "<img src='$feed_image' $alt$title" . ' />';
} else {
$link .= $name;
}
$link .= '</a>';
if (empty($feed_image)) {
$link .= ')';
}
}
// post count
if (intval($optioncount) == 1) {
$total_posts = $wpdb->get_results(" SELECT COUNT(ID) AS pc
FROM $wpdb->posts WHERE post_status = 'publish'
AND post_date_gmt < '$now' $exclusions");
$link .= ' ('. $total_posts[0]->pc .')';
}
// latest post date
if ( $optiondates ) {
$max_date = $wpdb->get_results(" SELECT UNIX_TIMESTAMP( MAX(post_date) ) AS ts
FROM $wpdb->posts
WHERE post_status = 'publish'
AND post_date_gmt < '$now' $exclusions");
if ( $optiondates == 1 ) $optiondates = 'Y-m-d';
$link .= ' ' . gmdate($optiondates, $max_date[0]->ts);
}
if ($list) {
$thelist .= "\t<li>$link\n";
} else {
$thelist .= "\t$link<br />\n";
}
}
I've attached the whole file as well (template-functions-category.php), just in case.
#6
@
20 years ago
Hate to open another ticket for this so will comment here--does there need to be two parameters for this functionality? Why is the optionall parameter needed? Can't you just test for the existence of anything in $all, and if there is something there, create the link to all the Categories.
Fixed version