<?php
/**
 * Banner Section
 *
 * @package Feminine_Lifestyle_Blog
 */

function feminine_lifestyle_blog_slider( $wp_customize ) {

	$wp_customize->get_section( 'header_image' )->panel                    = 'homepage_settings';
    $wp_customize->get_section( 'header_image' )->title                    = __( 'Banner Section', 'feminine-lifestyle-blog' );
    $wp_customize->get_section( 'header_image' )->priority                 = 10;
    $wp_customize->get_control( 'header_image' )->active_callback          = 'feminine_lifestyle_blog_banner_ac';
    $wp_customize->get_control( 'header_video' )->active_callback          = 'feminine_lifestyle_blog_banner_ac';
    $wp_customize->get_control( 'external_header_video' )->active_callback = 'feminine_lifestyle_blog_banner_ac';
    $wp_customize->get_section( 'header_image' )->description              = '';                                               
    $wp_customize->get_setting( 'header_image' )->transport                = 'refresh';
    $wp_customize->get_setting( 'header_video' )->transport                = 'refresh';
    $wp_customize->get_setting( 'external_header_video' )->transport       = 'refresh';
    
    /** Banner Options */
    $wp_customize->add_setting(
		'ed_banner_section',
		array(
			'default'			=> 'static_banner',
			'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_select'
		)
	);

	$wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Select_Control(
    		$wp_customize,
    		'ed_banner_section',
    		array(
                'label'	      => __( 'Banner Options', 'feminine-lifestyle-blog' ),
                'description' => __( 'Choose banner as static image/video or as a slider.', 'feminine-lifestyle-blog' ),
    			'section'     => 'header_image',
    			'choices'     => array(
                    'no_banner'         => __( 'Disable Banner Section', 'feminine-lifestyle-blog' ),
                    'slider_banner'     => __( 'Banner as Slider', 'feminine-lifestyle-blog' ),
                    'static_banner'     => __( 'Static/Video Banner', 'feminine-lifestyle-blog' )
                ),
                'priority' => 5	
     		)            
		)
	);
    
    /** No. of slides */
    $wp_customize->add_setting(
        'no_of_slides',
        array(
            'default'           => 3,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_number_absint'
        )
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Slider_Control( 
			$wp_customize,
			'no_of_slides',
			array(
				'section'     => 'header_image',
                'label'       => __( 'Number of Slides', 'feminine-lifestyle-blog' ),
                'description' => __( 'Choose the number of slides you want to display', 'feminine-lifestyle-blog' ),
                'choices'	  => array(
					'min' 	=> 1,
					'max' 	=> 20,
					'step'	=> 1,
				),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'                 
			)
		)
	);

    /** Repetitive Posts */
    $wp_customize->add_setting(
        'include_repetitive_posts',
        array(
            'default'           => false,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Toggle_Control( 
            $wp_customize,
            'include_repetitive_posts',
            array(
                'section'       => 'header_image',
                'label'         => __( 'Include Repetitive Posts', 'feminine-lifestyle-blog' ),
                'description'   => __( 'Enable to add posts included in slider in blog page too.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
            )
        )
    );
    
    /** HR */
    $wp_customize->add_setting(
        'banner_hr',
        array(
            'default'           => '',
            'sanitize_callback' => 'wp_kses_post' 
        )
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Note_Control( 
			$wp_customize,
			'banner_hr',
			array(
				'section'	  => 'header_image',
				'description' => '<hr/>',
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
			)
		)
    );
    
    /** Slider Auto */
    $wp_customize->add_setting(
        'slider_auto',
        array(
            'default'           => true,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Toggle_Control( 
			$wp_customize,
			'slider_auto',
			array(
				'section'     => 'header_image',
				'label'       => __( 'Slider Auto', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable slider auto transition.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
			)
		)
	);
    
    /** Slider Loop */
    $wp_customize->add_setting(
        'slider_loop',
        array(
            'default'           => true,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Toggle_Control( 
			$wp_customize,
			'slider_loop',
			array(
				'section'     => 'header_image',
				'label'       => __( 'Slider Loop', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable slider loop.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
			)
		)
	);

    $wp_customize->add_setting(
        'slider_speed',
        array(
            'default'           => 3000,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_number_absint'
        )
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Slider_Control( 
            $wp_customize,
            'slider_speed',
            array(
                'section'     => 'header_image',
                'label'       => __( 'Slider Speed', 'feminine-lifestyle-blog' ),
                'description' => __( 'Controls the speed of slider.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac',    
                'choices'     => array(
                    'min'   => 800,
                    'max'   => 10000,
                    'step'  => 100,
                ),                 
            )
        )
    );
    
    /** Slider Caption */
    $wp_customize->add_setting(
        'slider_caption',
        array(
            'default'           => true,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
		new Feminine_Lifestyle_Blog_Toggle_Control( 
			$wp_customize,
			'slider_caption',
			array(
				'section'     => 'header_image',
				'label'       => __( 'Slider Caption', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable slider caption.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
			)
		)
	);

	/** Title */
    $wp_customize->add_setting(
        'banner_title',
        array(
            'default'           => __( 'Explore the world around you', 'feminine-lifestyle-blog' ),
            'sanitize_callback' => 'sanitize_text_field',
            'transport'         => 'postMessage'
        )
    );
    
    $wp_customize->add_control(
        'banner_title',
        array(
            'label'           => __( 'Title', 'feminine-lifestyle-blog' ),
            'section'         => 'header_image',
            'type'            => 'text',
            'active_callback' => 'feminine_lifestyle_blog_banner_ac'
        )
    );
    
    $wp_customize->selective_refresh->add_partial( 'banner_title', array(
        'selector' => '.site-banner .banner-caption .banner-title',
        'render_callback' => 'feminine_lifestyle_blog_get_banner_title',
    ) );

    /** Sub Title */
    $wp_customize->add_setting(
        'banner_subtitle',
        array(
            'default'           => __( 'Plan, create and start your own adventure just the way you like!', 'feminine-lifestyle-blog' ),
            'sanitize_callback' => 'wp_kses_post',
            'transport'         => 'postMessage'
        )
    );
    
    $wp_customize->add_control(
        'banner_subtitle',
        array(
            'label'           => __( 'Sub Title', 'feminine-lifestyle-blog' ),
            'section'         => 'header_image',
            'type'            => 'textarea',
            'active_callback' => 'feminine_lifestyle_blog_banner_ac'
        )
    );
    
    $wp_customize->selective_refresh->add_partial( 'banner_subtitle', array(
        'selector' => '.site-banner .banner-caption .banner-desc',
        'render_callback' => 'feminine_lifestyle_blog_get_banner_sub_title',
    ) );

    /** Banner Button Label */
    $wp_customize->add_setting(
        'banner_button',
        array(
            'default'           => __( 'Read More', 'feminine-lifestyle-blog' ),
            'sanitize_callback' => 'sanitize_text_field',
            'transport'         => 'postMessage'
        )
    );
    
    $wp_customize->add_control(
        'banner_button',
        array(
            'label'           => __( 'Banner Button Label', 'feminine-lifestyle-blog' ),
            'section'         => 'header_image',
            'type'            => 'text',
            'active_callback' => 'feminine_lifestyle_blog_banner_ac'
        )
    );
    
    $wp_customize->selective_refresh->add_partial( 'banner_button', array(
        'selector' => '.site-banner .banner-caption .btn',
        'render_callback' => 'feminine_lifestyle_blog_get_banner_button',
    ) );

    /** Banner Link */
    $wp_customize->add_setting(
        'banner_url',
        array(
            'default'           => '#',
            'sanitize_callback' => 'esc_url_raw',
        )
    );
    
    $wp_customize->add_control(
        'banner_url',
        array(
            'label'           => __( 'Banner Button Link', 'feminine-lifestyle-blog' ),
            'section'         => 'header_image',
            'type'            => 'url',
            'active_callback' => 'feminine_lifestyle_blog_banner_ac'
        )
    );

    $wp_customize->add_setting(
        'banner_url_new_tab',
        array(
            'default'           => false,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox',
        )
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Toggle_Control( 
            $wp_customize,
            'banner_url_new_tab',
            array(
                'section'     => 'header_image',
                'label'       => __( 'Open in new tab', 'feminine-lifestyle-blog' ),
                'description' => __( 'Enable to open static banner link in a new tab.', 'feminine-lifestyle-blog' ),
                'active_callback' => 'feminine_lifestyle_blog_banner_ac'
            )
        )
    );

}
add_action( 'customize_register', 'feminine_lifestyle_blog_slider' );