Skip to content

Commit

Permalink
Moved .active class from li.nav-item to a.nav-link
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWebLab committed Jan 22, 2021
1 parent 3613deb commit da098a5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) ? '<a class="dropdown-item"' . $attributes . '>' : '<a' . $attributes . '>';
Expand Down

0 comments on commit da098a5

Please sign in to comment.