Fix for duplicate active menu items. #986

Closed
wants to merge 1 commit into from

3 participants

@dalabarge

There's a duplication of active menu items when using custom post types. Namely that custom posts nested beneath a page cause the blog to become .active while simultaneously setting the parent page .active and the current menu item .active. This patch fixes all that nonsense. If you print_r($classes); print_r($new_classes) on line 60 you'll see that there are always at least 2 active replaces prior to the array_unique($new_classes). The array_search('current-menu-item',... conditional check is to ensure that .active is still set for current menu item regardless of the number of $new_class_counts.

@dalabarge dalabarge Fix for duplicate active menu items.
There's a duplication of active menu items when using custom post types. Namely that custom posts nested beneath a page cause the blog to become `.active` while simultaneously setting the parent page `.active` and the current menu item `.active`. This patch fixes all that nonsense. If you `print_r($classes); print_r($new_classes)` on line 60 you'll see that there are always at least 2 active replaces prior to the `array_unique($new_classes)`. The `array_search('current-menu-item',...` conditional check  is to ensure that `.active` is still set for current menu item regardless of the number of `$new_class_counts`.
09c3f55
@retlehs
Roots member

@Foxaii has a nav rejig branch that handles this which will be merged in soon

@dalabarge

Dang, wish I knew. His looks a lot fancier and probably more tested. This solved my problem in a down and dirty way. Feel free to close if you don't use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment