Skip to content

Commit

Permalink
V.basic update to excluded nav classes, allowing custom classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-sheppard committed Apr 21, 2021
1 parent 51f6710 commit f9baca6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ class MenuBuilder
];

/**
* Blacklisted Classes
* Excluded Classes
*
* @var array
*/
protected $classes = [
protected $excluded_classes = [
'current-menu',
'current_page',
'sub-menu',
'menu-item',
// 'menu-item',
'menu-item-type-post_type',
'menu-item-object-page',
'menu-item-type-custom',
'menu-item-object-custom',
'menu_item',
'page-item',
'page_item',
Expand Down Expand Up @@ -88,10 +92,7 @@ protected function filter($menu = [])

return array_map(function ($item) {
$classes = array_filter($item->classes, function ($class) {
return array_key_exists(
$class,
array_flip($this->classes)
);
return !in_array($class, $this->excluded_classes);
});

$item->classes = is_array($classes) ? implode(' ', $classes) : $classes;
Expand Down

0 comments on commit f9baca6

Please sign in to comment.