<?php
/**
 * Slider Panel
 *
 * @package Excel_Blog
 */
 
function excel_blog_customize_register_slider( $wp_customize ) {
	
    /* Option list of all categories */
    $args = array(
	   'type'                     => 'post',
	   'orderby'                  => 'name',
	   'order'                    => 'ASC',
	   'hide_empty'               => 1,
	   'hierarchical'             => 1,
	   'taxonomy'                 => 'category'
    ); 
    $option_categories = array();
    $category_lists = get_categories( $args );
    $option_categories[''] = __( 'Choose Category', 'excel-blog' );
    foreach( $category_lists as $category ){
        $option_categories[$category->term_id] = $category->name;
    }
    
    /** Slider Settings */
    $wp_customize->add_panel( 
        'slider_panel',
         array(
            'priority'   => 20,
            'capability' => 'edit_theme_options',
            'title'      => __( 'Slider Settings', 'excel-blog' ),
        ) 
    );
    
    /** Banner Slider */
    $wp_customize->add_section( 'banner_slider_setting', array(
        'title'    => __( 'Banner Slider Settings', 'excel-blog' ),
        'priority' => 20,
        'panel'    => 'slider_panel',
    ) );
    
    /** Slider Note */
    $wp_customize->add_setting(
		'banner_slider_note',
		array(
			'sanitize_callback' => 'wp_kses_post'
		)
	);

	$wp_customize->add_control(
		new Excel_Theme_Info_Text( 
			$wp_customize,
			'banner_slider_note',
			array(
				'section'     => 'banner_slider_setting',
				'label'       => __( 'Banner Slider', 'excel-blog' ),
                'description' => __( 'Sticky Posts are displayed in Banner slider. So, to display posts in banner slider you have to first make sticky posts.', 'excel-blog' ),
			)
		)
	);
    
    /** Enable/Disable Banner Slider */
    $wp_customize->add_setting(
        'ed_banner_slider',
        array(
            'default'           => 'disable',
            'sanitize_callback' => 'excel_blog_sanitize_select',
        )
    );
    
    $wp_customize->add_control(
        'ed_banner_slider',
        array(
            'label'   => __( 'Enable Banner Slider', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'radio',
            'choices' => array(
                'disable'    => __( 'Disable on All Pages.', 'excel-blog' ),
                'front_page' => __( 'Show on Front Page Only.', 'excel-blog' ),
                'all_page'   => __( 'Show on All Pages.', 'excel-blog' ),
            )
        )
    );
    
    /** Enable/Disable Slider Auto Transition */
    $wp_customize->add_setting(
        'banner_slider_auto',
        array(
            'default'           => '',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_auto',
        array(
            'label'   => __( 'Enable Slider Auto Transition', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Enable/Disable Slider Loop */
    $wp_customize->add_setting(
        'banner_slider_loop',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_loop',
        array(
            'label'   => __( 'Enable Slider Loop', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Enable/Disable Slider Control */
    $wp_customize->add_setting(
        'banner_slider_control',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_control',
        array(
            'label'   => __( 'Enable Slider Control', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Enable/Disable Slider Caption */
    $wp_customize->add_setting(
        'banner_slider_caption',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_caption',
        array(
            'label'   => __( 'Enable Slider Caption', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Slider Animation */
    $wp_customize->add_setting(
        'banner_slider_animation',
        array(
            'default'           => 'slide',
            'sanitize_callback' => 'excel_blog_sanitize_select',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_animation',
        array(
            'label'   => __( 'Choose Slider Animation', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'select',
            'choices' => array(
                'fade'  => __( 'Fade', 'excel-blog' ),
                'slide' => __( 'Slide', 'excel-blog' ),
            )
        )
    );
    
    /** Slider Speed */
    $wp_customize->add_setting(
        'banner_slider_speed',
        array(
            'default'           => 700,
            'sanitize_callback' => 'excel_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_speed',
        array(
            'label'   => __( 'Slider Speed', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'text',
        )
    );
    
    /** Slider Pause */
    $wp_customize->add_setting(
        'banner_slider_pause',
        array(
            'default'           => 6000,
            'sanitize_callback' => 'excel_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_pause',
        array(
            'label'   => __( 'Slider Pause', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'text',
        )
    );
    
    /** Slider Read More */
    $wp_customize->add_setting(
        'banner_slider_read_more',
        array(
            'default'           => __( 'Read More', 'excel-blog' ),
            'sanitize_callback' => 'sanitize_text_field',
        )
    );
    
    $wp_customize->add_control(
        'banner_slider_read_more',
        array(
            'label'   => __( 'Slider Read More', 'excel-blog' ),
            'section' => 'banner_slider_setting',
            'type'    => 'text'
        )
    );
    /** Banner Slider Ends */
    
    /** Bottom Slider */
    $wp_customize->add_section( 'bottom_slider_setting', array(
        'title'    => __( 'Bottom Slider Settings', 'excel-blog' ),
        'priority' => 30,
        'panel'    => 'slider_panel',
    ) );
    
    /** Enable/Disable Bottom Slider */
    $wp_customize->add_setting(
        'ed_bottom_slider',
        array(
            'default'           => 'disable',
            'sanitize_callback' => 'excel_blog_sanitize_select',
        )
    );
    
    $wp_customize->add_control(
        'ed_bottom_slider',
        array(
            'label'   => __( 'Enable Bottom Slider', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'radio',
            'choices' => array(
                'disable'    => __( 'Disable on All Pages.', 'excel-blog' ),
                'front_page' => __( 'Show on Front Page Only.', 'excel-blog' ),
                'all_page'   => __( 'Show on All Pages.', 'excel-blog' ),
            )
        )
    );
    
    /** Enable/Disable Slider Auto Transition */
    $wp_customize->add_setting(
        'bottom_slider_auto',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_auto',
        array(
            'label'   => __( 'Enable Slider Auto Transition', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Enable/Disable Slider Loop */
    $wp_customize->add_setting(
        'bottom_slider_loop',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_loop',
        array(
            'label'   => __( 'Enable Slider Loop', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Enable/Disable Slider Control */
    $wp_customize->add_setting(
        'bottom_slider_control',
        array(
            'default'           => '1',
            'sanitize_callback' => 'excel_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_control',
        array(
            'label'   => __( 'Enable Slider Control', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'checkbox',
        )
    );
    
    /** Bottom Section Title */
    $wp_customize->add_setting(
        'bottom_slider_title',
        array(
            'default'           => __( 'Most Viewed', 'excel-blog' ),
            'sanitize_callback' => 'sanitize_text_field',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_title',
        array(
            'label'       => __( 'Bottom Slider Title', 'excel-blog' ),
            'description' => __( 'Please add bottom slider title here. If left blank, the selected category title will be displayed.', 'excel-blog' ),
            'section'     => 'bottom_slider_setting',
            'type'        => 'text',
        )
    );
    
    /** Select Category */
    $wp_customize->add_setting(
        'bottom_slider_cat',
        array(
            'default'           => '',
            'sanitize_callback' => 'excel_blog_sanitize_select',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_cat',
        array(
            'label'       => __( 'Select Category', 'excel-blog' ),
            'description' => __( 'Select category to display bottom slider.', 'excel-blog' ),
            'section'     => 'bottom_slider_setting',
            'type'        => 'select',
            'choices'     => $option_categories,
        )
    );
        
    /** Slider Speed */
    $wp_customize->add_setting(
        'bottom_slider_speed',
        array(
            'default'           => 700,
            'sanitize_callback' => 'excel_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_speed',
        array(
            'label'   => __( 'Slider Speed', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'text',
        )
    );
    
    /** Slider Pause */
    $wp_customize->add_setting(
        'bottom_slider_pause',
        array(
            'default'           => 6000,
            'sanitize_callback' => 'excel_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        'bottom_slider_pause',
        array(
            'label'   => __( 'Slider Pause', 'excel-blog' ),
            'section' => 'bottom_slider_setting',
            'type'    => 'text',
        )
    );
    /** Bottom Slider Ends */
}
add_action( 'customize_register', 'excel_blog_customize_register_slider' );