<?php
/**
 * Register block patterns for CyyWordpress.
 *
 * @package CyyWordpress
 */

if ( ! function_exists( 'cyywordpress_register_block_patterns' ) ) :
	/**
	 * Register all theme block patterns.
	 */
	function cyywordpress_register_block_patterns(): void {
		// Register pattern category.
		register_block_pattern_category(
			'cyywordpress',
			array( 'label' => esc_html__( 'CyyWordpress', 'cyywordpress' ) )
		);

		// Load pattern files.
		$pattern_files = array(
			'hero-banner',
			'post-card-grid',
			'cta-section',
		);

		foreach ( $pattern_files as $pattern ) {
			$file = get_template_directory() . "/patterns/{$pattern}.php";
			if ( file_exists( $file ) ) {
				require $file;
			}
		}
	}
endif;
add_action( 'init', 'cyywordpress_register_block_patterns' );
