Selaa lähdekoodia

Tidy up into partials.

Kjell Reigstad 4 vuotta sitten
vanhempi
commit
fd4c213ec6

+ 1 - 15
varia/footer.php

@@ -25,22 +25,8 @@
 	<footer id="colophon" class="site-footer responsive-max-width">
 	<footer id="colophon" class="site-footer responsive-max-width">
 			<?php
 			<?php
 			if ( ! ( true === get_theme_mod( 'hide_site_footer', false ) && is_front_page() && is_page() ) ) : // If this is the homepage and the footer elements are set to hide, don't load this part.
 			if ( ! ( true === get_theme_mod( 'hide_site_footer', false ) && is_front_page() && is_page() ) ) : // If this is the homepage and the footer elements are set to hide, don't load this part.
-
 				get_template_part( 'template-parts/footer/footer', 'widgets' );
 				get_template_part( 'template-parts/footer/footer', 'widgets' );
-
-				if ( has_nav_menu( 'menu-2' ) ) : ?>
-					<nav class="footer-navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'varia' ); ?>">
-						<?php
-						wp_nav_menu(
-							array(
-								'theme_location' => 'menu-2',
-								'menu_class'     => 'footer-menu',
-								'depth'          => 1,
-							)
-						);
-						?>
-					</nav><!-- .footer-navigation -->
-				<?php endif;
+				get_template_part( 'template-parts/footer/footer', 'navigation' );
 			endif; ?>
 			endif; ?>
 
 
 		<?php endif; ?>
 		<?php endif; ?>

+ 5 - 53
varia/header.php

@@ -11,13 +11,6 @@
  * @since 1.0.0
  * @since 1.0.0
  */
  */
 $has_primary_nav       = has_nav_menu( 'menu-1' );
 $has_primary_nav       = has_nav_menu( 'menu-1' );
-$has_primary_nav_items = wp_nav_menu(
-	array(
-		'theme_location' => 'menu-1',
-		'fallback_cb'    => false,
-		'echo'           => false,
-	)
-);
 $header_classes        = 'site-header responsive-max-width';
 $header_classes        = 'site-header responsive-max-width';
 $header_classes       .= has_custom_logo() ? ' has-logo' : '';
 $header_classes       .= has_custom_logo() ? ' has-logo' : '';
 $header_classes       .= 1 === get_theme_mod( 'header_text', 1 ) ? ' has-title-and-tagline' : '';
 $header_classes       .= 1 === get_theme_mod( 'header_text', 1 ) ? ' has-title-and-tagline' : '';
@@ -42,7 +35,9 @@ if ( function_exists( 'wp_body_open' ) ) {
 <div id="page" class="site">
 <div id="page" class="site">
 	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'varia' ); ?></a>
 	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'varia' ); ?></a>
 
 
-	<?php if ( class_exists( 'A8C\FSE\WP_Template' ) ) : // If the FSE plugin is active, use the Header template for content. ?>
+	<?php if ( ( true === get_theme_mod( 'hide_site_header', false ) && is_front_page() && is_page() ) ) : return; // Return if this is the homepage and the hide-header setting is active. ?>
+
+	<?php elseif ( class_exists( 'A8C\FSE\WP_Template' ) ) : // If not, check if the FSE plugin is active, use the Header template for content. ?>
 
 
 		<header id="masthead" class="fse-template-part fse-header entry-content">
 		<header id="masthead" class="fse-template-part fse-header entry-content">
 			<?php
 			<?php
