WordPress.org

Make WordPress Core

Ticket #20483: nav-menu-template.diff

File nav-menu-template.diff, 695 bytes (added by niallkennedy, 3 years ago)

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

  • wp-includes/nav-menu-template.php

     
    7474                $classes[] = 'menu-item-' . $item->ID; 
    7575 
    7676                $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); 
    77                 $class_names = ' class="' . esc_attr( $class_names ) . '"'; 
     77                $class_names = strlen( $class_names ) ? ' class="' . esc_attr( $class_names ) . '"' : ''; 
    7878 
    7979                $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); 
    8080                $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';