<?php
function chargingstation_blog_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
			'chargingstation_frontpage_sections', array(
				'priority' => 32,
				'title' => esc_html__( 'Frontpage Sections', 'charging-station' ),
			)
		); 
	


	/*=========================================
	Slider Section
	=========================================*/
	$wp_customize->add_section(
		'slider_setting', array(
			'title' => esc_html__( 'Slider Section', 'charging-station' ),
			'priority' => 13,
			'panel' => 'chargingstation_frontpage_sections',
		)
	);


	$wp_customize->add_setting('chargingstation_reset_slider_settings',array(
		'sanitize_callback'   => 'sanitize_text_field'
	  ));
	  $wp_customize->add_control(new chargingstation_Reset_Custom_Control($wp_customize, 'chargingstation_reset_slider_settings',array(
		'type' => 'reset_control',
		 'priority' => 1,
		'label' => __('Reset Slider Settings', 'charging-station'),
		'description' => 'chargingstation_slider_reset_settings',
		'section' => 'slider_setting'
	  )));
  
  
  
	  $wp_customize->add_setting('chargingstation_top_slider_tabs', array(
		 'sanitize_callback' => 'wp_kses_post',
	  ));
  
	  $wp_customize->add_control(new chargingstation_Tab_Control($wp_customize, 'chargingstation_top_slider_tabs', array(
		 'section' => 'slider_setting',
		 'priority' => 1,
		 'buttons' => array(
			array(
			   'name' => esc_html__('General', 'charging-station'),
			   'icon' => 'dashicons dashicons-welcome-write-blog',
			  'fields' => array(
				  'slider1',
				  'slider2',
				  'slider3',
				  'slider4',
				  'slider5'
			  ),
			  'active' => true,
		   ),
			array(
			  'name' => esc_html__('Style', 'charging-station'),
			  'icon' => 'dashicons dashicons-art',
			  'fields' => array(
				  'slider_title_color',
				  'slider_description_color',
				  'slider_btntext_color',
				  'slider_Buttonbg_color',
				  'slider_btnbghover_color',
				  'slider_contntbg_color',
				  'slider_contntBorder_color'
			  ),
			),
			array(
            'name' => esc_html__('Layout', 'charging-station'),
            'icon' => 'dashicons dashicons-layout',
            'fields' => array(
                'slider_section_width',
                'slider_padding',
                'slider_section_t_padding',
                'slider_section_b_padding'

            ),
         )
		  
		  ),
	  )));
	
	


	// Slider 1
	$wp_customize->add_setting( 
    	'slider1',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 1,
		)
	);	

	$wp_customize->add_control( 
		'slider1',
		array(
		    'label'   		=> __('Slider 1','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);		



	// Slider 2
	$wp_customize->add_setting(
    	'slider2',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 2,
		)
	);	

	$wp_customize->add_control( 
		'slider2',
		array(
		    'label'   		=> __('Slider 2','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);	


	// Slider 3
	$wp_customize->add_setting(
    	'slider3',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'slider3',
		array(
		    'label'   		=> __('Slider 3','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);	


	// Slider 4
	$wp_customize->add_setting(
    	'slider4',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 4,
		)
	);	

	$wp_customize->add_control( 
		'slider4',
		array(
		    'label'   		=> __('Slider 4','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);



	// Slider 5
	$wp_customize->add_setting(
    	'slider5',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 5,
		)
	);	

	$wp_customize->add_control( 
		'slider5',
		array(
		    'label'   		=> __('Slider 5','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);


	// slider title color
	$slidertitlecolor = esc_html__('#becb01', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_title_color',
    	array(
			'default' => $slidertitlecolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_title_color',
		array(
		    'label'   		=> __('Title Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	

	// slider description color
	$sliderdescriptioncolor = esc_html__('#979b9d', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_description_color',
    	array(
			'default' => $sliderdescriptioncolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_description_color',
		array(
		    'label'   		=> __('Description Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	

	// slider btntext color
	$sliderbtntextcolor = esc_html__('#ffffff', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_btntext_color',
    	array(
			'default' => $sliderbtntextcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_btntext_color',
		array(
		    'label'   		=> __('Button Text Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	

	// slider Buttonbg color
	$sliderButtonbgcolor = esc_html__('#becb01', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_Buttonbg_color',
    	array(
			'default' => $sliderButtonbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_Buttonbg_color',
		array(
		    'label'   		=> __('Button BG Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	

	// slider btnbghover color
	$sliderbtnbghovercolor = esc_html__('#58b43e', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_btnbghover_color',
    	array(
			'default' => $sliderbtnbghovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_btnbghover_color',
		array(
		    'label'   		=> __('Button BG Hover Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	


		// slider Content BG color
	$slidercontentBGcolor = esc_html__('#161415', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_contntbg_color',
    	array(
			'default' => $slidercontentBGcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_contntbg_color',
		array(
		    'label'   		=> __('Content BG Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	


	// slider Content Border color
	$slidercontentBordercolor = esc_html__('#fff', 'charging-station' );
	$wp_customize->add_setting(
    	'slider_contntBorder_color',
    	array(
			'default' => $slidercontentBordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'slider_contntBorder_color',
		array(
		    'label'   		=> __('Content Border Color','charging-station'),
		    'section'		=> 'slider_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	




	// Layout
	$wp_customize->add_setting('slider_section_width',array(
        'default' => 'Full Width',
        'sanitize_callback' => 'chargingstation_sanitize_choices',
    ));
    $wp_customize->add_control('slider_section_width',array(
        'type' => 'select',
        'label' => __('Section Width','charging-station'),
        'choices' => array (
            'Box Width' => __('Box Width','charging-station'),
            'Full Width' => __('Full Width','charging-station')
        ),
        'section' => 'slider_setting',
    ));


    // Slider section padding 
	$wp_customize->add_setting('slider_padding',array(
		'sanitize_callback'   => 'esc_html'
	));
	$wp_customize->add_control('slider_padding',array(
		'label' => __('Section Padding','charging-station'),
		'section' => 'slider_setting'
	));

	$wp_customize->add_setting('slider_section_t_padding',array(
		'default' => '0',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('slider_section_t_padding',array(
		'type' => 'number',
		'label' => __('Top','charging-station'),
		'section' => 'slider_setting',
	));

	$wp_customize->add_setting('slider_section_b_padding',array(
		'default' => '0',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('slider_section_b_padding',array(
		'type' => 'number',
		'label' => __('Bottom','charging-station'),
		'section' => 'slider_setting',
	));



	/*=========================================
	Service Section
	=========================================*/
	$wp_customize->add_section(
		'Service_setting', array(
			'title' => esc_html__( 'Service Section', 'charging-station' ),
			'priority' => 14,
			'panel' => 'chargingstation_frontpage_sections',
		)
	);

	$wp_customize->add_setting('chargingstation_reset_Service_settings',array(
		'sanitize_callback'   => 'sanitize_text_field'
	  ));
	  $wp_customize->add_control(new chargingstation_Reset_Custom_Control($wp_customize, 'chargingstation_reset_Service_settings',array(
		'type' => 'reset_control',
		 'priority' => 1,
		'label' => __('Reset Service Settings', 'charging-station'),
		'description' => 'chargingstation_Service_reset_settings',
		'section' => 'Service_setting'
	  )));
  

	  $wp_customize->add_setting('chargingstation_top_Service_tabs', array(
		 'sanitize_callback' => 'wp_kses_post',
	  ));
  
	  $wp_customize->add_control(new chargingstation_Tab_Control($wp_customize, 'chargingstation_top_Service_tabs', array(
		 'section' => 'Service_setting',
		 'priority' => 1,
		 'buttons' => array(
			array(
			   'name' => esc_html__('General', 'charging-station'),
			   'icon' => 'dashicons dashicons-welcome-write-blog',
			  'fields' => array(
				  'Service_disable_section',
				  'Service1',
				  'Service2',
				  'Service3',
				  'Service4',
				  'Service5',
				  'Service6'
			  ),
			  'active' => true,
		   ),
			array(
			  'name' => esc_html__('Style', 'charging-station'),
			  'icon' => 'dashicons dashicons-art',
			  'fields' => array(
				'Service_heading_color',
				'Service_subheading_color',
				'Service_title_color',
				'Service_border_color',
				'Service_innerborder_color'
			  ),
			),
			array(
            'name' => esc_html__('Layout', 'charging-station'),
            'icon' => 'dashicons dashicons-layout',
            'fields' => array(
                'Service_section_width',
				'Service_padding',
				'Service_section_t_padding',
				'Service_section_b_padding',
				'chargingstation_Service_image_height'

            ),
         )
		  
		  ),
	  )));
	

	// General

	// hide show Service section
	$wp_customize->add_setting(
        'Service_disable_section',
        array(
            'sanitize_callback' => 'wp_kses_post',
        )
    );
    $wp_customize->add_control(
        new chargingstation_Toggle_Switch_Custom_Control(
            $wp_customize,
            'Service_disable_section',
            array(
                'settings'      => 'Service_disable_section',
                'section'       => 'Service_setting',
                'label'         => __( 'Disable Section', 'charging-station' ),
                'on_off_label'  => array(
                    'on' => __( 'Yes', 'charging-station' ),
                    'off' => __( 'No', 'charging-station' )
                ),
            )
        )
    );


	// Service 1
	$wp_customize->add_setting( 
    	'Service1',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 1,
		)
	);	

	$wp_customize->add_control( 
		'Service1',
		array(
		    'label'   		=> __('Service 1','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);		



	// Service 2
	$wp_customize->add_setting(
    	'Service2',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 2,
		)
	);	

	$wp_customize->add_control( 
		'Service2',
		array(
		    'label'   		=> __('Service 2','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);	


	// Service 3
	$wp_customize->add_setting(
    	'Service3',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'Service3',
		array(
		    'label'   		=> __('Service 3','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);	


	// Service 4
	$wp_customize->add_setting(
    	'Service4',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 4,
		)
	);	

	$wp_customize->add_control( 
		'Service4',
		array(
		    'label'   		=> __('Service 4','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);



	// Service 5
	$wp_customize->add_setting(
    	'Service5',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 5,
		)
	);	

	$wp_customize->add_control( 
		'Service5',
		array(
		    'label'   		=> __('Service 5','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);


	// Service 6
	$wp_customize->add_setting(
    	'Service6',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 5,
		)
	);	

	$wp_customize->add_control( 
		'Service6',
		array(
		    'label'   		=> __('Service 6','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'dropdown-pages',
			'transport'         => $selective_refresh,
		)  
	);


	// style

	// Service heading color
	$Serviceheadingcolor = esc_html__('#bfcc03', 'charging-station' );
	$wp_customize->add_setting(
    	'Service_heading_color',
    	array(
			'default' => $Serviceheadingcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'Service_heading_color',
		array(
		    'label'   		=> __('Heading Color','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	


	// Service subheading color
	$Servicesubheadingcolor = esc_html__('#8a8a8a', 'charging-station' );
	$wp_customize->add_setting(
    	'Service_subheading_color',
    	array(
			'default' => $Servicesubheadingcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'Service_subheading_color',
		array(
		    'label'   		=> __('Sub Heading Color','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);	

	// Service title color
	$Servicetitlecolor = esc_html__('#fff', 'charging-station' );
	$wp_customize->add_setting(
    	'Service_title_color',
    	array(
			'default' => $Servicetitlecolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'Service_title_color',
		array(
		    'label'   		=> __('Box Title Color','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// Service border color
	$Servicebordercolor = esc_html__('#bfcc03', 'charging-station' );
	$wp_customize->add_setting(
    	'Service_border_color',
    	array(
			'default' => $Servicebordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'Service_border_color',
		array(
		    'label'   		=> __('Box Border Color','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// Service innerborder color
	$Serviceinnerbordercolor = esc_html__('#dddddd', 'charging-station' );
	$wp_customize->add_setting(
    	'Service_innerborder_color',
    	array(
			'default' => $Serviceinnerbordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'Service_innerborder_color',
		array(
		    'label'   		=> __('Box Inner Border Color','charging-station'),
		    'section'		=> 'Service_setting',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// Layout
	$wp_customize->add_setting('Service_section_width',array(
        'default' => 'Box Width',
        'sanitize_callback' => 'chargingstation_sanitize_choices',
    ));
    $wp_customize->add_control('Service_section_width',array(
        'type' => 'select',
        'label' => __('Section Width','charging-station'),
        'choices' => array (
            'Box Width' => __('Box Width','charging-station'),
            'Full Width' => __('Full Width','charging-station')
        ),
        'section' => 'Service_setting',
    ));

	// Service section padding 
	$wp_customize->add_setting('Service_padding',array(
		'sanitize_callback'   => 'esc_html'
	));
	$wp_customize->add_control('Service_padding',array(
		'label' => __('Section Padding','charging-station'),
		'section' => 'Service_setting'
	));

	$wp_customize->add_setting('Service_section_t_padding',array(
		'default' => '4',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('Service_section_t_padding',array(
		'type' => 'number',
		'label' => __('Top','charging-station'),
		'section' => 'Service_setting',
	));

	$wp_customize->add_setting('Service_section_b_padding',array(
		'default' => '5',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('Service_section_b_padding',array(
		'type' => 'number',
		'label' => __('Bottom','charging-station'),
		'section' => 'Service_setting',
	));

	// Service img height
    $wp_customize->add_setting('chargingstation_Service_image_height',array(
        'default' => 340,
        'sanitize_callback' => 'chargingstation_sanitize_float'
    ));
    $wp_customize->add_control(new chargingstation_Custom_Control( $wp_customize, 'chargingstation_Service_image_height',array(
	    'label' => __('Image Height','charging-station'),
	    'section' => 'Service_setting',
	    'input_attrs' => array(
	            'min' => 0,
	            'max' => 500,
	            'step' => 1,
	        ),
    )));


	$wp_customize->register_control_type('chargingstation_Tab_Control');


}

add_action( 'customize_register', 'chargingstation_blog_setting' );

// service selective refresh
function chargingstation_blog_section_partials( $wp_customize ){	
	// blog_title
	$wp_customize->selective_refresh->add_partial( 'blog_title', array(
		'selector'            => '.home-blog .title h6',
		'settings'            => 'blog_title',
		'render_callback'  => 'chargingstation_blog_title_render_callback',
	
	) );
	
	// blog_subtitle
	$wp_customize->selective_refresh->add_partial( 'blog_subtitle', array(
		'selector'            => '.home-blog .title h2',
		'settings'            => 'blog_subtitle',
		'render_callback'  => 'chargingstation_blog_subtitle_render_callback',
	
	) );
	
	// blog_description
	$wp_customize->selective_refresh->add_partial( 'blog_description', array(
		'selector'            => '.home-blog .title p',
		'settings'            => 'blog_description',
		'render_callback'  => 'chargingstation_blog_description_render_callback',
	
	) );	
	}

add_action( 'customize_register', 'chargingstation_blog_section_partials' );

// blog_title
function chargingstation_blog_title_render_callback() {
	return get_theme_mod( 'blog_title' );
}

// blog_subtitle
function chargingstation_blog_subtitle_render_callback() {
	return get_theme_mod( 'blog_subtitle' );
}

// service description
function chargingstation_blog_description_render_callback() {
	return get_theme_mod( 'blog_description' );
}