Skip to content

Commit a65b49c

Browse files
committed
Updated navbar walker to the latest v.1.3.4
1 parent ba5a8aa commit a65b49c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bs5starter/functions/navbar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)