<?php
function furnituremart_header_settings( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	/*=========================================
	Header Settings Panel
	=========================================*/
	$wp_customize->add_panel( 
		'header_section', 
		array(
			'priority'      => 2,
			'capability'    => 'edit_theme_options',
			'title'			=> __('Header', 'furniture-mart'),
		) 
	);

	
	/*=========================================
	Furniture Mart Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','furniture-mart'),
			'panel'  		=> 'header_section',
		)
    );


	// topheader Logo Width
    $wp_customize->add_setting('topheader_logowidth',array(
        'default' => 100,
        'sanitize_callback' => 'furnituremart_sanitize_float'
    ));
    $wp_customize->add_control(new furnituremart_Custom_Control( $wp_customize, 'topheader_logowidth',array(
	    'label' => __('Logo Width','furniture-mart'),
	    'section' => 'title_tagline',
	    'input_attrs' => array(
	            'min' => 0,
	            'max' => 500,
	            'step' => 1,
	        ),
    )));



    // top header Site Title Color
	$topheadersitetitlecol = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'topheader_sitetitlecol',
    	array(
			'default' => $topheadersitetitlecol,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'topheader_sitetitlecol',
		array(
		    'label'   		=> __('Site Title Color','furniture-mart'),
		    'section'		=> 'title_tagline',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// top header Tagline Color
	$topheadertaglinecol = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'topheader_taglinecol',
    	array(
			'default' => $topheadertaglinecol,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 4,
		)
	);	

	$wp_customize->add_control( 
		'topheader_taglinecol',
		array(
		    'label'   		=> __('Tagline Color','furniture-mart'),
		    'section'		=> 'title_tagline',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);
	
 
	/*=========================================
	Furniture Mart header
	=========================================*/
	$wp_customize->add_section(
        'top_header',
        array(
        	'priority'      => 5,
            'title' 		=> __('Header','furniture-mart'),
			'panel'  		=> 'header_section',
		)
    );	


    $wp_customize->add_setting('furnituremart_reset_header_settings',array(
	  'sanitize_callback'   => 'sanitize_text_field'
	));
	$wp_customize->add_control(new furnituremart_Reset_Custom_Control($wp_customize, 'furniture_mart_reset_header_settings',array(
	  'type' => 'reset_control',
	   'priority' => 1,
	  'label' => __('Reset Header Settings', 'furniture-mart'),
	  'description' => 'furniture_mart_header_reset_settings',
	  'section' => 'top_header'
	)));



    $wp_customize->add_setting('furnituremart_top_header_tabs', array(
	   'sanitize_callback' => 'wp_kses_post',
	));

	$wp_customize->add_control(new furnituremart_Tab_Control($wp_customize, 'furnituremart_top_header_tabs', array(
	   'section' => 'top_header',
	   'priority' => 1,
	   'buttons' => array(
	      array(
     		'name' => esc_html__('General', 'furniture-mart'),
 			'icon' => 'dashicons dashicons-welcome-write-blog',
            'fields' => array(
            	'hide_show_sticky',
				'topheader_topheadtext1',
				'topheader_topheadtext1link'
            ),
            'active' => true,
         ),
	      array(
            'name' => esc_html__('Style', 'furniture-mart'),
            'icon' => 'dashicons dashicons-art',
            'fields' => array(
				'header_topheadbgcolor',
				'header_topheadtextcolor',
            	'header_bgcolor',
				'header_menuhamburgericoncolor',
				'header_menuhamburgericonbgcolor',
				'header_menuscolor',
				'header_brdmenuscolor',
				'header_menuscloseiconcolor',
				'header_menuscloseiconbgcolor',
            	'header_menuiconcolor',
				'header_submenuiconbgcolor',
				'header_searchbariconcolor',
				'header_searchbarbgcolor',
				'header_acciconcolor',
				'header_cartnumcolor',
				'header_cartnumbgcolor',
				'header_categoriescolor'
            ),
         )
	    
    	),
	)));


	// general setting

	// sticky header
	$wp_customize->add_setting( 'hide_show_sticky',array(
        'default' => false,
        'sanitize_callback' => 'furnituremart_switch_sanitization'
   	) );
   	$wp_customize->add_control( new furnituremart_Toggle_Switch_Custom_Control( $wp_customize, 'hide_show_sticky',array(
        'label' => __( 'Show Sticky Header','furniture-mart' ),
        'section' => 'top_header'
   	)));


	// topheader topheadtext1
	$topheadertopheadtext1 = esc_html__('', 'furniture-mart' );
	$wp_customize->add_setting(
    	'topheader_topheadtext1',
    	array(
			'default' => $topheadertopheadtext1,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'topheader_topheadtext1',
		array(
		    'label'   		=> __('Top Head Text','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	// topheader topheadtext1link
	$topheadertopheadtext1link = esc_html__('', 'furniture-mart' );
	$wp_customize->add_setting(
    	'topheader_topheadtext1link',
    	array(
			'default' => $topheadertopheadtext1link,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'topheader_topheadtext1link',
		array(
		    'label'   		=> __('Top Head Text Link','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);



	// Style setting

	// header topheadbg Color
	$headertopheadbgcolor = esc_html__('#2D2B2B', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_topheadbgcolor',
    	array(
			'default' => $headertopheadbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_topheadbgcolor',
		array(
		    'label'   		=> __('Top Head BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header topheadtext Color
	$headertopheadtextcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_topheadtextcolor',
    	array(
			'default' => $headertopheadtextcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_topheadtextcolor',
		array(
		    'label'   		=> __('Top Head Text Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header bg Color
	$headerbgcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_bgcolor',
    	array(
			'default' => $headerbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_bgcolor',
		array(
		    'label'   		=> __('BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menuhamburgericon Color 
	$headermenuhamburgericoncolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuhamburgericoncolor',
    	array(
			'default' => $headermenuhamburgericoncolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuhamburgericoncolor',
		array(
		    'label'   		=> __('Menu Hamburger Icon Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menuhamburgericonbg Color 
	$headermenuhamburgericonbgcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuhamburgericonbgcolor',
    	array(
			'default' => $headermenuhamburgericonbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuhamburgericonbgcolor',
		array(
		    'label'   		=> __('Menu Hamburger Icon BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menus Color
	$headermenuscolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuscolor',
    	array(
			'default' => $headermenuscolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuscolor',
		array(
		    'label'   		=> __('Menus Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header brdmenus Color
	$headerbrdmenuscolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_brdmenuscolor',
    	array(
			'default' => $headerbrdmenuscolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_brdmenuscolor',
		array(
		    'label'   		=> __('Menus Border Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menuscloseicon Color
	$headermenuscloseiconcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuscloseiconcolor',
    	array(
			'default' => $headermenuscloseiconcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuscloseiconcolor',
		array(
		    'label'   		=> __('Menus Close Icons Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menuscloseiconbg Color
	$headermenuscloseiconbgcolor = esc_html__('#2B2929', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuscloseiconbgcolor',
    	array(
			'default' => $headermenuscloseiconbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuscloseiconbgcolor',
		array(
		    'label'   		=> __('Menus Close Icons BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// header menuicon Color
	$headermenuiconcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_menuiconcolor',
    	array(
			'default' => $headermenuiconcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menuiconcolor',
		array(
		    'label'   		=> __('SubMenu Icon Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenuiconbg Color
	$headersubmenuiconbgcolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_submenuiconbgcolor',
    	array(
			'default' => $headersubmenuiconbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenuiconbgcolor',
		array(
		    'label'   		=> __('SubMenu Icon BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// header searchbaricon Color 
	$headersearchbariconcolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_searchbariconcolor',
    	array(
			'default' => $headersearchbariconcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_searchbariconcolor',
		array(
		    'label'   		=> __('Search Bar Icon Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header searchbarbg Color 
	$headersearchbarbgcolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_searchbarbgcolor',
    	array(
			'default' => $headersearchbarbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_searchbarbgcolor',
		array(
		    'label'   		=> __('Search Bar BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header accicon Color 
	$headeracciconcolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_acciconcolor',
    	array(
			'default' => $headeracciconcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_acciconcolor',
		array(
		    'label'   		=> __('Account Icon Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header cartnum Color 
	$headercartnumcolor = esc_html__('#fff', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_cartnumcolor',
    	array(
			'default' => $headercartnumcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_cartnumcolor',
		array(
		    'label'   		=> __('Cart Number Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header cartnumbg Color 
	$headercartnumbgcolor = esc_html__('#8B060B', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_cartnumbgcolor',
    	array(
			'default' => $headercartnumbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_cartnumbgcolor',
		array(
		    'label'   		=> __('Cart Number BG Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header categories Color 
	$headercategoriescolor = esc_html__('#000', 'furniture-mart' );
	$wp_customize->add_setting(
    	'header_categoriescolor',
    	array(
			'default' => $headercategoriescolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_categoriescolor',
		array(
		    'label'   		=> __('Categories Color','furniture-mart'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);



	$wp_customize->register_control_type('furnituremart_Tab_Control');
	$wp_customize->register_panel_type( 'furnituremart_WP_Customize_Panel' );
	$wp_customize->register_section_type( 'furnituremart_WP_Customize_Section' );

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



if ( class_exists( 'WP_Customize_Panel' ) ) {
  	class furnituremart_WP_Customize_Panel extends WP_Customize_Panel {
	   public $panel;
	   public $type = 'furnituremart_panel';
	   public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type', 'panel', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;
	      return $array;
    	}
  	}
}

if ( class_exists( 'WP_Customize_Section' ) ) {
  	class furnituremart_WP_Customize_Section extends WP_Customize_Section {
	   public $section;
	   public $type = 'furnituremart_section';
	   public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden', 'section', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;

	      if ( $this->panel ) {
	        $array['customizeAction'] = sprintf( 'Customizing &#9656; %s', esc_html( $this->manager->get_panel( $this->panel )->title ) );
	      } else {
	        $array['customizeAction'] = 'Customizing';
	      }
	      return $array;
    	}
  	}
}






