<?php
/**
 * Theme Customizer Controls
 *
 * @package Jungle Eco Tours
 */

if ( ! function_exists( 'jungle_eco_tours_customizer_home_banner_register' ) ) :
function jungle_eco_tours_customizer_home_banner_register( $wp_customize ) {
 	
 	$wp_customize->add_section(
        'jungle_eco_tours_home_banner_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__( 'Banner Settings', 'jungle-eco-tours' )
        )
    );

    // Title label
	$wp_customize->add_setting( 
		'jungle_eco_tours_label_banner_settings_title', 
		array(
		    'sanitize_callback' => 'jungle_eco_tours_sanitize_title',
		) 
	);

	$wp_customize->add_control( 
		new Jungle_Eco_Tours_Title_Info_Control( $wp_customize, 'jungle_eco_tours_label_banner_settings_title', 
		array(
		    'label'       => esc_html__( 'Banner Settings', 'jungle-eco-tours' ),
		    'section'     => 'jungle_eco_tours_home_banner_settings',
		    'type'        => 'jungle-eco-tours-title',
		    'settings'    => 'jungle_eco_tours_label_banner_settings_title',
		) 
	));

     $wp_customize->add_setting('jungle_eco_tours_slider_increase',array(
        'default' => '',
        'sanitize_callback' => 'jungle_eco_tours_sanitize_number',
    ));
    $wp_customize->add_control('jungle_eco_tours_slider_increase',array(
        'label' => __('Number of slides to show','jungle-eco-tours'),
        'section' => 'jungle_eco_tours_home_banner_settings',
        'type'    => 'number'
    ));
      $jungle_eco_tours_banner_count =  get_theme_mod('jungle_eco_tours_slider_increase');

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

    $wp_customize->add_setting(
        'jungle_eco_tours_banner_image'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'jungle_eco_tours_sanitize_image',

        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize, 'jungle_eco_tours_banner_image'.$i, 
            array(
                'label'           => sprintf( esc_html__( 'Banner Image', 'jungle-eco-tours' ).$i, ),
                'settings'  => 'jungle_eco_tours_banner_image'.$i,
                'section'   => 'jungle_eco_tours_home_banner_settings'
            ) 
        )
    );

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

    $wp_customize->add_control(
        'jungle_eco_tours_banner_small_head'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Small Heading', 'jungle-eco-tours' ).$i, ),
            'section'         => 'jungle_eco_tours_home_banner_settings',
            'settings'        => 'jungle_eco_tours_banner_small_head'.$i ,
            'type'            => 'text',
        )
    );

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

    $wp_customize->add_control(
        'jungle_eco_tours_banner_heading'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Heading', 'jungle-eco-tours' ).$i, ),
            'section'         => 'jungle_eco_tours_home_banner_settings',
            'settings'        => 'jungle_eco_tours_banner_heading'.$i ,
            'type'            => 'text',
        )
    );

    // banner Button
    $wp_customize->add_setting(
        'jungle_eco_tours_banner_button_link'.$i,
        array(
            'default'           => '',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'jungle_eco_tours_banner_button_link'.$i,
        array(
            'label'           => sprintf( esc_html__( 'Banner Button Link', 'jungle-eco-tours' ).$i, ),
            'section'         => 'jungle_eco_tours_home_banner_settings',
            'settings'        => 'jungle_eco_tours_banner_button_link'.$i ,
            'type'            => 'url',
        )
    );

}

    // Slider Content Alignment Setting
    $wp_customize->add_setting(
        'jungle_eco_tours_slider_content_alignment',
        array(
            'default'           => 'left',
            'sanitize_callback' => 'jungle_eco_tours_sanitize_select',
        )
    );

    $wp_customize->add_control(
        'jungle_eco_tours_slider_content_alignment',
        array(
            'label'    => esc_html__( 'Slider Content Alignment', 'jungle-eco-tours' ),
            'section'  => 'jungle_eco_tours_home_banner_settings',
            'settings' => 'jungle_eco_tours_slider_content_alignment',
            'type'     => 'select',
            'choices'  => array(
                'left'   => esc_html__( 'Left', 'jungle-eco-tours' ),
                'center' => esc_html__( 'Center', 'jungle-eco-tours' ),
                'right'  => esc_html__( 'Right', 'jungle-eco-tours' ),
            ),
        )
    );    
}
endif;

add_action( 'customize_register', 'jungle_eco_tours_customizer_home_banner_register' );