<?php
/**
 * Featured Slider options.
 *
 * @package Super Business
 */

$default = super_business_get_default_theme_options();

// Featured Featured Slider Section
$wp_customize->add_section( 'section_featured_slider',
	array(
	'title'      => __( 'Slider Section', 'super-business' ),
	'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' => 'super_business_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_featured_slider_section]', 
	array(		
	'label' 	=> __('Enable Section', 'super-business'),
	'description' => __('Go to Customize - Homepage Settings. Select A static page. Set Homepage as Home and Posts page as Blog to show this section.', 'super-business'),
	'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' => 'super_business_sanitize_number_range'
	)
);

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

$number_of_featured_slider_items = super_business_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' => 'super_business_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', 'super-business'), $i),
		'section'     		=> 'section_featured_slider',   
		'settings'    		=> 'theme_options[featured_slider_slide_image_'.$i.']',		
		'active_callback' 	=> 'super_business_featured_slider_active',
		'type'        		=> 'image',
		)
		)
	);

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

	$wp_customize->add_control('theme_options[featured_slider_subtitle_'.$i.']', 
		array(
		'label'       => sprintf( __('Subtitle #%1$s', 'super-business'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_subtitle_'.$i.']',		
		'active_callback' => 'super_business_featured_slider_active',		
		'type'        => 'text'
		)
	);

	// 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', 'super-business'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_title_'.$i.']',		
		'active_callback' => 'super_business_featured_slider_active',		
		'type'        => 'text'
		)
	);

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

	$wp_customize->add_control('theme_options[featured_slider_btn_text_one_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Label One #%1$s', 'super-business'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_btn_text_one_'.$i.']',		
		'active_callback' => 'super_business_featured_slider_active',		
		'type'        => 'text'
		)
	);

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

	$wp_customize->add_control('theme_options[featured_slider_btn_url_one_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Url One #%1$s', 'super-business'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[featured_slider_btn_url_one_'.$i.']',		
		'active_callback' => 'super_business_featured_slider_active',		
		'type'        => 'url'
		)
	);
}