From 0892fab0ac00b244eea7a52f23e10c79223c3bfd Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Fri, 5 Jun 2020 18:36:22 +0200 Subject: [PATCH] customizable menu button --- kit/functions.php | 11 ++++++++++- kit/header.php | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/kit/functions.php b/kit/functions.php index e119654..f76cd20 100644 --- a/kit/functions.php +++ b/kit/functions.php @@ -10,13 +10,22 @@ function kit_setup() { register_nav_menus( array( 'primary' => 'Main Menu', - 'secondary' => 'Footer Menu' + 'secondary' => 'Footer Menu', + 'extra' => 'Extra Menu' ) ); }; add_action( 'after_setup_theme', 'kit_setup' ); +function add_menu_link_class( $atts, $item, $args ) { + if (property_exists($args, 'link_class')) { + $atts['class'] = $args->link_class; + } + return $atts; +} +add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 ); + class kit_custom_main_menu extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { diff --git a/kit/header.php b/kit/header.php index 1aa4261..668e4ff 100644 --- a/kit/header.php +++ b/kit/header.php @@ -148,7 +148,20 @@
- Zum Bestand + false, + 'echo' => false, + 'items_wrap' => '%3$s', + 'depth' => 0, + 'theme_location' => 'extra', + 'link_class' => 'header-button', + 'link_before' => '', + 'link_after' => '', + ); + echo strip_tags(wp_nav_menu( $menuParameters ), '' ); + ?> +