From da098a5c00e9dee546190921b34b75ca14c409b7 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 22 Jan 2021 10:13:04 +0800 Subject: [PATCH] Moved .active class from li.nav-item to a.nav-link --- functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index b0d0a46..54a0078 100644 --- a/functions.php +++ b/functions.php @@ -20,7 +20,6 @@ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) $classes = empty($item->classes) ? array() : (array) $item->classes; $classes[] = ($args->walker->has_children) ? 'dropdown' : ''; - $classes[] = ($item->current || $item->current_item_ancestor) ? 'active' : ''; $classes[] = 'nav-item'; $classes[] = 'nav-item-' . $item->ID; if ($depth && $args->walker->has_children) { @@ -40,7 +39,8 @@ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : ''; $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : ''; - $attributes .= ($args->walker->has_children) ? ' class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="nav-link"'; + $active_class = ($item->current || $item->current_item_ancestor) ? 'active' : ''; + $attributes .= ($args->walker->has_children) ? ' class="nav-link ' . $active_class . ' dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="nav-link ' . $active_class . '"'; $item_output = $args->before; $item_output .= ($depth > 0) ? '' : '';