瀏覽代碼

update the header to add a custom logo class name

Ben Dwyer 4 年之前
父節點
當前提交
2d41766043
共有 1 個文件被更改,包括 11 次插入6 次删除
  1. 11 6
      varia/header.php

+ 11 - 6
varia/header.php

@@ -10,6 +10,11 @@
  * @subpackage Varia
  * @since 1.0.0
  */
+$has_primary_nav = has_nav_menu( 'menu-1' );
+$header_classes  = 'site-header responsive-max-width';
+$header_classes .= has_custom_logo() ? ' has-logo' : '';
+$header_classes .= true === get_theme_mod( 'display_title_and_tagline', true ) ? ' has-title-and-tagline' : '';
+$header_classes .= $has_primary_nav ? ' has-menu' : '';
 ?><!doctype html>
 <html <?php language_attributes(); ?>>
 <head>
@@ -26,7 +31,7 @@
 		wp_body_open();
 	}
 ?>
-	
+
 <div id="page" class="site">
 	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'varia' ); ?></a>
 
@@ -40,13 +45,12 @@
 		</header>
 
 	<?php else : // Otherwise we'll fallback to the default Varia header below. ?>
-
-		<header id="masthead" class="site-header responsive-max-width">
-
+		<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
 			<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
 
-			<?php if ( has_nav_menu( 'menu-1' ) ) : ?>
+			<?php if ( $has_primary_nav ) : ?>
 				<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' ); ?>
@@ -55,6 +59,7 @@
 						<span class="hide-visually expanded-text"><?php _e( 'expanded', 'varia' ); ?></span>
 						<span class="hide-visually collapsed-text"><?php _e( 'collapsed', 'varia' ); ?></span>
 					</label>
+
 					<?php
 					wp_nav_menu(
 						array(
@@ -68,7 +73,7 @@
 			<?php endif; ?>
 
 			<?php if ( has_nav_menu( 'social' ) ) : ?>
-				<nav class="social-navigation" aria-label="<?php esc_attr_e( 'Social Links Menu', 'varia' ); ?>">
+				<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Social Links Menu', 'varia' ); ?>">
 					<?php
 					wp_nav_menu(
 						array(