Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#20674 closed enhancement (duplicate)

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

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

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
14 years ago

  • Severity normal → trivial

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

#2 @janw.oostendorp
14 years ago

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

#3 @nacin
14 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed
Note: See TracTickets for help on using tickets.