<?php
/**
 * Slider Section options
 *
 * @package Theme Palace
 * @subpackage Ultravel
 * @since Ultravel 1.0.0
 */

// Add Slider section
$wp_customize->add_section( 'ultravel_hero_slider_section', array(
	'title'             => esc_html__( 'Hero Slider','ultravel' ),
	'description'       => esc_html__( 'Slider Section options.', 'ultravel' ),
	'panel'             => 'ultravel_front_page_panel',
) );

// Slider content enable control and setting
$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_section_enable]', array(
	'default'			=> 	$options['hero_slider_section_enable'],
	'sanitize_callback' => 'ultravel_sanitize_switch_control',
) );

$wp_customize->add_control( new Ultravel_Switch_Control( $wp_customize, 'ultravel_theme_options[hero_slider_section_enable]', array(
	'label'             => esc_html__( 'Slider Section Enable', 'ultravel' ),
	'section'           => 'ultravel_hero_slider_section',
	'on_off_label' 		=> ultravel_switch_options(),
) ) );

// hero_slider subtitle setting and control
$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['hero_slider_title'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'ultravel_theme_options[hero_slider_title]', array(
	'label'           	=> esc_html__( 'Title', 'ultravel' ),
	'section'        	=> 'ultravel_hero_slider_section',
	'active_callback' 	=> 'ultravel_is_hero_slider_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'ultravel_theme_options[hero_slider_title]', array(
		'selector'            => '#ultravel_hero_slider_section h2.section-title',
		'settings'            => 'ultravel_theme_options[hero_slider_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'ultravel_hero_slider_title_partial',
    ) );
}

// Slider content enable control and setting
$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_autoplay]', array(
	'default'			=> 	$options['hero_slider_autoplay'],
	'sanitize_callback' => 'ultravel_sanitize_switch_control',
) );

$wp_customize->add_control( new Ultravel_Switch_Control( $wp_customize, 'ultravel_theme_options[hero_slider_autoplay]', array(
	'label'             => esc_html__( 'Auto Play Enable', 'ultravel' ),
	'section'           => 'ultravel_hero_slider_section',
	'on_off_label' 		=> ultravel_switch_options(),
	'active_callback' 	=> 'ultravel_is_hero_slider_section_enable',
) ) );

// Event social icons number control and setting
$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_count]', array(
	'default'          	=> $options['hero_slider_count'],
	'sanitize_callback' => 'ultravel_sanitize_number_range',
	'validate_callback' => 'ultravel_validate_hero_slider_count',
) );

$wp_customize->add_control( 'ultravel_theme_options[hero_slider_count]', array(
	'label'             => esc_html__( 'Number of Slides', 'ultravel' ),
	'description'       => esc_html__( 'Note: Min 1 & Max 10. Please input the valid number and save. Then refresh the page to see the change.', 'ultravel' ),
	'section'           => 'ultravel_hero_slider_section',
	'active_callback'   => 'ultravel_is_hero_slider_section_enable',
	'type'				=> 'number',
	'input_attrs'		=> array(
		'min'	=> 1,
		'max'	=> 10,
		'style' => 'width: 100px;'
		),
) );

// Slider content type control and setting
$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_content_type]', array(
	'default'          	=> $options['hero_slider_content_type'],
	'sanitize_callback' => 'ultravel_sanitize_select',
) );

$wp_customize->add_control( 'ultravel_theme_options[hero_slider_content_type]', array(
	'label'             => esc_html__( 'Content Type', 'ultravel' ),
	'section'           => 'ultravel_hero_slider_section',
	'type'				=> 'select',
	'active_callback' 	=> 'ultravel_is_hero_slider_section_enable',
	'choices'			=> ultravel_main_slider_content_type(),
) );

for ( $i = 1; $i <= 3; $i++ ) :

	// slider pages drop down chooser control and setting
	$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_content_page_' . $i . ']', array(
		'sanitize_callback' => 'ultravel_sanitize_page',
	) );

	$wp_customize->add_control( new Ultravel_Dropdown_Chooser( $wp_customize, 'ultravel_theme_options[hero_slider_content_page_' . $i . ']', array(
		'label'             => sprintf( esc_html__( 'Select Page %d', 'ultravel' ), $i ),
		'section'           => 'ultravel_hero_slider_section',
		'choices'			=> ultravel_page_choices(),
		'active_callback'	=> 'ultravel_is_hero_slider_section_content_page_enable',
	) ) );

	$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_content_trip_' . $i . ']', array(
		'sanitize_callback' => 'ultravel_sanitize_page',
	) );

	$wp_customize->add_control( new Ultravel_Dropdown_Chooser( $wp_customize, 'ultravel_theme_options[hero_slider_content_trip_' . $i . ']', array(
		'label'             => sprintf ( esc_html__( 'Select Trip %d', 'ultravel' ), $i ),
		'section'           => 'ultravel_hero_slider_section',
		'choices'			=> ultravel_trip_choices(),
		'active_callback'	=> 'ultravel_is_hero_slider_section_content_trip_enable',
	) ) );

	// hero slider extra text title setting and control
	$wp_customize->add_setting( 'ultravel_theme_options[hero_slider_extra_text_' . $i . ']', array(
		'sanitize_callback' => 'sanitize_text_field',
		'default'			=> esc_html__( '32 Activities to do', 'ultravel' ),
		'transport'			=> 'postMessage',
	) );

	$wp_customize->add_control( 'ultravel_theme_options[hero_slider_extra_text_' . $i . ']', array(
		'label'             => sprintf ( esc_html__( 'Extra Text %d', 'ultravel' ), $i ),
		'section'        	=> 'ultravel_hero_slider_section',
		'active_callback' 	=> 'ultravel_is_hero_slider_section_enable',
		'type'				=> 'text',
	) );

endfor;