Ticket #1072 (closed enhancement: wontfix)

Opened 7 years ago

Last modified 5 years ago

list_cats() ignores 'optionall=1' option

Reported by: dpbeatley Owned by: anonymous
Priority: normal Milestone:
Component: General Version: 1.5.2
Severity: normal Keywords: has-patch
Cc: dpbeatley

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

template-functions-category.php Download (16.2 KB) - added by little_ram 6 years ago.
Fixed version

Change History

  • Patch set to No

Fixed version

  • Status changed from new to closed
  • Version changed from 1.5.1 to 1.5.2
  • Resolution set to fixed

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.

  • Status changed from closed to reopened
  • Resolution fixed deleted

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.

Apologies for the double submission :-)

  • Milestone set to 2.1

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.

  • Keywords has-patch added

comment:8   matt5 years ago

  • Status changed from reopened to closed
  • Resolution set to wontfix
  • Milestone 2.1 deleted
Note: See TracTickets for help on using tickets.