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


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

    // Title label
	$wp_customize->add_setting( 
		'unique_gift_shop_label_banner_settings_title', 
		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_banner_settings_title', 
		array(
		    'label'       => esc_html__( 'Banner Settings', 'unique-gift-shop' ),
		    'section'     => 'unique_gift_shop_home_banner_settings',
		    'type'        => 'unique-gift-shop-title',
		    'settings'    => 'unique_gift_shop_label_banner_settings_title',
		) 
	));

    $wp_customize->add_setting('unique_gift_shop_banner_slider_increase',array(
        'default' => '',
        'sanitize_callback' => 'unique_gift_shop_sanitize_number',
    ));
    $wp_customize->add_control('unique_gift_shop_banner_slider_increase',array(
        'label' => __('Number of slides to show','unique-gift-shop'),
        'section' => 'unique_gift_shop_home_banner_settings',
        'type'    => 'number'
    ));
      $unique_gift_shop_banner_count =  get_theme_mod('unique_gift_shop_banner_slider_increase');

        for($i=1; $i<=$unique_gift_shop_banner_count; $i++ ) {  

    // Button Image
    $wp_customize->add_setting(
        'unique_gift_shop_banner_image'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'unique_gift_shop_sanitize_image',

        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize, 'unique_gift_shop_banner_image'.$i, 
            array(
                'label'           => sprintf( esc_html__( 'Banner Image', 'unique-gift-shop' ).$i, ),
                'settings'  => 'unique_gift_shop_banner_image'.$i,
                'section'   => 'unique_gift_shop_home_banner_settings'
            ) 
        )
    );

    // Banner Heading
	$wp_customize->add_setting(
        'unique_gift_shop_banner_heading'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_banner_heading'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Heading', 'unique-gift-shop' ).$i, ),
            'section'         => 'unique_gift_shop_home_banner_settings',
            'settings'        => 'unique_gift_shop_banner_heading'.$i ,
            'type'            => 'text',
        )
    );

    $wp_customize->add_setting(
        'unique_gift_shop_banner_text'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_banner_text'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Text', 'unique-gift-shop' ).$i, ),
            'section'         => 'unique_gift_shop_home_banner_settings',
            'settings'        => 'unique_gift_shop_banner_text'.$i ,
            'type'            => 'text',
        )
    );

    $wp_customize->add_setting(
        'unique_gift_shop_banner_button_link'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_banner_button_link'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Button Link', 'unique-gift-shop' ).$i, ),
            'section'         => 'unique_gift_shop_home_banner_settings',
            'settings'        => 'unique_gift_shop_banner_button_link'.$i ,
            'type'            => 'url',
        )
    );

    $wp_customize->add_setting(
        'unique_gift_shop_banner_ri8_text1'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_banner_ri8_text1'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Right Text 1', 'unique-gift-shop' ), ),
            'section'         => 'unique_gift_shop_home_banner_settings',
            'settings'        => 'unique_gift_shop_banner_ri8_text1'.$i ,
            'type'            => 'text',
        )
    );

    $wp_customize->add_setting(
        'unique_gift_shop_banner_ri8_text2'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_banner_ri8_text2'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Right Text 2', 'unique-gift-shop' ), ),
            'section'         => 'unique_gift_shop_home_banner_settings',
            'settings'        => 'unique_gift_shop_banner_ri8_text2'.$i ,
            'type'            => 'text',
        )
    );
    
    }

// Slider Content Alignment Setting
    $wp_customize->add_setting(
        'unique_gift_shop_slider_content_alignment',
        array(
            'default'           => 'center',
            'sanitize_callback' => 'unique_gift_shop_sanitize_select',
        )
    );

    $wp_customize->add_control(
        'unique_gift_shop_slider_content_alignment',
        array(
            'label'    => esc_html__( 'Slider Content Alignment', 'unique-gift-shop' ),
            'section'  => 'unique_gift_shop_home_banner_settings',
            'settings' => 'unique_gift_shop_slider_content_alignment',
            'type'     => 'select',
            'choices'  => array(
                'left'   => esc_html__( 'Left', 'unique-gift-shop' ),
                'center' => esc_html__( 'Center', 'unique-gift-shop' ),
                'right'  => esc_html__( 'Right', 'unique-gift-shop' ),
            ),
        )
    );
}
endif;

add_action( 'customize_register', 'unique_gift_shop_customizer_home_banner_register' );