|
1
|
|
|
<?php |
|
2
|
|
|
// Register menus |
|
3
|
|
|
register_nav_menus( |
|
4
|
|
|
[ |
|
5
|
|
|
'main-nav' => __('The Main Menu', 'podium') // Main nav in header //'footer-links' => __( 'Footer Links', 'podium' ) // Secondary nav in footer |
|
6
|
|
|
] |
|
7
|
|
|
); |
|
8
|
|
|
|
|
9
|
|
|
// The Top Menu |
|
10
|
|
View Code Duplication |
function podium_top_nav() |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
wp_nav_menu([ |
|
13
|
|
|
'container' => false, // Remove nav container |
|
14
|
|
|
'container_class' => '', // Class of container |
|
15
|
|
|
'menu' => 'The Top Menu', 'podium', // Menu name |
|
16
|
|
|
'menu_class' => 'dropdown menu', // Adding custom nav class |
|
17
|
|
|
'theme_location' => 'main-nav', // Where it's located in the theme |
|
18
|
|
|
'before' => '', // Before each link <a> |
|
19
|
|
|
'after' => '', // After each link </a> |
|
20
|
|
|
'link_before' => '', // Before each link text |
|
21
|
|
|
'link_after' => '', // After each link text |
|
22
|
|
|
'depth' => 3, // Limit the depth of the nav |
|
23
|
|
|
'fallback_cb' => false, // Fallback function (see below) |
|
24
|
|
|
'walker' => new Top_Bar_Walker() |
|
25
|
|
|
]); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/* End Top Menu */ |
|
29
|
|
|
|
|
30
|
|
View Code Duplication |
function podium_off_canvas() |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
wp_nav_menu([ |
|
33
|
|
|
'container' => false, // Remove nav container |
|
34
|
|
|
'container_class' => '', // Class of container |
|
35
|
|
|
'menu' => '', // Menu name |
|
36
|
|
|
'menu_class' => 'off-canvas-list', // Adding custom nav class |
|
37
|
|
|
'theme_location' => 'main-nav', // Where it's located in the theme |
|
38
|
|
|
'before' => '', // Before each link <a> |
|
39
|
|
|
'after' => '', // After each link </a> |
|
40
|
|
|
'link_before' => '', // Before each link text |
|
41
|
|
|
'link_after' => '', // After each link text |
|
42
|
|
|
'depth' => 2, // Limit the depth of the nav |
|
43
|
|
|
'fallback_cb' => false, // Fallback function (see below) |
|
44
|
|
|
'walker' => new Offcanvas_Walker() |
|
45
|
|
|
]); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
// The Footer Menu |
|
49
|
|
|
function podium_footer_links() |
|
50
|
|
|
{ |
|
51
|
|
|
wp_nav_menu([ |
|
52
|
|
|
'container' => '', // Remove nav container |
|
53
|
|
|
'container_class' => 'footer-links clearfix', // Class of container (should you choose to use it) |
|
54
|
|
|
'menu' => __('Footer Links', 'podium'), // Nav name |
|
55
|
|
|
'menu_class' => 'sub-nav', // Adding custom nav class |
|
56
|
|
|
'theme_location' => 'footer-links', // Where it's located in the theme |
|
57
|
|
|
'before' => '', // Before the menu |
|
58
|
|
|
'after' => '', // After the menu |
|
59
|
|
|
'link_before' => '', // Before each link |
|
60
|
|
|
'link_after' => '', // After each link |
|
61
|
|
|
'depth' => 0, // Limit the depth of the nav |
|
62
|
|
|
'fallback_cb' => 'podium_footer_links_fallback' // Fallback function |
|
63
|
|
|
]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/* End Footer Menu */ |
|
67
|
|
|
|
|
68
|
|
|
// Header Fallback Menu |
|
69
|
|
|
function podium_main_nav_fallback() |
|
70
|
|
|
{ |
|
71
|
|
|
wp_page_menu([ |
|
72
|
|
|
'show_home' => true, |
|
73
|
|
|
'menu_class' => '', // Adding custom nav class |
|
74
|
|
|
'include' => '', |
|
75
|
|
|
'exclude' => '', |
|
76
|
|
|
'echo' => true, |
|
77
|
|
|
'link_before' => '', // Before each link |
|
78
|
|
|
'link_after' => '' // After each link |
|
79
|
|
|
]); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
// Footer Fallback Menu |
|
83
|
|
|
function joints_footer_links_fallback() |
|
84
|
|
|
{ |
|
85
|
|
|
/* You can put a default here if you like */ |
|
86
|
|
|
} |
|
87
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.