WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 7 years ago

#16792 closed enhancement (fixed)

CategoryWalker, if cat_name is empty, do not append the empty a tag to the output

Reported by: samo9789 Owned by: boonebgorges
Milestone: 4.2 Priority: normal
Severity: trivial Version: 3.1
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

If the theme is customized to skip some categories by doing something like add_filter('list_cats', 'hideSomeCatgory') and returning a null or an empty string as cat name, the CategoryWalker will append an empty html element to the output

Attachments (1)

patchCategoryWalkerSkippedCategory.patch (4.1 KB) - added by samo9789 11 years ago.
patch for described minor bug

Download all attachments as: .zip

Change History (7)

#1 @samo9789
11 years ago

Hi,

This is my first contribution to an existing open source project. I hope I respected the ticket creation and patch submission process and that this can help improve Wordpress. I hope someone will review this correction.

Take care,
samo9789

@samo9789
11 years ago

patch for described minor bug

#2 @iseulde
8 years ago

  • Component changed from General to Taxonomy
  • Version changed from 3.1 to trunk

#3 @iseulde
8 years ago

  • Version changed from trunk to 3.1

#4 @wonderboymusic
8 years ago

  • Keywords needs-refresh added

#5 @boonebgorges
7 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Awaiting Review to 4.2

samo9789 - Thanks for the patch, and sorry for the delay in response.

In general, I would not recommend the use of the 'list_cats' filter for this purpose - if you want to prevent terms from being displayed in, say, wp_list_categories(), you're much better off passing an 'exclude' parameter to that function, or filtering 'get_terms'. That being said, I think you're right that there's no good reason to generate an empty element.

#6 @boonebgorges
7 years ago

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

In 31025:

In Walker_Category, don't generate list elements for empty cat names.

This change allows the 'list_cats' filter to be used to suppress certain
items in category lists, without creating invalid or superfluous markup.

Props samo9789.
Fixes #16792.

Note: See TracTickets for help on using tickets.