瀏覽代碼

Switch to a method that doesn't use display:none.

Kjell Reigstad 4 年之前
父節點
當前提交
ad8272c44d

+ 15 - 0
seedlet/assets/css/style-editor.css

@@ -1662,6 +1662,17 @@ pre.wp-block-verse {
 	}
 }
 
+.home.page.hide-homepage-header.hide-homepage-title .entry-content {
+	margin-top: 0;
+	padding-top: 0;
+}
+
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-image.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-cover.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-media-text.alignfull:first-child {
+	margin-top: calc(-1 * var(--global--spacing-vertical));
+}
+
 .entry-attachment {
 	text-align: center;
 }
@@ -1741,6 +1752,10 @@ pre.wp-block-verse {
 	border-top: var(--separator--height) solid var(--separator--border-color);
 }
 
+.home.page.hide-homepage-footer .site-main > article > .entry-footer {
+	border-width: 0;
+}
+
 /**
  * Post Thumbnails
  */

+ 13 - 0
seedlet/assets/sass/components/entry/_content.scss

@@ -56,6 +56,19 @@
 	.wp-audio-shortcode {
 		@extend %responsive-aligndefault-width;
 	}
+
+	// If the homepage header and page title are both configured to be hidden.
+	.home.page.hide-homepage-header.hide-homepage-title & {
+		margin-top: 0;
+		padding-top: 0;
+
+		// Move some full-width blocks up to the top of the screen.
+		> .wp-block-image.alignfull:first-child,
+		> .wp-block-cover.alignfull:first-child,
+		> .wp-block-media-text.alignfull:first-child {
+			margin-top: calc(-1 * var(--global--spacing-vertical));
+		}
+	}
 }
 
 .entry-attachment {

+ 5 - 0
seedlet/assets/sass/components/entry/_meta.scss

@@ -62,4 +62,9 @@
 	margin-top: calc( var(--global--spacing-vertical) * 3 );
 	padding-top: var(--global--spacing-unit);
 	border-top: var(--separator--height) solid var(--separator--border-color);
+
+	// Remove the border if the homepage's main footer is also hidden.
+	.home.page.hide-homepage-footer & {
+		border-width: 0;
+	}
 }

+ 15 - 13
seedlet/footer.php

@@ -16,20 +16,22 @@
 
 	<footer id="colophon" class="site-footer default-max-width" role="contentinfo" aria-label="<?php esc_attr_e( 'Footer', 'seedlet' ); ?>">
 
-		<?php get_template_part( 'template-parts/footer/footer-widgets' ); ?>
+		<?php if ( false === get_theme_mod( 'hide_site_footer', false ) ) : ?>
+			<?php get_template_part( 'template-parts/footer/footer-widgets' ); ?>
 
-		<?php if ( has_nav_menu( 'footer' ) ) : ?>
-		<nav class="footer-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'seedlet' ); ?>">
-			<?php
-			wp_nav_menu(
-				array(
-					'theme_location' => 'footer',
-					'menu_class'     => 'footer-menu',
-					'depth'          => 1,
-				)
-			);
-			?>
-		</nav><!-- .footer-navigation -->
+			<?php if ( has_nav_menu( 'footer' ) ) : ?>
+			<nav class="footer-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'seedlet' ); ?>">
+				<?php
+				wp_nav_menu(
+					array(
+						'theme_location' => 'footer',
+						'menu_class'     => 'footer-menu',
+						'depth'          => 1,
+					)
+				);
+				?>
+			</nav><!-- .footer-navigation -->
+			<?php endif; ?>
 		<?php endif; ?>
 
 		<div class="site-info">

+ 2 - 0
seedlet/header.php

@@ -28,6 +28,7 @@ $header_classes .= $has_primary_nav ? ' has-menu' : '';
 <div id="page" class="site">
 	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'seedlet' ); ?></a>
 
+	<?php if ( false === get_theme_mod( 'hide_site_header', false ) ) : ?>
 		<header id="masthead" class="<?php echo $header_classes; ?>" role="banner">
 			<?php get_template_part( 'template-parts/header/site-branding' ); ?>
 
@@ -121,5 +122,6 @@ $header_classes .= $has_primary_nav ? ' has-menu' : '';
 			<?php endif; ?>
 
 		</header><!-- #masthead -->
+	<?php endif; ?>
 
 	<div id="content" class="site-content">

+ 36 - 0
seedlet/inc/customizer.php

