<?php

/**
 * Block Patterns and Styles
 *
 * @package AgencyX Blog
 */

/**
 * Register Block Patterns and categories
 */
function agencyx_blog_register_block_patterns()
{
    if (! function_exists('register_block_pattern_category')) {
        return;
    }

    // Register block pattern category
    register_block_pattern_category(
        'agencyx-blog',
        array('label' => __('AgencyX Blog', 'agencyx-blog'))
    );

    // Register block patterns
    register_block_pattern(
        'agencyx-blog/hero-section',
        array(
            'title'       => __('Hero Section', 'agencyx-blog'),
            'description' => __('A hero section with heading, text, and buttons', 'agencyx-blog'),
            'categories'  => array('agencyx-blog'),
            'content'     => '<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|60"}}},"backgroundColor":"background","layout":{"type":"constrained"}} -->
                            <div class="wp-block-group alignfull has-background-background-color has-background" style="padding-top:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60)">
                                <!-- wp:heading {"textAlign":"center","level":1} -->
                                <h1 class="wp-block-heading has-text-align-center">' . __('Welcome to AgencyX Blog', 'agencyx-blog') . '</h1>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph {"align":"center"} -->
                                <p class="has-text-align-center">' . __('Create beautiful and engaging content with our customizable blocks.', 'agencyx-blog') . '</p>
                                <!-- /wp:paragraph -->
                            </div>
                            <!-- /wp:group -->'
        )
    );
}
add_action('init', 'agencyx_blog_register_block_patterns');

/**
 * Register Block Styles
 */
function agencyx_blog_register_block_styles()
{
    // Register block style for quote block
    register_block_style(
        'core/quote',
        array(
            'name'         => 'agencyx-fancy-quote',
            'label'        => __('Fancy Quote', 'agencyx-blog'),
            'is_default'   => false,
        )
    );

    // Register block style for button block
    register_block_style(
        'core/button',
        array(
            'name'         => 'agencyx-button-outline',
            'label'        => __('Outline Style', 'agencyx-blog'),
            'is_default'   => false,
        )
    );
}
add_action('init', 'agencyx_blog_register_block_styles');
