<?php
/**
 * Block patterns and block styles.
 *
 * Registered on init. Registering at file scope runs before init and forces
 * an early text domain load, which WordPress 6.7 and later report through
 * _load_textdomain_just_in_time as doing_it_wrong.
 *
 * @package Intimate
 */

if ( ! function_exists( 'intimate_register_block_patterns' ) ) :

	/**
	 * Register the theme's block patterns.
	 */
	function intimate_register_block_patterns() {

		if ( ! function_exists( 'register_block_pattern' ) ) {
			return;
		}

		if ( function_exists( 'register_block_pattern_category' ) ) {
			register_block_pattern_category( 'intimate', array( 'label' => __( 'Intimate', 'intimate' ) ) );
		}

		register_block_pattern(
			'intimate/lead-paragraph',
			array(
				'title'       => __( 'Heading with lead paragraph', 'intimate' ),
				'categories'  => array( 'intimate', 'text' ),
				'description' => __( 'A section heading followed by an introductory paragraph.', 'intimate' ),
				'content'     => '<!-- wp:heading {"level":2} --><h2>' . esc_html__( 'A section heading', 'intimate' ) . '</h2><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'Open the story with a sentence or two that gives the reader a reason to keep going.', 'intimate' ) . '</p><!-- /wp:paragraph -->',
			)
		);

		register_block_pattern(
			'intimate/pull-quote',
			array(
				'title'       => __( 'Accent pull quote', 'intimate' ),
				'categories'  => array( 'intimate', 'text' ),
				'description' => __( 'A quotation set off from the surrounding copy.', 'intimate' ),
				'content'     => '<!-- wp:quote {"className":"is-style-intimate-accent"} --><blockquote class="wp-block-quote is-style-intimate-accent"><p>' . esc_html__( 'A short line worth quoting.', 'intimate' ) . '</p></blockquote><!-- /wp:quote -->',
			)
		);

		register_block_pattern(
			'intimate/three-column-highlights',
			array(
				'title'       => __( 'Three column highlights', 'intimate' ),
				'categories'  => array( 'intimate', 'columns' ),
				'description' => __( 'Three short blurbs side by side, in the style of the highlights section.', 'intimate' ),
				'content'     => '<!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":3} --><h3>' . esc_html__( 'First', 'intimate' ) . '</h3><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'A sentence of detail.', 'intimate' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":3} --><h3>' . esc_html__( 'Second', 'intimate' ) . '</h3><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'A sentence of detail.', 'intimate' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:heading {"level":3} --><h3>' . esc_html__( 'Third', 'intimate' ) . '</h3><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'A sentence of detail.', 'intimate' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --></div><!-- /wp:columns -->',
			)
		);
	}
endif;
add_action( 'init', 'intimate_register_block_patterns' );

if ( ! function_exists( 'intimate_register_block_styles' ) ) :

	/**
	 * Register the theme's block styles.
	 */
	function intimate_register_block_styles() {

		if ( ! function_exists( 'register_block_style' ) ) {
			return;
		}

		register_block_style(
			'core/quote',
			array( 'name' => 'intimate-accent', 'label' => __( 'Accent border', 'intimate' ) )
		);

		register_block_style(
			'core/image',
			array( 'name' => 'intimate-rounded', 'label' => __( 'Rounded', 'intimate' ) )
		);

		register_block_style(
			'core/button',
			array( 'name' => 'intimate-outline', 'label' => __( 'Outline', 'intimate' ) )
		);
	}
endif;
add_action( 'init', 'intimate_register_block_styles' );
