Explorar o código

Blank Canvas: Even out footer spacing

Kjell Reigstad %!s(int64=4) %!d(string=hai) anos
pai
achega
3fb27a0abc

+ 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' );

+ 26 - 0
blank-canvas/style.css

@@ -78,3 +78,29 @@ Used as block pattern image.
 .footer-menu {
 	text-align: center;
 }
+
+/* Remove some top padding if the first block on the page is a full-width image, cover, media & text, or group block. */
+
+.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));
+}

+ 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(