From f9baca69c7c6984bdfdf289a1e0faa696143da5d Mon Sep 17 00:00:00 2001 From: Mike Sheppard Date: Wed, 21 Apr 2021 23:06:05 +0100 Subject: [PATCH] V.basic update to excluded nav classes, allowing custom classes --- src/MenuBuilder.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/MenuBuilder.php b/src/MenuBuilder.php index be75e19..d3c62fd 100644 --- a/src/MenuBuilder.php +++ b/src/MenuBuilder.php @@ -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', @@ -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;