<?php
function mobilerepaircenter_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', 'mobile-repair-center'),
		) 
	);

	
	/*=========================================
	Mobile Repair Center Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','mobile-repair-center'),
			'panel'  		=> 'header_section',
		)
    );


	// topheader Logo Width
    $wp_customize->add_setting('topheader_logowidth',array(
        'default' => 100,
        'sanitize_callback' => 'mobilerepaircenter_sanitize_float'
    ));
    $wp_customize->add_control(new mobilerepaircenter_Custom_Control( $wp_customize, 'topheader_logowidth',array(
	    'label' => __('Logo Width','mobile-repair-center'),
	    'section' => 'title_tagline',
	    'input_attrs' => array(
	            'min' => 0,
	            'max' => 500,
	            'step' => 1,
	        ),
    )));

	
	// logo section padding 
	$wp_customize->add_setting('mobilerepaircenter_logo_padding',array(
		'sanitize_callback'   => 'esc_html'
	));
	$wp_customize->add_control('mobilerepaircenter_logo_padding',array(
		'label' => __('Logo Padding','mobile-repair-center'),
		'section' => 'title_tagline'
	));

	$wp_customize->add_setting('mobilerepaircenter_logo_top_padding',array(
		'default' => '2',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('mobilerepaircenter_logo_top_padding',array(
		'type' => 'number',
		'label' => __('Top','mobile-repair-center'),
		'section' => 'title_tagline',
	));

	$wp_customize->add_setting('mobilerepaircenter_logo_left_padding',array(
		'default' => '2',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('mobilerepaircenter_logo_left_padding',array(
		'type' => 'number',
		'label' => __('Left','mobile-repair-center'),
		'section' => 'title_tagline',
	));

	$wp_customize->add_setting('mobilerepaircenter_logo_bottom_padding',array(
		'default' => '2',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('mobilerepaircenter_logo_bottom_padding',array(
		'type' => 'number',
		'label' => __('Bottom','mobile-repair-center'),
		'section' => 'title_tagline',
	));

	$wp_customize->add_setting('mobilerepaircenter_logo_right_padding',array(
		'default' => '2',
		'sanitize_callback' => 'sanitize_text_field'
	));
	$wp_customize->add_control('mobilerepaircenter_logo_right_padding',array(
		'type' => 'number',
		'label' => __('Right','mobile-repair-center'),
		'section' => 'title_tagline',
	));


    // top header Site Title Color
	$topheadersitetitlecol = esc_html__('#000', 'mobile-repair-center' );
	$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','mobile-repair-center'),
		    'section'		=> 'title_tagline',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// top header Tagline Color
	$topheadertaglinecol = esc_html__('#293C4B', 'mobile-repair-center' );
	$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','mobile-repair-center'),
		    'section'		=> 'title_tagline',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);
	
 
	/*=========================================
	Mobile Repair Center header
	=========================================*/
	$wp_customize->add_section(
        'top_header',
        array(
        	'priority'      => 5,
            'title' 		=> __('Header','mobile-repair-center'),
			'panel'  		=> 'header_section',
		)
    );	

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

	$wp_customize->add_control(new mobilerepaircenter_Tab_Control($wp_customize, 'mobilerepaircenter_top_header_tabs', array(
	   'section' => 'top_header',
	   'priority' => 1,
	   'buttons' => array(
	      array(
     		'name' => esc_html__('General', 'mobile-repair-center'),
 			'icon' => 'dashicons dashicons-welcome-write-blog',
            'fields' => array(
            	'hide_show_sticky',
				'header_text',
				'header_mail',
				'header_time',
				'topheader_subtextphone',
				'topheader_phone'
            ),
            'active' => true,
         ),
	      array(
            'name' => esc_html__('Style', 'mobile-repair-center'),
            'icon' => 'dashicons dashicons-art',
            'fields' => array(
				'header_topheadbgcolor',
				'header_topheadtextcolor',
				'header_topheadiconscolor',
				'header_topheadmailtimeiconscolor',
				'header_topheadmailtimetextcolor',
				'header_topheadtexthovercolor',
            	'header_menuscolor',
            	'header_menushovercolor',
            	'header_submenusbgcolor',
            	'header_submenusbordercolor',
            	'header_submenutextcolor',
				'header_submenutexticoncolor',
            	'header_submenusbghovercolor',
            	'header_submenustxthovercolor',
				'header_searchicon_color',
				'header_phoneicon_color',
				'header_phoneiconbg_color',
				'header_phonetext_color',
				'header_phonenumber_color'
            ),
         )
	    
    	),
	)));


	// general setting

	// sticky header
	$wp_customize->add_setting( 'hide_show_sticky',array(
        'default' => false,
        'sanitize_callback' => 'mobilerepaircenter_switch_sanitization'
   	) );
   	$wp_customize->add_control( new mobilerepaircenter_Toggle_Switch_Custom_Control( $wp_customize, 'hide_show_sticky',array(
        'label' => __( 'Show Sticky Header','mobile-repair-center' ),
        'section' => 'top_header'
   	)));
	
	// topheader text
	$headertext = esc_html__('The Majority Have Suffered', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_text',
    	array(
			'default' => $headertext,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 1,
		)
	);	

	$wp_customize->add_control( 
		'header_text',
		array(
		    'label'   		=> __('Text','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	// topheader mail
	$headermail = esc_html__('demo@demo.com', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_mail',
    	array(
			'default' => $headermail,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 1,
		)
	);	

	$wp_customize->add_control( 
		'header_mail',
		array(
		    'label'   		=> __('Mail','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	// topheader time
	$headertime = esc_html__('Mon-Sat 09:00-10:00', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_time',
    	array(
			'default' => $headertime,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 1,
		)
	);	

	$wp_customize->add_control( 
		'header_time',
		array(
		    'label'   		=> __('Timing','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	// topheader subtextphone
	$topheadersubtextphone = esc_html__('Dial to Drive', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'topheader_subtextphone',
    	array(
			'default' => $topheadersubtextphone,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 7,
		)
	);	

	$wp_customize->add_control( 
		'topheader_subtextphone',
		array(
		    'label'   		=> __('Sub Text Phone','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	// topheader phone
	$topheaderphone = esc_html__('(00)88812345', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'topheader_phone',
    	array(
			'default' => $topheaderphone,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 7,
		)
	);	

	$wp_customize->add_control( 
		'topheader_phone',
		array(
		    'label'   		=> __('Phone Number','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);



	// Style setting

	// header bg Color
	$headerbgcolor = esc_html__('#121113', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_topheadbgcolor',
    	array(
			'default' => $headerbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

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

	$headertopheadtextcolor = esc_html__('#fff', 'mobile-repair-center' );
	$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','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headertopheadmailtimeiconscolor = esc_html__('#fff', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_topheadmailtimeiconscolor',
    	array(
			'default' => $headertopheadmailtimeiconscolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_topheadmailtimeiconscolor',
		array(
		    'label'   		=> __('Top Head Mail & Time Icon Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headertopheadmailtimetextcolor = esc_html__('#fff', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_topheadmailtimetextcolor',
    	array(
			'default' => $headertopheadmailtimetextcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_topheadmailtimetextcolor',
		array(
		    'label'   		=> __('Top Head Mail & Time Text Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);
	
	$headertopheadtexthovercolor = esc_html__('#F27A0A', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_topheadtexthovercolor',
    	array(
			'default' => $headertopheadtexthovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_topheadtexthovercolor',
		array(
		    'label'   		=> __('Top Head Mial Hover Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menus Color
	$headermenuscolor = esc_html__('#064273', 'mobile-repair-center' );
	$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','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header menushover Color
	$headermenushovercolor = esc_html__('#F27A0A', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_menushovercolor',
    	array(
			'default' => $headermenushovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_menushovercolor',
		array(
		    'label'   		=> __('Menus Hover & Active Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headersubmenusbgcolor = esc_html__('#fff', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenusbgcolor',
    	array(
			'default' => $headersubmenusbgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenusbgcolor',
		array(
		    'label'   		=> __('SubMenus BG Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headersubmenusbordercolor = esc_html__('#F27A0A', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenusbordercolor',
    	array(
			'default' => $headersubmenusbordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenusbordercolor',
		array(
		    'label'   		=> __('SubMenus Border Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// header submenutext Color
	$headersubmenutextcolor = esc_html__('#F27A0A', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenutextcolor',
    	array(
			'default' => $headersubmenutextcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenutextcolor',
		array(
		    'label'   		=> __('SubMenus Text Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenutexticon Color
	$headersubmenutexticoncolor = esc_html__('#000', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenutexticoncolor',
    	array(
			'default' => $headersubmenutexticoncolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenutexticoncolor',
		array(
		    'label'   		=> __('SubMenus Text Icon Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenusbghover Color
	$headersubmenusbghovercolor = esc_html__('#F27A0A', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenusbghovercolor',
    	array(
			'default' => $headersubmenusbghovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenusbghovercolor',
		array(
		    'label'   		=> __('SubMenus BG Hover Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenustxthover Color
	$headersubmenustxthovercolor = esc_html__('#fff', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_submenustxthovercolor',
    	array(
			'default' => $headersubmenustxthovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_submenustxthovercolor',
		array(
		    'label'   		=> __('SubMenus Text Hover Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);
	

	// header searchicon_ Color
	$headersearchicon_color = esc_html__('#000', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_searchicon_color',
    	array(
			'default' => $headersearchicon_color,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_searchicon_color',
		array(
		    'label'   		=> __('Search Icon Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phoneicon_ Color
	$headerphoneicon_color = esc_html__('#000', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_phoneicon_color',
    	array(
			'default' => $headerphoneicon_color,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phoneicon_color',
		array(
		    'label'   		=> __('Phone Icon Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phoneiconbg Color
	$headerphoneiconbg_color = esc_html__('#fff', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_phoneiconbg_color',
    	array(
			'default' => $headerphoneiconbg_color,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phoneiconbg_color',
		array(
		    'label'   		=> __('Phone Icon BG Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phonetext Color
	$headerphonetext_color = esc_html__('#6E6E6E', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_phonetext_color',
    	array(
			'default' => $headerphonetext_color,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phonetext_color',
		array(
		    'label'   		=> __('Phone Text Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phonenumber Color
	$headerphonenumber_color = esc_html__('#000', 'mobile-repair-center' );
	$wp_customize->add_setting(
    	'header_phonenumber_color',
    	array(
			'default' => $headerphonenumber_color,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phonenumber_color',
		array(
		    'label'   		=> __('Phone Number Color','mobile-repair-center'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$wp_customize->register_control_type('mobilerepaircenter_Tab_Control');
	$wp_customize->register_panel_type( 'mobilerepaircenter_WP_Customize_Panel' );
	$wp_customize->register_section_type( 'mobilerepaircenter_WP_Customize_Section' );

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



if ( class_exists( 'WP_Customize_Panel' ) ) {
  	class mobilerepaircenter_WP_Customize_Panel extends WP_Customize_Panel {
	   public $panel;
	   public $type = 'mobilerepaircenter_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 mobilerepaircenter_WP_Customize_Section extends WP_Customize_Section {
	   public $section;
	   public $type = 'mobilerepaircenter_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;
    	}
  	}
}






