-
Notifications
You must be signed in to change notification settings - Fork 271
/
Copy pathmenu.php
91 lines (83 loc) · 3.09 KB
/
menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
// Register menus
register_nav_menus(
array(
'main-nav' => __( 'The Main Menu', 'jointswp' ), // Main nav in header
'offcanvas-nav' => __( 'The Off-Canvas Menu', 'jointswp' ), // Off-Canvas nav
'footer-links' => __( 'Footer Links', 'jointswp' ) // Secondary nav in footer
)
);
// The Top Menu
function joints_top_nav() {
wp_nav_menu(array(
'container' => false, // Remove nav container
'menu_id' => 'main-nav', // Adding custom nav id
'menu_class' => 'medium-horizontal menu', // Adding custom nav class
'items_wrap' => '<ul id="%1$s" class="%2$s" data-responsive-menu="accordion medium-dropdown">%3$s</ul>',
'theme_location' => 'main-nav', // Where it's located in the theme
'depth' => 5, // Limit the depth of the nav
'fallback_cb' => false, // Fallback function (see below)
'walker' => new Topbar_Menu_Walker()
));
}
// Big thanks to Brett Mason (https://github.com/brettsmason) for the awesome walker
class Topbar_Menu_Walker extends Walker_Nav_Menu {
function start_lvl(&$output, $depth = 0, $args = Array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"menu\">\n";
}
}
// The Off Canvas Menu
function joints_off_canvas_nav() {
wp_nav_menu(array(
'container' => false, // Remove nav container
'menu_id' => 'offcanvas-nav', // Adding custom nav id
'menu_class' => 'vertical menu accordion-menu', // Adding custom nav class
'items_wrap' => '<ul id="%1$s" class="%2$s" data-accordion-menu>%3$s</ul>',
'theme_location' => 'offcanvas-nav', // Where it's located in the theme
'depth' => 5, // Limit the depth of the nav
'fallback_cb' => false, // Fallback function (see below)
'walker' => new Off_Canvas_Menu_Walker()
));
}
class Off_Canvas_Menu_Walker extends Walker_Nav_Menu {
function start_lvl(&$output, $depth = 0, $args = Array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"vertical menu\">\n";
}
}
// The Footer Menu
function joints_footer_links() {
wp_nav_menu(array(
'container' => 'false', // Remove nav container
'menu_id' => 'footer-links', // Adding custom nav id
'menu_class' => 'menu', // Adding custom nav class
'theme_location' => 'footer-links', // Where it's located in the theme
'depth' => 0, // Limit the depth of the nav
'fallback_cb' => '' // Fallback function
));
} /* End Footer Menu */
// Header Fallback Menu
function joints_main_nav_fallback() {
wp_page_menu( array(
'show_home' => true,
'menu_class' => '', // Adding custom nav class
'include' => '',
'exclude' => '',
'echo' => true,
'link_before' => '', // Before each link
'link_after' => '' // After each link
));
}
// Footer Fallback Menu
function joints_footer_links_fallback() {
/* You can put a default here if you like */
}
// Add Foundation active class to menu
function required_active_nav_class( $classes, $item ) {
if ( $item->current == 1 || $item->current_item_ancestor == true ) {
$classes[] = 'active';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'required_active_nav_class', 10, 2 );