@@ -138,6 +138,42 @@ if ( ! class_exists( 'Seedlet_Customize' ) ) {
 					'label'   => esc_html__( 'Display Site Title & Tagline', 'seedlet' ),
 				)
 			);
+
+			// Add setting to hide the site header on the homepage.
+			$wp_customize->add_setting( 'hide_site_header', array(
+				'default'              => false,
+				'type'                 => 'theme_mod',
+				'transport'            => 'refresh',
+				'sanitize_callback'    => array( __CLASS__, 'sanitize_checkbox' ),
+			) );
+
+			// Add control to hide the site header on the homepage.
+			$wp_customize->add_control( 'hide_site_header', array(
+				'label'		  => esc_html__( 'Hide the Site Header', 'seedlet' ),
+				'description' => esc_html__( 'Check to hide the site header, if your homepage is set to display a static page.', 'seedlet' ),
+				'section'	  => 'static_front_page',
+				'priority'	  => 10,
+				'type'		  => 'checkbox',
+				'settings'	  => 'hide_site_header',
+			) );
+
+			// Add setting to hide footer elements on the homepage.
+			$wp_customize->add_setting( 'hide_site_footer', array(
+				'default'              => false,
+				'type'                 => 'theme_mod',
+				'transport'            => 'refresh',
+				'sanitize_callback'    => array( __CLASS__, 'sanitize_checkbox' ),
+			) );
+
+			// Add control to hide footer elements on the homepage.
+			$wp_customize->add_control( 'hide_site_footer', array(
+				'label'		  => esc_html__( 'Hide the Site Footer Menu & Widgets', 'seedlet' ),
+				'description' => esc_html__( 'Check to hide the site menu & widgets in the footer, if your homepage is set to display a static page.', 'seedlet' ),
+				'section'	  => 'static_front_page',
+				'priority'	  => 10,
+				'type'		  => 'checkbox',
+				'settings'	  => 'hide_site_footer',
+			) );
 		}
 
 		/**

+ 14 - 0
seedlet/inc/template-functions.php

@@ -35,6 +35,20 @@ function seedlet_body_classes( $classes ) {
 		$classes[] = 'has-main-navigation';
 	}
 
+	// Add a body class if the site header is hidden on the homepage.
+	$hide_site_header = get_theme_mod( 'hide_site_header', false );
+
+	if ( true === $hide_site_header && is_front_page() ) {
+		$classes[] = 'hide-homepage-header';
+	}
+
+	// Add a body class if the footer elements are hidden on the homepage.
+	$hide_site_footer = get_theme_mod( 'hide_site_footer', false );
+
+	if ( true === $hide_site_footer && is_front_page() ) {
+		$classes[] = 'hide-homepage-footer';
+	}
+
 	return $classes;
 }
 add_filter( 'body_class', 'seedlet_body_classes' );

+ 0 - 22
seedlet/inc/wpcom-customize-preview.js

@@ -93,26 +93,4 @@ function changeColorLuminescence( hex, amount ) {
 			}
 		} );
 	} );
-
-	// Hide Site Header
-	wp.customize( 'hide_site_header', function( value ) {
-		value.bind( function( to ) {
-			if ( true === to ) {
-				$( 'body' ).addClass( 'hide-homepage-header' );
-			} else {
-				$( 'body' ).removeClass( 'hide-homepage-header' );
-			}
-		} );
-	} );
-
-	// Hide Site Footer Menu
-	wp.customize( 'hide_site_footer', function( value ) {
-		value.bind( function( to ) {
-			if ( true === to ) {
-				$( 'body' ).addClass( 'hide-homepage-footer' );
-			} else {
-				$( 'body' ).removeClass( 'hide-homepage-footer' );
-			}
-		} );
-	} );
 } )( jQuery );

+ 0 - 31
seedlet/inc/wpcom-style.css

@@ -13,37 +13,6 @@
 	margin-top: 0;
 }
 
-/**
- * Hide site header on the homepage
- */
-.home.page.hide-homepage-header .site-header {
-	display: none;
-}
-
-.home.page.hide-homepage-header .entry-content {
-	margin-top: 0;
-	padding-top: 0;
-}
-
-.home.page.hide-homepage-header .site-main > article > .entry-footer {
-	border-width: 0;
-}
-
-/* Move some full-width blocks up to the top of the screen) */
-.home.page.hide-homepage-header .entry-content > .wp-block-image.alignfull:first-child,
-.home.page.hide-homepage-header .entry-content > .wp-block-cover.alignfull:first-child,
-.home.page.hide-homepage-header .entry-content > .wp-block-media-text.alignfull:first-child {
-	margin-top: calc(-1 * var(--global--spacing-vertical));
-}
-
- /**
- * Hide footer navigation on the homepage
- */
-.home.page.hide-homepage-footer .footer-navigation,
-.home.page.hide-homepage-footer .widget-area {
-	display: none;
-}
-
 /**
  * Fix Direct Manipulation icons in the Customizer
  */

