Ticket #4182 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

Add ability to return list for wp_list_categories..

Reported by: profdeadmeat Assigned to: rob1n
Priority: normal Milestone: 2.3
Component: Template Version: 2.1.3
Severity: normal Keywords: has-patch
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

wp_list_categories_echo.diff (1.0 kB) - added by Otto42 on 04/24/07 08:52:27.
Patch to add echo parameter support to wp_list_categories

Change History

04/23/07 20:49:13 changed by Otto42

  • severity changed from major to normal.
  • component changed from Administration to Template.
  • summary changed from bug with wp_list_catories to Add ability to return list for wp_list_categories...
  • priority changed from high to normal.
  • version changed from 2.1.2 to 2.1.3.
  • milestone changed from 2.1.4 to 2.2.
  • type changed from defect to enhancement.

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.

04/24/07 03:21:42 changed by rob1n

  • milestone changed from 2.2 to 2.3.

04/24/07 03:21:50 changed by rob1n

2.2 is in feature freeze, I believe.

04/24/07 03:21:54 changed by rob1n

  • owner changed from anonymous to rob1n.

04/24/07 08:52:27 changed by Otto42

  • attachment wp_list_categories_echo.diff added.

Patch to add echo parameter support to wp_list_categories

04/24/07 08:52:55 changed by Otto42

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

04/27/07 03:00:26 changed by rob1n

See also #3567.

09/05/07 20:03:08 changed by foolswisdom

  • keywords set to has-patch.

09/12/07 02:53:27 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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