瀏覽代碼

Merge pull request #2977 from Automattic/blank-canvas/update/dont-render-header-unless-it-has-content

Blank Canvas: Only load the header if there's content in it
Kjell Reigstad 4 年之前
父節點
當前提交
4d00cb133a
共有 1 個文件被更改,包括 20 次插入18 次删除
  1. 20 18
      blank-canvas/header.php

+ 20 - 18
blank-canvas/header.php

@@ -28,26 +28,28 @@ $header_class = $show_title ? 'site-title' : 'screen-reader-text';
 <div id="page" class="site">
 	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'blank-canvas' ); ?></a>
 
-	<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
-		<?php if ( has_custom_logo() && $show_title && ! is_singular() ) : ?>
-			<div class="site-logo"><?php the_custom_logo(); ?></div>
-		<?php endif; ?>
+	<?php if ( ! is_singular() ) : ?>
+		<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
+			<?php if ( has_custom_logo() && $show_title ) : ?>
+				<div class="site-logo"><?php the_custom_logo(); ?></div>
+			<?php endif; ?>
 
-		<div class="site-branding">
-			<?php if ( ! empty( $blog_info ) && $show_title && ! is_singular() ) : ?>
-				<?php if ( is_front_page() && is_home() ) : ?>
-					<h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></h1>
-				<?php else : ?>
-					<p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></p>
+			<div class="site-branding">
+				<?php if ( ! empty( $blog_info ) && $show_title ) : ?>
+					<?php if ( is_front_page() && is_home() ) : ?>
+						<h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></h1>
+					<?php else : ?>
+						<p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php echo $blog_info; ?></a></p>
+					<?php endif; ?>
 				<?php endif; ?>
-			<?php endif; ?>
 
-			<?php if ( ( $description || is_customize_preview() ) && $show_title && ! is_singular() ) : ?>
-				<p class="site-description">
-					<?php echo $description; ?>
-				</p>
-			<?php endif; ?>
-		</div><!-- .site-branding -->
-	</header><!-- #masthead -->
+				<?php if ( ( $description || is_customize_preview() ) && $show_title ) : ?>
+					<p class="site-description">
+						<?php echo $description; ?>
+					</p>
+				<?php endif; ?>
+			</div><!-- .site-branding -->
+		</header><!-- #masthead -->
+	<?php endif; ?>
 
 	<div id="content" class="site-content">