Menus: Add filter to sub-menu class in nav menus.
Add new filter `nav_menu_submenu_css_class` to the `Walker_Nav_Menu::start_el()` method, allowing themers to modify the sub menu classes output by `wp_nav_menu()`. Props: csloisel, darthaud, raisonon. Fixes: #36163. git-svn-id: https://develop.svn.wordpress.org/trunk@40537 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ce8a915c06
commit
1345e33a21
@ -58,7 +58,22 @@ class Walker_Nav_Menu extends Walker {
|
||||
$n = "\n";
|
||||
}
|
||||
$indent = str_repeat( $t, $depth );
|
||||
$output .= "{$n}{$indent}<ul class=\"sub-menu\">{$n}";
|
||||
|
||||
/**
|
||||
* Filters the CSS class(es) applied to a menu list element.
|
||||
*
|
||||
* @since 4.8.0
|
||||
*
|
||||
* @param array $classes The CSS classes that are applied to the menu `<ul>` element.
|
||||
* @param stdClass $args An object of `wp_nav_menu()` arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
|
||||
$classes = array( 'sub-menu' );
|
||||
$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}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user