<?php
/**
 * Blog Eye Block Patterns
 *
 * @package Blog Eye
 */

/**
 * Register block patterns and pattern categories
 */
function blog_eye_register_block_patterns() {
	
	// Register pattern category
	if (function_exists('register_block_pattern_category')) {
		register_block_pattern_category(
			'blog-eye',
			array('label' => esc_html__('Blog Eye', 'blog-eye'))
		);
	}

	// Register patterns
	if (function_exists('register_block_pattern')) {
		
		// Two column text pattern
		register_block_pattern(
			'blog-eye/two-column-text',
			array(
				'title'       => esc_html__('Two Column Text', 'blog-eye'),
				'description' => esc_html__('Two columns of text with a heading.', 'blog-eye'),
				'content'     => '<!-- wp:heading {"textAlign":"center"} -->
				<h2 class="has-text-align-center">' . esc_html__('Two Column Section', 'blog-eye') . '</h2>
				<!-- /wp:heading -->
				
				<!-- wp:columns -->
				<div class="wp-block-columns">
				<!-- wp:column -->
				<div class="wp-block-column">
				<!-- wp:paragraph -->
				<p>' . esc_html__('This is the first column of text. You can write about your services, products, or any content that fits your needs.', 'blog-eye') . '</p>
				<!-- /wp:paragraph -->
				</div>
				<!-- /wp:column -->
				
				<!-- wp:column -->
				<div class="wp-block-column">
				<!-- wp:paragraph -->
				<p>' . esc_html__('This is the second column of text. You can write about your services, products, or any content that fits your needs.', 'blog-eye') . '</p>
				<!-- /wp:paragraph -->
				</div>
				<!-- /wp:column -->
				</div>
				<!-- /wp:columns -->',
				'categories'  => array('blog-eye', 'columns'),
			)
		);

		// Featured content pattern
		register_block_pattern(
			'blog-eye/featured-content',
			array(
				'title'       => esc_html__('Featured Content', 'blog-eye'),
				'description' => esc_html__('A featured content section with image and text.', 'blog-eye'),
				'content'     => '<!-- wp:media-text {"mediaPosition":"right","mediaType":"image","verticalAlignment":"center"} -->
				<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center">
				<figure class="wp-block-media-text__media">
				<!-- wp:image -->
				<img src="' . esc_url(get_template_directory_uri() . '/assets/img/hero.jpg') . '" alt="' . esc_attr__('Featured Image', 'blog-eye') . '"/>
				<!-- /wp:image -->
				</figure>
				<div class="wp-block-media-text__content">
				<!-- wp:heading {"level":3} -->
				<h3>' . esc_html__('Featured Content Title', 'blog-eye') . '</h3>
				<!-- /wp:heading -->
				
				<!-- wp:paragraph -->
				<p>' . esc_html__('This is featured content that highlights important information about your blog, services, or products.', 'blog-eye') . '</p>
				<!-- /wp:paragraph -->
				
				<!-- wp:button -->
				<div class="wp-block-button">
				<a class="wp-block-button__link">' . esc_html__('Learn More', 'blog-eye') . '</a>
				</div>
				<!-- /wp:button -->
				</div>
				</div>
				<!-- /wp:media-text -->',
				'categories'  => array('blog-eye', 'featured'),
			)
		);

		// Call to action pattern
		register_block_pattern(
			'blog-eye/call-to-action',
			array(
				'title'       => esc_html__('Call to Action', 'blog-eye'),
				'description' => esc_html__('A centered call to action section.', 'blog-eye'),
				'content'     => '<!-- wp:group {"align":"full","style":{"color":{"background":"#f8f9fa"}},"layout":{"type":"constrained"}} -->
				<div class="wp-block-group alignfull has-background" style="background-color:#f8f9fa">
				<!-- wp:spacer {"height":"40px"} -->
				<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>
				<!-- /wp:spacer -->
				
				<!-- wp:heading {"textAlign":"center","level":2} -->
				<h2 class="has-text-align-center">' . esc_html__('Ready to Get Started?', 'blog-eye') . '</h2>
				<!-- /wp:heading -->
				
				<!-- wp:paragraph {"align":"center"} -->
				<p class="has-text-align-center">' . esc_html__('Join thousands of satisfied customers and take your business to the next level.', 'blog-eye') . '</p>
				<!-- /wp:paragraph -->
				
				<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
				<div class="wp-block-buttons">
				<!-- wp:button {"backgroundColor":"strong-blue","textColor":"white"} -->
				<div class="wp-block-button">
				<a class="wp-block-button__link has-white-color has-strong-blue-background-color has-text-color has-background">' . esc_html__('Get Started Now', 'blog-eye') . '</a>
				</div>
				<!-- /wp:button -->
				</div>
				<!-- /wp:buttons -->
				
				<!-- wp:spacer {"height":"40px"} -->
				<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>
				<!-- /wp:spacer -->
				</div>
				<!-- /wp:group -->',
				'categories'  => array('blog-eye', 'call-to-action'),
			)
		);

		// Blog post grid pattern
		register_block_pattern(
			'blog-eye/blog-grid',
			array(
				'title'       => esc_html__('Blog Post Grid', 'blog-eye'),
				'description' => esc_html__('A grid layout for displaying blog posts.', 'blog-eye'),
				'content'     => '<!-- wp:heading {"textAlign":"center"} -->
				<h2 class="has-text-align-center">' . esc_html__('Latest Blog Posts', 'blog-eye') . '</h2>
				<!-- /wp:heading -->
				
				<!-- wp:latest-posts {"postsToShow":6,"displayPostContent":true,"excerptLength":15,"displayPostDate":true,"postLayout":"grid","columns":3,"displayFeaturedImage":true,"featuredImageAlign":"top","featuredImageSizeSlug":"medium"} /-->',
				'categories'  => array('blog-eye', 'posts'),
			)
		);
	}
}
add_action('init', 'blog_eye_register_block_patterns');

/**
 * Remove core block patterns if needed
 */
function blog_eye_remove_core_patterns() {
	// Uncomment below to remove all core patterns
	// remove_theme_support('core-block-patterns');
}
add_action('after_setup_theme', 'blog_eye_remove_core_patterns');
