From 0b9d0684c7edfd15c4ea3a3e78c568c5fef300bd Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 1 Feb 2021 11:59:15 +0800 Subject: [PATCH] added support for dropdown menu (responsive) alignment --- functions.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 54a0078..5c238a9 100644 --- a/functions.php +++ b/functions.php @@ -2,15 +2,38 @@ // bootstrap 5 wp_nav_menu walker class bootstrap_5_wp_nav_menu_walker extends Walker_Nav_menu { + private $current_item; + private $dropdown_menu_alignment_values = [ + 'dropdown-menu-start', + 'dropdown-menu-end', + 'dropdown-menu-sm-start', + 'dropdown-menu-sm-end', + 'dropdown-menu-md-start', + 'dropdown-menu-md-end', + 'dropdown-menu-lg-start', + 'dropdown-menu-lg-end', + 'dropdown-menu-xl-start', + 'dropdown-menu-xl-end', + 'dropdown-menu-xxl-start', + 'dropdown-menu-xxl-end' + ]; + function start_lvl(&$output, $depth = 0, $args = array()) { + $dropdown_menu_class[] = ''; + foreach($this->current_item->classes as $class) { + if(in_array($class, $this->dropdown_menu_alignment_values)) { + $dropdown_menu_class[] = $class; + } + } $indent = str_repeat("\t", $depth); $submenu = ($depth > 0) ? ' sub-menu' : ''; - $output .= "\n$indent