+ 0 - 44
seedlet/inc/wpcom.php

@@ -166,38 +166,6 @@ function seedlet_wpcom_customize_update( $wp_customize ) {
 		'priority'	  => 10,
 		'type'		  => 'hidden',
 	) );
-
-	$wp_customize->add_setting( 'hide_site_header', array(
-		'default'              => false,
-		'type'                 => 'theme_mod',
-		'transport'            => 'postMessage',
-		'sanitize_callback'    => 'seedlet_sanitize_checkbox',
-	) );
-
-	$wp_customize->add_control( 'hide_site_header', array(
-		'label'		  => esc_html__( 'Hide the Site Header', 'seedlet' ),
-		'description' => esc_html__( 'Check to hide the site header, if your homepage is set to display a static page.', 'seedlet' ),
-		'section'	  => 'static_front_page',
-		'priority'	  => 10,
-		'type'		  => 'checkbox',
-		'settings'	  => 'hide_site_header',
-	) );
-
-	$wp_customize->add_setting( 'hide_site_footer', array(
-		'default'              => false,
-		'type'                 => 'theme_mod',
-		'transport'            => 'postMessage',
-		'sanitize_callback'    => 'seedlet_sanitize_checkbox',
-	) );
-
-	$wp_customize->add_control( 'hide_site_footer', array(
-		'label'		  => esc_html__( 'Hide the Site Footer Menu & Widgets', 'seedlet' ),
-		'description' => esc_html__( 'Check to hide the site menu & widgets in the footer, if your homepage is set to display a static page.', 'seedlet' ),
-		'section'	  => 'static_front_page',
-		'priority'	  => 10,
-		'type'		  => 'checkbox',
-		'settings'	  => 'hide_site_footer',
-	) );
 }
 add_action( 'customize_register', 'seedlet_wpcom_customize_update' );
 
@@ -247,18 +215,6 @@ function seedlet_wpcom_body_classes( $classes ) {
 		$classes[] = 'hide-homepage-title';
 	}
 
-	$hide_site_header = get_theme_mod( 'hide_site_header', false );
-
-	if ( true === $hide_site_header ) {
-		$classes[] = 'hide-homepage-header';
-	}
-
-	$hide_site_footer = get_theme_mod( 'hide_site_footer', false );
-
-	if ( true === $hide_site_footer ) {
-		$classes[] = 'hide-homepage-footer';
-	}
-
 	$credit_option = get_option( 'footercredit' );
 
 	if ( 'hidden' == $credit_option ) {

+ 15 - 0
seedlet/style-rtl.css

@@ -3191,6 +3191,17 @@ nav a {
 	}
 }
 
+.home.page.hide-homepage-header.hide-homepage-title .entry-content {
+	margin-top: 0;
+	padding-top: 0;
+}
+
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-image.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-cover.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-media-text.alignfull:first-child {
+	margin-top: calc(-1 * var(--global--spacing-vertical));
+}
+
 .entry-attachment {
 	text-align: center;
 }
@@ -3270,6 +3281,10 @@ nav a {
 	border-top: var(--separator--height) solid var(--separator--border-color);
 }
 
+.home.page.hide-homepage-footer .site-main > article > .entry-footer {
+	border-width: 0;
+}
+
 /**
  * Post Thumbnails
  */

+ 15 - 0
seedlet/style.css

@@ -3212,6 +3212,17 @@ nav a {
 	}
 }
 
+.home.page.hide-homepage-header.hide-homepage-title .entry-content {
+	margin-top: 0;
+	padding-top: 0;
+}
+
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-image.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-cover.alignfull:first-child,
+.home.page.hide-homepage-header.hide-homepage-title .entry-content > .wp-block-media-text.alignfull:first-child {
+	margin-top: calc(-1 * var(--global--spacing-vertical));
+}
+
 .entry-attachment {
 	text-align: center;
 }
@@ -3291,6 +3302,10 @@ nav a {
 	border-top: var(--separator--height) solid var(--separator--border-color);
 }
 
+.home.page.hide-homepage-footer .site-main > article > .entry-footer {
+	border-width: 0;
+}
+
 /**
  * Post Thumbnails
  */