<?php
/**
 * Templazee functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Templazee
 * @since Templazee 1.0
 */

if ( ! function_exists( 'templazee_setup' ) ) : 

    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * This function is hooked into the `after_setup_theme` hook, which runs before the `init` hook.
     * The `init` hook is too late for some features, such as indicating support for post thumbnails.
     * Here, we define theme features such as support for feed links, wide alignment, block navigation menus, etc.
     *
     * @since Templazee 1.0
     */
    function templazee_setup() {

        // Enable automatic feed links for RSS feed support
        add_theme_support( 'automatic-feed-links' );

        // Enable wide align support for blocks (e.g., images, videos)
        add_theme_support( 'align-wide' );

        // Enable block-based navigation menus
        add_theme_support( 'block-nav-menus' );

        // Enable experimental link color feature (to customize link color in editor)
        add_theme_support( 'experimental-link-color' );

        // Add editor stylesheet for the block editor
        add_editor_style('style.css');
    }
endif;
add_action( 'after_setup_theme', 'templazee_setup' );

if ( !function_exists( 'templazee_front_styles' ) ) {
    /**
     * Enqueue styles for the front-end of the theme
     *
     * This function ensures that the main stylesheet (style.css) is loaded on the front-end of the site.
     *
     * @since Templazee 1.0
     * @return void
     */
    function templazee_front_styles(){
        // Enqueue the main stylesheet with the correct version based on the theme's version
        wp_enqueue_style( 'templazee-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
    }
}

add_action( 'wp_enqueue_scripts', 'templazee_front_styles' );

/**
 * Register pattern categories
 *
 * This section is for registering custom block pattern categories.
 * A block pattern category is used to group together a collection of predefined block patterns for easier use within the editor.
 */
if ( ! function_exists( 'templazee_pattern_categories' ) ) :
    /**
     * Register pattern categories
     *
     * @since Templazee 1.0
     * @return void
     */
    function templazee_pattern_categories() {

        // Register a custom category for block patterns
        register_block_pattern_category(
            'templazee', // Category slug (used for internal reference)
            array(
                'label'       => __( 'Templazee Patterns', 'templazee' ), // Display name for the category
                'description' => __( 'A collection of pre-built patterns.', 'templazee' ), // Category description
            )
        );
    }
endif;

add_action( 'init', 'templazee_pattern_categories' );

require get_template_directory() . '/tgm-plugin/tgm-hook.php';