@@ -18,7 +18,7 @@ class bootstrap_5_wp_nav_menu_walker extends Walker_Nav_menu
1818 'dropdown-menu-xxl-end '
1919 ];
2020
21- function start_lvl (&$ output , $ depth = 0 , $ args = array () )
21+ function start_lvl (&$ output , $ depth = 0 , $ args = null )
2222 {
2323 $ dropdown_menu_class [] = '' ;
2424 foreach ($ this ->current_item ->classes as $ class ) {
@@ -31,7 +31,7 @@ function start_lvl(&$output, $depth = 0, $args = array())
3131 $ output .= "\n$ indent<ul class= \"dropdown-menu $ submenu " . esc_attr (implode (" " ,$ dropdown_menu_class )) . " depth_ $ depth \"> \n" ;
3232 }
3333
34- function start_el (&$ output , $ item , $ depth = 0 , $ args = array () , $ id = 0 )
34+ function start_el (&$ output , $ item , $ depth = 0 , $ args = null , $ id = 0 )
3535 {
3636 $ this ->current_item = $ item ;
3737
@@ -62,7 +62,7 @@ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
6262 $ attributes .= !empty ($ item ->xfn ) ? ' rel=" ' . esc_attr ($ item ->xfn ) . '" ' : '' ;
6363 $ attributes .= !empty ($ item ->url ) ? ' href=" ' . esc_attr ($ item ->url ) . '" ' : '' ;
6464
65- $ active_class = ($ item ->current || $ item ->current_item_ancestor ) ? 'active ' : '' ;
65+ $ active_class = ($ item ->current || $ item ->current_item_ancestor || in_array ( " current_page_parent " , $ item -> classes , true ) || in_array ( " current-post-ancestor " , $ item -> classes , true ) ) ? 'active ' : '' ;
6666 $ nav_link_class = ( $ depth > 0 ) ? 'dropdown-item ' : 'nav-link ' ;
6767 $ attributes .= ( $ args ->walker ->has_children ) ? ' class=" ' . $ nav_link_class . $ active_class . ' dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ' : ' class=" ' . $ nav_link_class . $ active_class . '" ' ;
6868
0 commit comments