Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#38839 closed defect (bug) (fixed)

wp_list_categories can output not well nested HTML

Reported by: chesio's profile chesio Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Hi,

#33460 requested an option to hide title if no categories are present. This has been implemented in [33764] and [33767].

However, [33764] introduced a bug that can result in not well nested output, because only the condition that optionally "opens" list item and starts new list has been altered, not the condition that optionally close both.

On a clean install (from trunk):

wp_list_categories([
        'child_of' => 1, // to have $categories empty
        'hide_title_if_empty' => true, // to hide title
        'show_option_none' => '', // to get only the invalid output
]);

Produces:

</ul></li>

I believe, the fix is quite straight-forward - see the patch attached.

Attachments (1)

patch.diff (519 bytes) - added by chesio 9 years ago.
Proposed patch for #38839

Download all attachments as: .zip

Change History (3)

@chesio
9 years ago

Proposed patch for #38839

#1 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.7

@chesio, thank you for the solid report and the patch!

#2 @SergeyBiryukov
9 years ago

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

In 39280:

Taxonomy: Prevent wp_list_categories() from producing not well-nested output if hide_title_if_empty is true.

Props chesio.
Fixes #38839. See #33460.

Note: See TracTickets for help on using tickets.