<?php
/**
 * Featured Slider options.
 *
 * @package Rock Studio
 */

$default = rock_studio_get_default_theme_options();

// Featured Featured Slider Section
$wp_customize->add_section( 'section_featured_slider',
	array(
	'title'      => __( 'Slider Section', 'rock-studio' ),
	'priority'   => 100,
	'capability' => 'edit_theme_options',
	'panel'      => 'home_page_panel',
	)
);

// Enable Featured Slider Section
$wp_customize->add_setting('theme_options[enable_featured_slider_section]', 
	array(
	'default' 			=> $default['enable_featured_slider_section'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_studio_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_featured_slider_section]', 
	array(		
	'label' 	=> __('Enable Section', 'rock-studio'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[enable_featured_slider_section]',
	'type' 		=> 'checkbox',	
	)
);

// Number of items
$wp_customize->add_setting('theme_options[number_of_featured_slider_items]', 
	array(
	'default' 			=> $default['number_of_featured_slider_items'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'rock_studio_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[number_of_featured_slider_items]', 
	array(
	'label'       => __('Number Of Items (Max: 3)', 'rock-studio'),
	'description' => __('Click on Publish and refresh after changing the value.', 'rock-studio'),
	'section'     => 'section_featured_slider',   
	'settings'    => 'theme_options[number_of_featured_slider_items]',		
	'type'        => 'number',
	'active_callback' => 'rock_studio_featured_slider_active',
	'input_attrs' => array(
			'min'	=> 1,
			'max'	=> 3,
			'step'	=> 1,
		),
	)
);

$number_of_featured_slider_items = rock_studio_get_option( 'number_of_featured_slider_items' );

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

	// Slide Image
	$wp_customize->add_setting('theme_options[featured_slider_slide_image_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'rock_studio_sanitize_image'
		)
	);

	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,
		'theme_options[featured_slider_slide_image_'.$i.']', 
		array(
		'label'       => sprintf( __('Slide Image #%1$s', 'rock-studio'), $i),
		'section'     		=> 'section_featured_slider',   
		'settings'    		=> 'theme_options[featured_slider_slide_image_'.$i.']',		
		'active_callback' 	=> 'rock_studio_featured_slider_active',
		'type'        		=> 'image',
		)
		)
	);

	// Slide Title
	$wp_customize->add_setting('theme_options[featured_slider_title_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[featured_slider_title_'.$i.']', 
		array(
		'label'       => sprintf( __('Title #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_title_'.$i.']',		
		'active_callback' => 'rock_studio_featured_slider_active',		
		'type'        => 'text'
		)
	);

	// Slide Content
	$wp_customize->add_setting('theme_options[featured_slider_content_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'rock_studio_sanitize_textarea_content'
		)
	);

	$wp_customize->add_control('theme_options[featured_slider_content_'.$i.']', 
		array(
		'label'       => sprintf( __('Content #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_content_'.$i.']',		
		'active_callback' => 'rock_studio_featured_slider_active',		
		'type'        => 'textarea'
		)
	);

	// Button Text One
	$wp_customize->add_setting('theme_options[featured_slider_btn_text_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[featured_slider_btn_text_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Label #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_btn_text_'.$i.']',		
		'active_callback' => 'rock_studio_featured_slider_active',		
		'type'        => 'text'
		)
	);

	// Button Url One
	$wp_customize->add_setting('theme_options[featured_slider_btn_url_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'esc_url_raw'
		)
	);

	$wp_customize->add_control('theme_options[featured_slider_btn_url_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Url #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_btn_url_'.$i.']',		
		'active_callback' => 'rock_studio_featured_slider_active',		
		'type'        => 'url'
		)
	);
}

// Slider Speed
$wp_customize->add_setting('theme_options[data_slick_speed]', 
	array(
	'default' 			=> $default['data_slick_speed'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'rock_studio_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[data_slick_speed]', 
	array(
	'label'       		=> __('Slider Speed', 'rock-studio'),
	'description' 		=> __('Save & Refresh the customizer to see its effect. Maximum is 5000.', 'rock-studio'),
	'section'     		=> 'section_featured_slider',   
	'settings'    		=> 'theme_options[data_slick_speed]',		
	'type'        		=> 'number',
	'active_callback' 	=> 'rock_studio_featured_slider_active',
	'input_attrs' => array(
			'min'	=> 0,
			'max'	=> 5000,
			'step'	=> 100,
		),
	)
);

// Slider Fade
$wp_customize->add_setting('theme_options[data_slick_fade]', 
	array(
	'default' 			=> $default['data_slick_fade'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_studio_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[data_slick_fade]', 
	array(		
	'label' 	=> __('Slider Fade', 'rock-studio'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[data_slick_fade]',
	'type' 		=> 'checkbox',	
	'active_callback' 	=> 'rock_studio_featured_slider_active',
	)
);

// Slider Infinite
$wp_customize->add_setting('theme_options[data_slick_infinite]', 
	array(
	'default' 			=> $default['data_slick_infinite'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_studio_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[data_slick_infinite]', 
	array(		
	'label' 	=> __('Slide Infinite', 'rock-studio'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[data_slick_infinite]',
	'type' 		=> 'checkbox',	
	'active_callback' 	=> 'rock_studio_featured_slider_active',
	)
);

// Slider Autoplay
$wp_customize->add_setting('theme_options[data_slick_autoplay]', 
	array(
	'default' 			=> $default['data_slick_autoplay'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_studio_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[data_slick_autoplay]', 
	array(		
	'label' 	=> __('Slider Autoplay', 'rock-studio'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[data_slick_autoplay]',
	'type' 		=> 'checkbox',	
	'active_callback' 	=> 'rock_studio_featured_slider_active',
	)
);

// Slider Draggable
$wp_customize->add_setting('theme_options[data_slick_draggable]', 
	array(
	'default' 			=> $default['data_slick_draggable'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_studio_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[data_slick_draggable]', 
	array(		
	'label' 	=> __('Slider Draggable', 'rock-studio'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[data_slick_draggable]',
	'type' 		=> 'checkbox',	
	'active_callback' 	=> 'rock_studio_featured_slider_active',
	)
);