WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 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:
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)

comment:1 scribu2 years ago

  • Severity changed from normal to trivial

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

comment:2 janw.oostendorp2 years ago

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

comment:3 nacin2 years ago

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