@@ -51,54 +46,11 @@ if ( function_exists( 'wp_body_open' ) ) {
 			?>
 			?>
 		</header>
 		</header>
 
 
-	<?php elseif ( ( true === get_theme_mod( 'hide_site_header', false ) && is_front_page() && is_page() ) ) : return; // Return if this is the homepage and the hide-header setting is active. ?>
-
 	<?php else : // Otherwise we'll fallback to the default Varia header below. ?>
 	<?php else : // Otherwise we'll fallback to the default Varia header below. ?>
+
 		<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
 		<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
 			<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
 			<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
-
-			<?php if ( $has_primary_nav && $has_primary_nav_items ) : ?>
-				<nav id="site-navigation" class="main-navigation" aria-label="<?php esc_attr_e( 'Main Navigation', 'varia' ); ?>">
-
-					<input type="checkbox" role="button" aria-haspopup="true" id="toggle" class="hide-visually">
-					<label for="toggle" id="toggle-menu" class="button">
-						<?php _e( 'Menu', 'varia' ); ?>
-						<span class="dropdown-icon open">+</span>
-						<span class="dropdown-icon close">&times;</span>
-						<span class="hide-visually expanded-text"><?php _e( 'expanded', 'varia' ); ?></span>
-						<span class="hide-visually collapsed-text"><?php _e( 'collapsed', 'varia' ); ?></span>
-					</label>
-
-					<?php
-					$main_nav_args = array(
-						'theme_location' => 'menu-1',
-						'menu_class'     => 'main-menu',
-						'items_wrap'     => '<ul id="%1$s" class="%2$s" aria-label="submenu">%3$s</ul>',
-					);
-					if ( get_theme_mod( 'enable_side_menu' ) === 1 ) {
-						$main_nav_args['container_class'] = 'main-menu-container';
-					}
-					wp_nav_menu( $main_nav_args );
-					?>
-				</nav><!-- #site-navigation -->
-			<?php endif; ?>
-
-			<?php if ( has_nav_menu( 'social' ) ) : ?>
-				<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Social Links Menu', 'varia' ); ?>">
-					<?php
-					wp_nav_menu(
-						array(
-							'theme_location' => 'social',
-							'menu_class'     => 'social-links-menu',
-							'link_before'    => '<span class="screen-reader-text">',
-							'link_after'     => '</span>' . varia_get_icon_svg( 'link' ),
-							'depth'          => 1,
-						)
-					);
-					?>
-				</nav><!-- .social-navigation -->
-			<?php endif; ?>
-
+			<?php get_template_part( 'template-parts/header/site', 'navigation' ); ?>
 		</header><!-- #masthead -->
 		</header><!-- #masthead -->
 
 
 	<?php endif; ?>
 	<?php endif; ?>

+ 13 - 0
varia/template-parts/footer/footer-navigation.php

@@ -0,0 +1,13 @@
+<?php if ( has_nav_menu( 'menu-2' ) ) : ?>
+	<nav class="footer-navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'varia' ); ?>">
+		<?php
+		wp_nav_menu(
+			array(
+				'theme_location' => 'menu-2',
+				'menu_class'     => 'footer-menu',
+				'depth'          => 1,
+			)
+		);
+		?>
+	</nav><!-- .footer-navigation -->
+<?php endif; ?>

+ 52 - 0
varia/template-parts/header/site-navigation.php

@@ -0,0 +1,52 @@
+<?php 
+	$has_primary_nav       = has_nav_menu( 'menu-1' );
+	$has_primary_nav_items = wp_nav_menu(
+		array(
+			'theme_location' => 'menu-1',
+			'fallback_cb'    => false,
+			'echo'           => false,
+		)
+	);
+
+	if ( $has_primary_nav && $has_primary_nav_items ) : 
+?>
+	<nav id="site-navigation" class="main-navigation" aria-label="<?php esc_attr_e( 'Main Navigation', 'varia' ); ?>">
+
+		<input type="checkbox" role="button" aria-haspopup="true" id="toggle" class="hide-visually">
+		<label for="toggle" id="toggle-menu" class="button">
+			<?php _e( 'Menu', 'varia' ); ?>
+			<span class="dropdown-icon open">+</span>
+			<span class="dropdown-icon close">&times;</span>
+			<span class="hide-visually expanded-text"><?php _e( 'expanded', 'varia' ); ?></span>
+			<span class="hide-visually collapsed-text"><?php _e( 'collapsed', 'varia' ); ?></span>
+		</label>
+
+		<?php
+		$main_nav_args = array(
+			'theme_location' => 'menu-1',
+			'menu_class'     => 'main-menu',
+			'items_wrap'     => '<ul id="%1$s" class="%2$s" aria-label="submenu">%3$s</ul>',
+		);
+		if ( get_theme_mod( 'enable_side_menu' ) === 1 ) {
+			$main_nav_args['container_class'] = 'main-menu-container';
+		}
+		wp_nav_menu( $main_nav_args );
+		?>
+	</nav><!-- #site-navigation -->
+<?php endif; ?>
+
+<?php if ( has_nav_menu( 'social' ) ) : ?>
+	<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Social Links Menu', 'varia' ); ?>">
+		<?php
+		wp_nav_menu(
+			array(
+				'theme_location' => 'social',
+				'menu_class'     => 'social-links-menu',
+				'link_before'    => '<span class="screen-reader-text">',
+				'link_after'     => '</span>' . varia_get_icon_svg( 'link' ),
+				'depth'          => 1,
+			)
+		);
+		?>
+	</nav><!-- .social-navigation -->
+<?php endif; ?>