<?php
/**
 * Block patterns and block styles.
 *
 * Registered on init. Registering at file scope would run before init and
 * force an early text domain load, which WordPress 6.7 and later report as
 * doing_it_wrong.
 *
 * @package Opus_Blog
 */

function opus_blog_register_block_patterns() {

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

	if ( function_exists( 'register_block_pattern_category' ) ) {
		register_block_pattern_category( 'opus-blog', array( 'label' => __( 'Opus Blog', 'opus-blog' ) ) );
	}

	register_block_pattern(
		'opus-blog/intro',
		array(
			'title'       => __( 'Intro heading and text', 'opus-blog' ),
			'categories'  => array( 'opus-blog', 'text' ),
			'description' => __( 'A large heading with a paragraph beneath it.', 'opus-blog' ),
			'content'     => '<!-- wp:heading {"level":2} --><h2>' . esc_html__( 'Welcome', 'opus-blog' ) . '</h2><!-- /wp:heading --><!-- wp:paragraph --><p>' . esc_html__( 'Introduce the post in a sentence or two.', 'opus-blog' ) . '</p><!-- /wp:paragraph -->',
		)
	);

	register_block_pattern(
		'opus-blog/quote-callout',
		array(
			'title'       => __( 'Pull quote callout', 'opus-blog' ),
			'categories'  => array( 'opus-blog', 'text' ),
			'description' => __( 'A quotation set off from the surrounding copy.', 'opus-blog' ),
			'content'     => '<!-- wp:quote {"className":"is-style-opus-blog-bordered"} --><blockquote class="wp-block-quote is-style-opus-blog-bordered"><p>' . esc_html__( 'A short, quotable line.', 'opus-blog' ) . '</p></blockquote><!-- /wp:quote -->',
		)
	);

	register_block_pattern(
		'opus-blog/two-columns',
		array(
			'title'       => __( 'Two column text', 'opus-blog' ),
			'categories'  => array( 'opus-blog', 'columns' ),
			'description' => __( 'Two columns of body copy side by side.', 'opus-blog' ),
			'content'     => '<!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p>' . esc_html__( 'First column.', 'opus-blog' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p>' . esc_html__( 'Second column.', 'opus-blog' ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --></div><!-- /wp:columns -->',
		)
	);
}
add_action( 'init', 'opus_blog_register_block_patterns' );

function opus_blog_register_block_styles() {

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

	register_block_style( 'core/quote', array( 'name' => 'opus-blog-bordered', 'label' => __( 'Bordered', 'opus-blog' ) ) );
	register_block_style( 'core/image', array( 'name' => 'opus-blog-rounded', 'label' => __( 'Rounded', 'opus-blog' ) ) );
	register_block_style( 'core/button', array( 'name' => 'opus-blog-outline', 'label' => __( 'Outline', 'opus-blog' ) ) );
}
add_action( 'init', 'opus_blog_register_block_styles' );
