<?php
/**
 * Theme Customizer Controls
 *
 * @package Unique Gift Shop
 */

if ( ! function_exists( 'unique_gift_shop_customizer_page_register' ) ) :
function unique_gift_shop_customizer_page_register( $wp_customize ) {
 
 	$wp_customize->add_section(
        'unique_gift_shop_page_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__( 'Page Settings', 'unique-gift-shop' )
        )
    );

    // Info label
     $wp_customize->add_setting( 
        'unique_gift_shop_label_page_title_hide_settings', 
        array(
            'sanitize_callback' => 'unique_gift_shop_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Unique_Gift_Shop_Title_Info_Control( $wp_customize, 'unique_gift_shop_label_page_title_hide_settings', 
        array(
            'label'       => esc_html__( 'Hide Page Title', 'unique-gift-shop' ),
            'section'     => 'unique_gift_shop_page_settings',
            'type'        => 'unique-gift-shop-title',
            'settings'    => 'unique_gift_shop_label_page_title_hide_settings',
        ) 
    ));  

    // Hide page title section
    $wp_customize->add_setting(
        'unique_gift_shop_enable_page_title',
        array(
            'type' => 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'unique_gift_shop_sanitize_checkbox'
        )
    );

    $wp_customize->add_control(
        new Unique_Gift_Shop_Toggle_Control( $wp_customize, 'unique_gift_shop_enable_page_title', 
        array(
            'settings'      => 'unique_gift_shop_enable_page_title',
            'section'       => 'unique_gift_shop_page_settings',
            'type'          => 'unique-gift-shop-toggle',
            'label'         => esc_html__( 'Show Page Title Section:', 'unique-gift-shop' ),
            'description'   => '',           
        )
    ));

    // Info label
    $wp_customize->add_setting( 
        'unique_gift_shop_label_page_title_bg_settings', 
        array(
            'sanitize_callback' => 'unique_gift_shop_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Unique_Gift_Shop_Title_Info_Control( $wp_customize, 'unique_gift_shop_label_page_title_bg_settings', 
        array(
            'label'       => esc_html__( 'Page Title Background', 'unique-gift-shop' ),
            'section'     => 'unique_gift_shop_page_settings',
            'type'        => 'title',
            'settings'    => 'unique_gift_shop_label_page_title_bg_settings',
            'active_callback' => 'unique_gift_shop_page_title_enable',
        ) 
    ));

    // Background selection
    $wp_customize->add_setting(
        'unique_gift_shop_page_bg_radio',
        array(
            'type' => 'theme_mod',
            'default'           => 'color',
            'sanitize_callback' => 'unique_gift_shop_sanitize_select'
        )
    );

    $wp_customize->add_control(
    	new Unique_Gift_Shop_Text_Radio_Control( $wp_customize, 'unique_gift_shop_page_bg_radio',
        array(
            'settings'      => 'unique_gift_shop_page_bg_radio',
            'section'       => 'unique_gift_shop_page_settings',
            'type'          => 'radio',
            'label'         => esc_html__( 'Choose Page Title Background Color or Background Image:', 'unique-gift-shop' ),
            'description'   => esc_html__('This setting will change the background of the page title area.', 'unique-gift-shop'),
            'choices' => array(
                            'color' => esc_html__('Background Color','unique-gift-shop'),
                            'image' => esc_html__('Background Image','unique-gift-shop'),
                            ),
            'active_callback' => 'unique_gift_shop_page_title_enable',
        )
    ));

    // Background color
    $wp_customize->add_setting(
        'unique_gift_shop_page_bg_color',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'sanitize_hex_color'
        )
    );

    $wp_customize->add_control(
        new WP_Customize_Color_Control(
            $wp_customize,
            'unique_gift_shop_page_bg_color',
            array(
                'label'      => esc_html__( 'Select Background Color', 'unique-gift-shop' ),
                'description'   => esc_html__('This setting will add background color to the page title area if Background Color was selected above.', 'unique-gift-shop'),
                'section'    => 'unique_gift_shop_page_settings',
                'settings'   => 'unique_gift_shop_page_bg_color',
                'active_callback' => 'unique_gift_shop_page_title_color_enable',
            )
        )
    );  

     // Background image
    $wp_customize->add_setting(
        'unique_gift_shop_page_bg_image',
        array(
            'type' => 'theme_mod',
            'sanitize_callback' => 'esc_url_raw'
        )
    );

    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize,
            'unique_gift_shop_page_bg_image',
            array(
                'label'       => esc_html__( 'Upload Background Image', 'unique-gift-shop' ),
                'description' => esc_html__('This setting will add a background image to the page title area if Background Image was selected above.', 'unique-gift-shop'),
                'section'     => 'unique_gift_shop_page_settings',
                'settings'    => 'unique_gift_shop_page_bg_image',
                'active_callback' => 'unique_gift_shop_page_title_image_enable',
            )
        )
    );  
}
endif;

add_action( 'customize_register', 'unique_gift_shop_customizer_page_register' );