Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#20483 closed enhancement (fixed)

Do not output nav menu class attribute if no classes exist

Reported by: niallkennedy Owned by: nacin
Priority: normal Milestone: 3.4
Component: Menus Version:
Severity: trivial Keywords: has-patch
Cc: Focuses:

Description

Walker_Nav_Menu->start_el passes an array of class names and a string through class and id filters respectively. It's possible for a theme or plugin to empty out a class or id, overriding defaults.

The element string builder checks for an empty id attribute string value before outputting the id attribute. If a plugin empties the classes array then $classes_name will be similarly empty.

Patch applies the same conditional attribute output logic present in the id attribute to the class attribute as well.

Attachments (1)

nav-menu-template.diff (695 bytes ) - added by niallkennedy 14 years ago.
check if classes_name is an empty string before building an empty attribute for a nav menu walker element

Download all attachments as: .zip

Change History (3)

@niallkennedy
14 years ago

check if classes_name is an empty string before building an empty attribute for a nav menu walker element

#1 @nacin
14 years ago

  • Milestone Awaiting Review3.4

Looks good. A note, strlen() is not necessary in either place.

#2 @nacin
14 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

In [20513]:

Only output the class attribute in wp_nav_menu() if we have classes to add. Don't waste time on an strlen() call. props niallkennedy, fixes #20483.

Note: See TracTickets for help on using tickets.