Browse Source

Archeo: Headline over dark image pattern (#5464)

* block patterns bootstrap

* headline pattern

* changed image

* Add alt text

Co-authored-by: Ben Dwyer <ben@scruffian.com>
Maggie 3 năm trước cách đây
mục cha
commit
2b8513ffd0

BIN
archeo/assets/images/uxmal.jpg


+ 1 - 1
archeo/functions.php

@@ -177,5 +177,5 @@ endif;
 add_action( 'wp_head', 'archeo_preload_webfonts' );
 add_action( 'wp_head', 'archeo_preload_webfonts' );
 
 
 // Add block patterns
 // Add block patterns
-// require get_template_directory() . '/inc/block-patterns.php';
+require get_template_directory() . '/inc/block-patterns.php';
 
 

+ 65 - 0
archeo/inc/block-patterns.php

@@ -0,0 +1,65 @@
+<?php
+/**
+ * archeo: Block Patterns
+ *
+ * @since archeo 1.0
+ */
+
+/**
+ * Registers block patterns and categories.
+ *
+ * @since archeo 1.0
+ *
+ * @return void
+ */
+function archeo_register_block_patterns() {
+	$block_pattern_categories = array(
+		'pages'    => array( 'label' => __( 'Pages', 'archeo' ) ),
+	);
+
+	/**
+	 * Filters the theme block pattern categories.
+	 *
+	 * @since archeo 1.0
+	 *
+	 * @param array[] $block_pattern_categories {
+	 *     An associative array of block pattern categories, keyed by category name.
+	 *
+	 *     @type array[] $properties {
+	 *         An array of block category properties.
+	 *
+	 *         @type string $label A human-readable label for the pattern category.
+	 *     }
+	 * }
+	 */
+	$block_pattern_categories = apply_filters( 'archeo_block_pattern_categories', $block_pattern_categories );
+
+	foreach ( $block_pattern_categories as $name => $properties ) {
+		if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
+			register_block_pattern_category( $name, $properties );
+		}
+	}
+
+	$block_patterns = array(
+		'headline-over-dark-image',
+	);
+
+	/**
+	 * Filters the theme block patterns.
+	 *
+	 * @since archeo 1.0
+	 *
+	 * @param array $block_patterns List of block patterns by name.
+	 */
+	$block_patterns = apply_filters( 'archeo_block_patterns', $block_patterns );
+
+	foreach ( $block_patterns as $block_pattern ) {
+		$pattern_file = get_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' );
+
+		register_block_pattern(
+			'archeo/' . $block_pattern,
+			require $pattern_file
+		);
+	}
+}
+add_action( 'init', 'archeo_register_block_patterns', 9 );

+ 13 - 0
archeo/inc/patterns/headline-over-dark-image.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Headline over dark image
+ */
+return array(
+	'title'      => __( 'Headline over dark image', 'archeo' ),
+	'categories' => array( 'pages' ),
+	'content'    => '<!-- wp:cover {"url":"' . esc_url( get_template_directory_uri() ) . '/assets/images/uxmal.jpg","dimRatio":80,"overlayColor":"foreground","minHeight":100,"minHeightUnit":"vh","contentPosition":"bottom left","align":"full"} -->
+	<div class="wp-block-cover alignfull has-custom-content-position is-position-bottom-left" style="min-height:100vh"><span aria-hidden="true" class="has-foreground-background-color has-background-dim-80 wp-block-cover__gradient-background has-background-dim"></span><img class="wp-block-cover__image-background" alt="' . esc_attr__( 'Photo of the Governor\'s Palace at Uxmal', 'archeo' ) . '" src="' . esc_url( get_template_directory_uri() ) . '/assets/images/uxmal.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"left","placeholder":"Write title…","style":{"typography":{"textTransform":"uppercase","fontStyle":"normal","fontWeight":"100","lineHeight":"1"}},"textColor":"white","fontSize":"huge"} -->
+	<p class="has-text-align-left has-white-color has-text-color has-huge-font-size" style="font-style:normal;font-weight:100;line-height:1;text-transform:uppercase">' . wp_kses_post( __( 'Palais Du <br>Gouverneur, <br>à Uxmal, <br>detail de la <br>Porte Principale', 'archeo' ) ) . '</p>
+	<!-- /wp:paragraph --></div></div>
+	<!-- /wp:cover -->',
+);

+ 10 - 0
archeo/theme.json

@@ -49,6 +49,16 @@
 			"contentSize": "620px",
 			"contentSize": "620px",
 			"wideSize": "1260px"
 			"wideSize": "1260px"
 		},
 		},
+		"spacing": {
+			"units": [
+				"%",
+				"px",
+				"em",
+				"rem",
+				"vh",
+				"vw"
+			]
+		},
 		"typography": {
 		"typography": {
 			"fontFamilies": [
 			"fontFamilies": [
 				{
 				{