WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#3552 closed defect (bug) (fixed)

wp_list_cats and list_cats are broken in 2.1

Reported by: Dickie Owned by: 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 (1)

depreciated.patch (547 bytes) - added by Dickie 6 years ago.
Patch for depreciated.php on trunk

Download all attachments as: .zip

Change History (4)

Dickie6 years ago

Patch for depreciated.php on trunk

comment:1 Nazgul6 years ago

  • Keywords has-patch added

comment:2 westi6 years ago

  • Keywords commit added
  • Owner changed from anonymous to Dickie

+1 change looks good

comment:3 ryan6 years ago

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

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

Note: See TracTickets for help on using tickets.