-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.php
More file actions
60 lines (52 loc) · 2.5 KB
/
header.php
File metadata and controls
60 lines (52 loc) · 2.5 KB
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
<header id="masthead" class="site__header siteHeader">
<div id="navbar" class="siteHeader__navbar <?php if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) { echo 'has-logo'; } ?>">
<div class="siteHeader__branding">
<?php // gets custom logo if selected, otherwise displays site title ?>
<?php if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) : ?>
<?php the_custom_logo(); ?>
<?php else : ?>
<span class="siteHeader__title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span>
<?php endif; ?>
</div>
<?php
// Initialize $menu_offset
$secondary_menu_present = wp_nav_menu( array( 'theme_location' => 'menu-2', 'echo' => false )) !== false;
$secondary_menu_assigned = has_nav_menu('menu-2');
$menu_offset = $secondary_menu_present && $secondary_menu_assigned ? '-menu-offset' : '';
?>
<nav id="site__navigation" class="siteNavigation <?php echo $menu_offset ?>" role="navigation" tabindex="0">
<h3 class="screen-reader-text">Main Menu</h3>
<?php // check if primary menu is empty and if menu location is assigned
$primary_menu_present = wp_nav_menu( array( 'theme_location' => 'menu-1', 'echo' => false )) !== false;
$primary_menu_assigned = has_nav_menu('menu-1');
if($primary_menu_present && $primary_menu_assigned) {
wp_nav_menu(array(
'theme_location' => 'menu-1',
'echo' => true,
'depth' => 2,
'container' => 'ul',
'menu_class' => 'primary-menu ' . $menu_offset,
'menu_id' => 'primary-menu',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'walker' => new custom_walker_nav_menu
));
}
?>
<?php // check if secondary menu is empty, and if so, apply spacing offset
if($secondary_menu_present && $secondary_menu_assigned) {
wp_nav_menu(array(
'theme_location' => 'menu-2',
'echo' => true,
'depth' => 2,
'container' => 'ul',
'menu_class' => 'secondary-menu',
'menu_id' => 'secondary-menu',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'walker' => new custom_walker_nav_menu
));
}
?>
</nav>
<button class="menuToggle" tabindex="0" aria-label="Menu" aria-controls="primary-menu"><?php esc_html_e( 'Menu', 'baseinstall' ); ?><span>toggle menu</span></button>
</div>
</header>