Ticket #3552 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

wp_list_cats and list_cats are broken in 2.1

Reported by: Dickie Assigned to: Dickie
Priority: normal Milestone: 2.1
Component: Template Version: 2.1
Severity: major Keywords: list_cats wp_list_cats template has-patch commit
Cc:

Description

While testing out my theme with WP 2.1 I noticed that the newly depreciated function list_cats does now not work as it used to. It was defaulting to 'break' behaviour rather than 'list'

This is also true of wp_list_cats although in a different way.

if calling

wp_list_cats("title_li=");

then the display will be an UL list as expected (due to default behaviour), whereas

wp_list_cats("list=1&title_li=");

will show them with BRs ('break' behaviour), but

wp_list_cats("list=0&title_li=");

will show an UL (this is the wrong way round)

as far as the list_cats function is concerned, that template function will display a 'break' list regardless of the settings supplied, either defaulted or not...

I have traced this down to the wp_list_cats function in depreciated.php line 432

if ( !empty($r[ 'list' ]) )

$r[ 'style' ] = 'break';

this needs to be

if ( isset($r[ 'list' ]) )

$r[ 'style' ] = $r[ 'list' ] ? 'list' : 'break';

This is because the function list_cats() will call this, and $r[ 'list' ] will never be empty because it is either defaulted or set by the caller, and therefore it will be set to break. Plus the test needs to be changed because if the parameter is set to 0 then it is empty, but still set.

I have tested this fix, and it all seems to work fine in all scenarios. (patch file attached, rev 4709)

Attachments

depreciated.patch (0.5 kB) - added by Dickie on 01/09/07 20:00:31.
Patch for depreciated.php on trunk

Change History

01/09/07 20:00:31 changed by Dickie

  • attachment depreciated.patch added.

Patch for depreciated.php on trunk

01/09/07 21:33:19 changed by Nazgul

  • keywords changed from list_cats wp_list_cats template to list_cats wp_list_cats template has-patch.

01/10/07 08:22:34 changed by westi

  • keywords changed from list_cats wp_list_cats template has-patch to list_cats wp_list_cats template has-patch commit.
  • owner changed from anonymous to Dickie.

+1 change looks good

01/10/07 09:19:03 changed by ryan

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

(In [4713]) Fix list cats style arg. Props Dickie. fixes #3552