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

$default = business_carter_get_default_theme_options();

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

$wp_customize->add_control('theme_options[enable_featured_slider_section]', 
	array(		
	'label' 	=> __('Enable Section', 'business-carter'),
	'description' => __('Go to Customize - Homepage Settings. Select A static page. Set Homepage as Home and Posts page as Blog to show this section.', 'business-carter'),
	'section' 	=> 'section_featured_slider',
	'settings'  => 'theme_options[enable_featured_slider_section]',
	'type' 		=> 'checkbox',	
	)
);

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

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

$business_carter_number_of_featured_slider_items = business_carter_get_option( 'business_carter_number_of_featured_slider_items' );

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

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

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

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

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

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

	$wp_customize->add_control('theme_options[business_carter_featured_slider_title_'.$i.']', 
		array(
		'label'       => sprintf( __('Title #%1$s', 'business-carter'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[business_carter_featured_slider_title_'.$i.']',		
		'active_callback' => 'business_carter_featured_slider_active',		
		'type'        => 'text'
		)
	);

	// Button Text One
	$wp_customize->add_setting('theme_options[business_carter_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[business_carter_featured_slider_btn_text_one_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Label One #%1$s', 'business-carter'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[business_carter_featured_slider_btn_text_one_'.$i.']',		
		'active_callback' => 'business_carter_featured_slider_active',		
		'type'        => 'text'
		)
	);

	// Button Url One
	$wp_customize->add_setting('theme_options[business_carter_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[business_carter_featured_slider_btn_url_one_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Url One #%1$s', 'business-carter'), $i),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[business_carter_featured_slider_btn_url_one_'.$i.']',		
		'active_callback' => 'business_carter_featured_slider_active',		
		'type'        => 'url'
		)
	);
}