Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#4182 closed enhancement (fixed)

Add ability to return list for wp_list_categories..

Reported by: profdeadmeat's profile profdeadmeat Owned by: rob1n's profile rob1n
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.1.3
Component: Template Keywords: has-patch
Focuses: Cc:

Description

Simply:

The function outputs directly to the page it does not allow any function to use the output.

Impact:

Plugins and templates which used the deprecated list_cats can not use the replacement.

Fix:

Change:

echo apply_filters('list_cats', $output);

To:

$output = apply_filters('list_cats', $output);

if ( $echo ) echo $output;

return $output;

Attachments (1)

wp_list_categories_echo.diff (1020 bytes) - added by Otto42 17 years ago.
Patch to add echo parameter support to wp_list_categories

Download all attachments as: .zip

Change History (9)

#1 @Otto42
17 years ago

  • Component changed from Administration to Template
  • Milestone changed from 2.1.4 to 2.2
  • Priority changed from high to normal
  • Severity changed from major to normal
  • Summary changed from bug with wp_list_catories to Add ability to return list for wp_list_categories..
  • Type changed from defect to enhancement
  • Version changed from 2.1.2 to 2.1.3

This would make it similar to the functionality in wp_list_pages (and probably elsewhere too). Changes required are minimal.

At the end of wp_list_categories(), change the echo statement to this:

$output = apply_filters('list_cats', $output);
if ( $r['echo'] ) echo $output;
else return $output;

Add this to the $defaults array:

'echo' => 1

And there you go. This will allow an "echo" parameter similar to wp_list_pages() echo parameter.

#2 @rob1n
17 years ago

  • Milestone changed from 2.2 to 2.3

#3 @rob1n
17 years ago

2.2 is in feature freeze, I believe.

#4 @rob1n
17 years ago

  • Owner changed from anonymous to rob1n

@Otto42
17 years ago

Patch to add echo parameter support to wp_list_categories

#5 @Otto42
17 years ago

Regardless of what version it eventually goes in, here's a quick patch for it.

#6 @rob1n
17 years ago

See also #3567.

#7 @foolswisdom
17 years ago

  • Keywords has-patch added

#8 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6091]) Add echo or return option to wp_list_categories. Props Otto42. fixes #4182

Note: See TracTickets for help on using tickets.