Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#20674 closed enhancement (duplicate)

if menu classes are empty the empty attribute will be added to the <li> (solution inside)

Reported by: janwoostendorp's profile janw.oostendorp Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.3.2
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

I often remove the classes form the <li> in menu's with the filter 'nav_menu_css_class'.
That results in empty 'class="" ' attributes in my menu's.
Fixing this is easy to do in the core:

/wp-includes/nav-menu-template.php
line 77

$class_names = ' class="' . esc_attr( $class_names ) . '"';

should be replaced with:

if (!empty($class_names )) {
    $class_names = ' class="' . esc_attr( $class_names ) . '"';
}

Change History (3)

#1 @scribu
12 years ago

  • Severity changed from normal to trivial

Having an empty class attribute doesn't really cause any problems; it's valid HTML.

#2 @janw.oostendorp
12 years ago

true, but it's ugly and the fix is really simple

#3 @nacin
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.