Make WordPress Core

Opened 16 years ago

Closed 12 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
Priority: normal Milestone: 4.2
Component: Taxonomy Version: 3.1
Severity: trivial Keywords: has-patch
Cc: Focuses:

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 16 years ago.
patch for described minor bug

Download all attachments as: .zip

Change History (7)

#1 @samo9789
16 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
16 years ago

patch for described minor bug

#2 @iseulde
13 years ago

  • Component GeneralTaxonomy
  • Version 3.1trunk

#3 @iseulde
13 years ago

  • Version trunk3.1

#4 @wonderboymusic
13 years ago

  • Keywords needs-refresh added

#5 @boonebgorges
12 years ago

  • Keywords needs-refresh removed
  • Milestone Awaiting Review4.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
12 years ago

  • Owner set to boonebgorges
  • Resolutionfixed
  • Status newclosed

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.