WordPress.org

Make WordPress Core

Opened 17 years ago

Closed 15 years ago

Last modified 3 months ago

#1072 closed enhancement (wontfix)

list_cats() ignores 'optionall=1' option

Reported by: dpbeatley 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)

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

Download all attachments as: .zip

Change History (10)

#1 @dpbeatley
17 years ago

  • Patch set to No

@little_ram
16 years ago

Fixed version

#2 @little_ram
16 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 @little_ram
16 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.

#4 @little_ram
16 years ago

Apologies for the double submission :-)

#5 @markjaquith
16 years ago

  • Milestone set to 2.1

#6 @MichaelH
16 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.

#7 @rgovostes
15 years ago

  • Keywords has-patch added

#8 @matt
15 years ago

  • Resolution set to wontfix
  • Status changed from reopened to closed

#9 @Nazgul
14 years ago

  • Milestone 2.1 deleted
Note: See TracTickets for help on using tickets.