<?php
/**
 * Slider options.
 *
 * @package Magazine Bell
 */

$default = magazine_bell_get_default_theme_options();

// Featured Slider Section
$wp_customize->add_section( 'section_featured_slider',
	array(
		'title'      => __( 'Banner Section', 'magazine-bell' ),
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		'active_callback' => 'magazine_bell_slider_design_enable',
		)
);

$wp_customize->add_setting( 'theme_options[disable_featured-slider_section]',
	array(
		'default'           => $default['disable_featured-slider_section'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'magazine_bell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new Magazine_Bell_Switch_Control( $wp_customize, 'theme_options[disable_featured-slider_section]',
    array(
		'label' 	=> __('Disable Slider Section', 'magazine-bell'),
		'section'    			=> 'section_featured_slider',
		'on_off_label' 		=> magazine_bell_switch_options(),
    )
) );

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

$wp_customize->add_control('theme_options[slider_excerpt_length]', 
	array(
	'label'       => __('Excerpt Length', 'magazine-bell'),
	'description' => __('Save & Refresh the customizer to see its effect. Maximum is 1000.', 'magazine-bell'),
	'section'     => 'section_featured_slider',   
	'settings'    => 'theme_options[slider_excerpt_length]',		
	'type'        => 'number',
	'active_callback' => 'magazine_bell_slider_active',
	'input_attrs' => array(
			'min'	=> 0,
			'max'	=> 1000,
			'step'	=> 1,
		),
	)
);

// Add arrow enable setting and control.
$wp_customize->add_setting( 'theme_options[slider_content_position_option]', array(
	'default'           => $default['slider_content_position_option'],
	'sanitize_callback' => 'magazine_bell_sanitize_select',
) );

$wp_customize->add_control( 'theme_options[slider_content_position_option]', array(
	'label'             => esc_html__( 'Choose Slider Contion position', 'magazine-bell' ),
	'section'           => 'section_featured_slider',
	'type'              => 'radio',
	'active_callback' => 'magazine_bell_slider_active',
	'choices'				=> array( 
		'default-position'     => esc_html__( 'Center', 'magazine-bell' ), 
		'left-position'     => esc_html__( 'Left Side', 'magazine-bell' ), 
		'right-position'     => esc_html__( 'Right Side', 'magazine-bell' ),
		)
) );


// Add arrow enable setting and control.
$wp_customize->add_setting( 'theme_options[slider_arrow_enable]', array(
	'default'           => $default['slider_arrow_enable'],
	'sanitize_callback' => 'magazine_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[slider_arrow_enable]', array(
	'label'             => esc_html__( 'Enable Slider Arrow', 'magazine-bell' ),
	'section'           => 'section_featured_slider',
	'type'              => 'checkbox',
	'active_callback' => 'magazine_bell_slider_active',
) );


// Add autoplay enable setting and control.
$wp_customize->add_setting( 'theme_options[slider_fade_enable]', array(
	'default'           => $default['slider_fade_enable'],
	'sanitize_callback' => 'magazine_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[slider_fade_enable]', array(
	'label'             => esc_html__( 'Enable Slider Fade Effect', 'magazine-bell' ),
	'section'           => 'section_featured_slider',
	'type'              => 'checkbox',
	'active_callback' => 'magazine_bell_slider_active',
) );


// Add posted on enable setting and control.
$wp_customize->add_setting( 'theme_options[slider_author_enable]', array(
	'default'           => $default['slider_author_enable'],
	'sanitize_callback' => 'magazine_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[slider_author_enable]', array(
	'label'             => esc_html__( 'Enable Author', 'magazine-bell' ),
	'section'           => 'section_featured_slider',
	'type'              => 'checkbox',
	'active_callback' => 'magazine_bell_slider_active',
) );
// Add posted on enable setting and control.
$wp_customize->add_setting( 'theme_options[slider_posted_on_enable]', array(
	'default'           => $default['slider_posted_on_enable'],
	'sanitize_callback' => 'magazine_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[slider_posted_on_enable]', array(
	'label'             => esc_html__( 'Enable Posted Date', 'magazine-bell' ),
	'section'           => 'section_featured_slider',
	'type'              => 'checkbox',
	'active_callback' => 'magazine_bell_slider_active',
) );

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

$wp_customize->add_control('theme_options[slider_speed]', 
	array(
	'label'       => __('Slider Speed', 'magazine-bell'),
	'description' => __('Slider Speed Default speed 800', 'magazine-bell'),
	'section'     => 'section_featured_slider',   
	'settings'    => 'theme_options[slider_speed]',		
	'type'        => 'number',
	'active_callback' => 'magazine_bell_slider_active',
	)
);

$wp_customize->add_setting( 'theme_options[slider_dot]',
	array(

		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'magazine_bell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new Magazine_Bell_Switch_Control( $wp_customize, 'theme_options[slider_dot]',
    array(
		'label' 	=> __('Disable Slider Dots', 'magazine-bell'),
		'section'    			=> 'section_featured_slider',
		'on_off_label' 		=> magazine_bell_switch_options(),
		'active_callback' => 'magazine_bell_slider_active',
    )
) );

$number_of_sr_items = magazine_bell_get_option( 'number_of_sr_items' );
for( $i=1; $i<=$number_of_sr_items; $i++ ){

	// Additional Information First Post
	$wp_customize->add_setting('theme_options[slider_post_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'magazine_bell_dropdown_posts'
		)
	);
	$wp_customize->add_control( new Magazine_Bell_Dropdown_Chooser( $wp_customize,'theme_options[slider_post_'.$i.']', 
		array(
		'label'       => sprintf( __('Select Post #%1$s', 'magazine-bell'), $i),
		'section'     => 'section_featured_slider',  
		'settings'    => 'theme_options[slider_post_'.$i.']',	
		'choices'	=> magazine_bell_post_choices(),	
		'type'        => 'dropdown-posts',
		'active_callback' => 'magazine_bell_slider_active',
		)
	));

	// Cta Button Text
	$wp_customize->add_setting('theme_options[slider_custom_btn_text_' . $i . ']', 
		array(

		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[slider_custom_btn_text_' . $i . ']', 
		array(
		'label'       => sprintf( __('Button Label %d', 'magazine-bell'),$i ),
		'section'     => 'section_featured_slider',   
		'settings'    => 'theme_options[slider_custom_btn_text_' . $i . ']',	
		'active_callback' => 'magazine_bell_slider_active',	
		'type'        => 'text',
		)
	);

	// slider hr setting and control
	$wp_customize->add_setting( 'theme_options[slider_hr_'. $i .']', array(
		'sanitize_callback' => 'sanitize_text_field'
	) );

	$wp_customize->add_control( new Magazine_Bell_Customize_Horizontal_Line( $wp_customize, 'theme_options[slider_hr_'. $i .']',
		array(
			'section'         => 'section_featured_slider',
			'active_callback' => 'magazine_bell_slider_active',
			'type'			  => 'hr',
	) ) );
}
// Slider Button Text
$wp_customize->add_setting('theme_options[slider_alt_custom_btn_text]', 
	array(

	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[slider_alt_custom_btn_text]', 
	array(
	'label'       => __('Alternative Button Label', 'magazine-bell'),
	'section'     => 'section_featured_slider',   
	'settings'    => 'theme_options[slider_alt_custom_btn_text]',	
	'active_callback' => 'magazine_bell_slider_active',	
	'type'        => 'text',
	)
);

	// Slider Button Url
$wp_customize->add_setting('theme_options[slider_alt_custom_btn_url]', 
	array(

	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control('theme_options[slider_alt_custom_btn_url]', 
	array(
	'label'       => __('Alternative Button Url', 'magazine-bell'),
	'section'     => 'section_featured_slider',   
	'settings'    => 'theme_options[slider_alt_custom_btn_url]',	
	'active_callback' => 'magazine_bell_slider_active',	
	'type'        => 'url',
	)
);
