Menus: Prevent empty class attribute following [40537].
Prevents an empty class attribute, `class=""`, from appearing in the HTML if a developer removes all classes using the `nav_menu_submenu_css_class` filter. Props Kopepasah. Fixes #36163. Built from https://develop.svn.wordpress.org/trunk@40665 git-svn-id: http://core.svn.wordpress.org/trunk@40528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
868312d995
commit
62de6cc7ec
|
@ -59,6 +59,9 @@ class Walker_Nav_Menu extends Walker {
|
||||||
}
|
}
|
||||||
$indent = str_repeat( $t, $depth );
|
$indent = str_repeat( $t, $depth );
|
||||||
|
|
||||||
|
// Default class.
|
||||||
|
$classes = array( 'sub-menu' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the CSS class(es) applied to a menu list element.
|
* Filters the CSS class(es) applied to a menu list element.
|
||||||
*
|
*
|
||||||
|
@ -68,12 +71,10 @@ class Walker_Nav_Menu extends Walker {
|
||||||
* @param stdClass $args An object of `wp_nav_menu()` arguments.
|
* @param stdClass $args An object of `wp_nav_menu()` arguments.
|
||||||
* @param int $depth Depth of menu item. Used for padding.
|
* @param int $depth Depth of menu item. Used for padding.
|
||||||
*/
|
*/
|
||||||
|
$class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
|
||||||
|
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||||
|
|
||||||
$classes = array( 'sub-menu' );
|
$output .= "{$n}{$indent}<ul $class_names>{$n}";
|
||||||
$classes = apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth );
|
|
||||||
$class_names = join( ' ', $classes );
|
|
||||||
|
|
||||||
$output .= "{$n}{$indent}<ul class='" . esc_attr( $class_names ) . "'>{$n}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.8-beta1-40664';
|
$wp_version = '4.8-beta1-40665';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue