瀏覽代碼

Merge pull request #3163 from Automattic/blank-canvas/fix/equal-footer-spacing

Blank Canvas: Even out footer spacing
Ben Dwyer 4 年之前
父節點
當前提交
73df0a97fd
共有 3 個文件被更改,包括 46 次插入13 次删除
  1. 24 0
      blank-canvas/functions.php
  2. 21 8
      blank-canvas/style.css
  3. 1 5
      blank-canvas/template-parts/content/content-singular.php

+ 24 - 0
blank-canvas/functions.php

@@ -176,3 +176,27 @@ add_action( 'customize_controls_enqueue_scripts', 'blank_canvas_customizer_enque
  * Customizer additions.
  */
 require get_stylesheet_directory() . '/inc/customizer.php';
+
+/**
+ * Adds custom classes to the array of body classes.
+ *
+ * @param array $classes Classes for the body element.
+ * @return array
+ */
+function blank_canvas_body_classes( $classes ) {
+
+	if ( false === get_theme_mod( 'show_post_and_page_titles', false ) ) {
+		$classes[] = 'hide-post-and-page-titles';
+	}
+
+	if ( false === get_theme_mod( 'show_site_footer', false ) ) {
+		$classes[] = 'hide-site-footer';
+	}
+
+	if ( false === get_theme_mod( 'show_comments', false ) ) {
+		$classes[] = 'hide-comments';
+	}
+
+	return $classes;
+}
+add_filter( 'body_class', 'blank_canvas_body_classes' );

+ 21 - 8
blank-canvas/style.css

@@ -58,17 +58,30 @@ Used as block pattern image.
 
 /* Remove some top padding if the first block on the page is a full-width image, cover, media & text, or group block. */
 
-.single .entry-content.hide-post-and-page-titles > .wp-block-image.alignfull:first-child,
-.page .entry-content.hide-post-and-page-titles > .wp-block-image.alignfull:first-child,
-.single .entry-content.hide-post-and-page-titles > .wp-block-cover.alignfull:first-child,
-.page .entry-content.hide-post-and-page-titles > .wp-block-cover.alignfull:first-child,
-.single .entry-content.hide-post-and-page-titles > .wp-block-media-text.alignfull:first-child,
-.page .entry-content.hide-post-and-page-titles > .wp-block-media-text.alignfull:first-child,
-.single .entry-content.hide-post-and-page-titles > .wp-block-group.has-background.alignfull:first-child,
-.page .entry-content.hide-post-and-page-titles > .wp-block-group.has-background.alignfull:first-child {
+.single.hide-post-and-page-titles .entry-content > .wp-block-image.alignfull:first-child,
+.page.hide-post-and-page-titles .entry-content > .wp-block-image.alignfull:first-child,
+.single.hide-post-and-page-titles .entry-content > .wp-block-cover.alignfull:first-child,
+.page.hide-post-and-page-titles .entry-content > .wp-block-cover.alignfull:first-child,
+.single.hide-post-and-page-titles .entry-content > .wp-block-media-text.alignfull:first-child,
+.page.hide-post-and-page-titles .entry-content > .wp-block-media-text.alignfull:first-child,
+.single.hide-post-and-page-titles .entry-content > .wp-block-group.has-background.alignfull:first-child,
+.page.hide-post-and-page-titles .entry-content > .wp-block-group.has-background.alignfull:first-child {
 	margin-top: calc(-1 * var(--global--spacing-vertical));
 }
 
+/* Remove some bottom padding if the last block on the page is a full-width image, cover, media & text, or group block. */
+
+.page.hide-site-footer .entry-content > .wp-block-image.alignfull:last-child,
+.page.hide-site-footer .entry-content > .wp-block-cover.alignfull:last-child,
+.page.hide-site-footer .entry-content > .wp-block-media-text.alignfull:last-child,
+.single.hide-site-footer.hide-site-footer .entry-content > .wp-block-group.has-background.alignfull:last-child,
+.single.hide-site-footer.hide-comments .entry-content > .wp-block-image.alignfull:last-child,
+.single.hide-site-footer.hide-comments .entry-content > .wp-block-cover.alignfull:last-child,
+.single.hide-site-footer.hide-comments .entry-content > .wp-block-media-text.alignfull:last-child,
+.single.hide-site-footer.hide-comments .entry-content > .wp-block-group.has-background.alignfull:last-child {
+	margin-bottom: calc(-1 * var(--global--spacing-vertical));
+}
+
 /* Center-align headers and footers. */
 
 .entry-header,

+ 1 - 5
blank-canvas/template-parts/content/content-singular.php

@@ -26,11 +26,7 @@ $show_post_and_page_titles = get_theme_mod( 'show_post_and_page_titles', false )
 
 	<?php seedlet_post_thumbnail(); ?>
 
-	<div class="entry-content
-	<?php
-	if ( ! $show_post_and_page_titles ) :
-		?>
-		hide-post-and-page-titles<?php endif; ?>">
+	<div class="entry-content">
 		<?php
 		the_content(
 			sprintf(