<?php
/**
 * Adds the Site Style section and its fields to the General Settings panel.
 * This section allows users to configure the site's overall style settings.
 * 
 * @package Yaatra
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_action( 'customize_register', 'yaatra_register_site_style_options' );

if ( ! function_exists( 'yaatra_register_site_style_options' ) ) :

    /**
     * Registers theme options for the Site Style section in the WordPress Customizer.
     * 
     * Adds and configures settings related to the site's appearance, such as colors and fonts.
     * 
     * @param WP_Customize_Manager $wp_customize The Customizer object responsible for managing theme options.
     * @since 1.0.0
     */
    function yaatra_register_site_style_options( $wp_customize ) {

        /*
         * Failsafe is safe
         */
        if ( ! isset( $wp_customize ) ) {
            return;
        }

        /**
         * Add Site Style Section
         * 
         * General Settings > Site Style
         * 
         * @uses $wp_customize->add_section() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/
         * @since 1.0.0
         */
        $wp_customize->add_section( new Yaatra_Customize_Section (
            $wp_customize, 'yaatra_section_site_style',
                array(
                    'priority'  => 10,
                    'panel'     => 'yaatra_panel_general',
                    'title'     => __( 'Site Style', 'yaatra' ),
                )
            )
        );

       
        /**
         * Radio image field for site layout
         *
         * General Settings > Site Style
         *
         * @since 1.5.0
         */
        
        $wp_customize->add_setting( 'yaatra_site_layout',
            array(
                'default'           => yaatra_get_customizer_default( 'yaatra_site_layout' ),
                'sanitize_callback' => 'yaatra_sanitize_select',
            )
        );
        $wp_customize->add_control( new Yaatra_Control_Radio_Image(
            $wp_customize, 'yaatra_site_layout',
                array(
                    'priority'      => 10,
                    'section'       => 'yaatra_section_site_style',
                    'settings'      => 'yaatra_site_layout',
                    'label'         => __( 'Site Layout', 'yaatra' ),
                    'choices'       => yaatra_site_layout_choices(),
                )
            )
        );

           
        /**
         * Toggle option for wow animation
         *
         * General Settings > Site Style
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'yaatra_wow_option',
            array(
                'default'           => yaatra_get_customizer_default( 'yaatra_wow_option' ),
                'sanitize_callback' => 'yaatra_sanitize_checkbox'
            )
        );
        $wp_customize->add_control( new Yaatra_Control_Toggle(
            $wp_customize, 'yaatra_wow_option',
                array(
                    'priority'      => 20,
                    'section'       => 'yaatra_section_site_style',
                    'settings'      => 'yaatra_wow_option',
                    'label'         => __( 'Enable WoW Animation', 'yaatra' ),
                    'description'   => __( 'Use this setting to manage the WoW animation, providing lively transitions and visual flair to keep your audience engaged.', 'yaatra' ),
                )
            )
        );

        /**
         * Upgrade field for site style section
         * 
         * General Settings > Site Style
         *
         * @since 1.2.0
         */ 
        $wp_customize->add_setting( 'upgrade_site_style',
            array(
                'sanitize_callback' => 'sanitize_text_field'
            )
        );
        $wp_customize->add_control( new Yaatra_Control_Upgrade(
            $wp_customize, 'upgrade_site_style',
                array(
                    'priority'      => 70,
                    'section'       => 'yaatra_section_site_style',
                    'settings'      => 'upgrade_site_style',
                    'label'         => __( 'More features with Yaatra Pro', 'yaatra' ),
                    'choices'       => yaatra_upgrade_choices( 'yaatra_site_style' )
                )
            )
        );

    }

endif;