<?php
function personallawyer_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', 'personal-lawyer'),
		) 
	);

	
	/*=========================================
	Personal Lawyer Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','personal-lawyer'),
			'panel'  		=> 'header_section',
		)
    );





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


	// top header Tagline Color
	$topheadertaglinecol = esc_html__('#fff', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'title_tagline',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);
	
 
	/*=========================================
	Personal Lawyer header
	=========================================*/
	$wp_customize->add_section(
        'top_header',
        array(
        	'priority'      => 5,
            'title' 		=> __('Header','personal-lawyer'),
			'panel'  		=> 'header_section',
		)
    );	


    $wp_customize->add_setting('personallawyer_reset_header_settings',array(
	  'sanitize_callback'   => 'sanitize_text_field'
	));
	$wp_customize->add_control(new personallawyer_Reset_Custom_Control($wp_customize, 'personal_lawyer_reset_header_settings',array(
	  'type' => 'reset_control',
	   'priority' => 1,
	  'label' => __('Reset Header Settings', 'personal-lawyer'),
	  'description' => 'personal_lawyer_header_reset_settings',
	  'section' => 'top_header'
	)));



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

	$wp_customize->add_control(new personallawyer_Tab_Control($wp_customize, 'personallawyer_top_header_tabs', array(
	   'section' => 'top_header',
	   'priority' => 1,
	   'buttons' => array(
	      array(
     		'name' => esc_html__('General', 'personal-lawyer'),
 			'icon' => 'dashicons dashicons-welcome-write-blog',
            'fields' => array(
            	'hide_show_sticky',
            	'topheader_phoneicon',
            	'topheader_phonetext',
            	'topheader_mailtext',
				'personal_lawyer_menufontsize'

            ),
            'active' => true,
         ),
	      array(
            'name' => esc_html__('Style', 'personal-lawyer'),
            'icon' => 'dashicons dashicons-art',
            'fields' => array(
            	'header_menuscolor',
            	'header_menushovercolor',
            	'header_submenusbgcolor',
            	'header_submenusbordercolor',
            	'header_submenutextcolor',
            	'header_submenusbghovercolor',
            	'header_submenustxthovercolor',
				'header_mobileviewmenutogglecolor',
				'header_mobileviewmenutogglehrvcolor',
				'header_mobileviewmenubgcolor',
            	'header_phnbgcolor1',
            	'header_phnbgcolor2',
            	'header_phnbordercolor',
            	'header_phniconcolor',
            	'header_phntxtcolor',
            	'header_phntxthovercolor',
            	'header_mailtxtcolor',
            	'header_mailtxthovercolor',
            	'header_bordercolor'
            ),
         ),
		 array(
		   'name' => esc_html__('Layout', 'personal-lawyer'),
		   'icon' => 'dashicons dashicons-layout',
		   'fields' => array(
			   'personal_lawyer_header_section_width',
		   ),
		)
	    
    	),
	)));


	// general setting

	// sticky header
	$wp_customize->add_setting( 'hide_show_sticky',array(
        'default' => false,
        'sanitize_callback' => 'personallawyer_switch_sanitization'
   	) );
   	$wp_customize->add_control( new personallawyer_Toggle_Switch_Custom_Control( $wp_customize, 'hide_show_sticky',array(
        'label' => __( 'Show Sticky Header','personal-lawyer' ),
        'section' => 'top_header'
   	)));




    // topheader icon 1
	$topheaderphoneicon = esc_html__('fa fa-phone', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'topheader_phoneicon',
    	array(
			'default' => $topheaderphoneicon,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 5,
		)
	);	

	$wp_customize->add_control( 
		'topheader_phoneicon',
		array(
		    'label'   		=> __('Phone Icon','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);



	// topheader text 1
	$topheaderphonetext = esc_html__('111-222-333', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'topheader_phonetext',
    	array(
			'default' => $topheaderphonetext,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 6,
		)
	);	

	$wp_customize->add_control( 
		'topheader_phonetext',
		array(
		    'label'   		=> __('Phone Text','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);


	// topheader mail
	$topheadermailtext = esc_html__('infoFake@mail.com', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'topheader_mailtext',
    	array(
			'default' => $topheadermailtext,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 7,
		)
	);	

	$wp_customize->add_control( 
		'topheader_mailtext',
		array(
		    'label'   		=> __('Mail','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'text',
			'transport'         => $selective_refresh,
		)  
	);

	$wp_customize->add_setting('personal_lawyer_menufontsize',array(
        'default' => '16',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('personal_lawyer_menufontsize',array(
	    'type' => 'number',
	    'label' => __('Menus Font Size','personal-lawyer'),
	    'section' => 'top_header',
    ));



	// Style setting

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

	// header menushover Color
	$headermenushovercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headersubmenusbgcolor = esc_html__('#fff', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	$headersubmenusbordercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// header submenutext Color
	$headersubmenutextcolor = esc_html__('#000', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenusbghover Color
	$headersubmenusbghovercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header submenustxthover Color
	$headersubmenustxthovercolor = esc_html__('#fff', 'personal-lawyer' );
	$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','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header mobileviewmenutoggle Color
	$headermobileviewmenutogglecolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_mobileviewmenutogglecolor',
    	array(
			'default' => $headermobileviewmenutogglecolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_mobileviewmenutogglecolor',
		array(
		    'label'   		=> __('Mobile View Menu Toggle Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header mobileviewmenutogglehrv Color
	$headermobileviewmenutogglehrvcolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_mobileviewmenutogglehrvcolor',
    	array(
			'default' => $headermobileviewmenutogglehrvcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_mobileviewmenutogglehrvcolor',
		array(
		    'label'   		=> __('Mobile View Menu Toggle Hover Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header mobileviewmenubg Color
	$headermobileviewmenubgcolor = esc_html__('#3c3f6c', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_mobileviewmenubgcolor',
    	array(
			'default' => $headermobileviewmenubgcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_mobileviewmenubgcolor',
		array(
		    'label'   		=> __('Mobile Menu BG Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);


	// header phnicon Color
	$headerphniconcolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phniconcolor',
    	array(
			'default' => $headerphniconcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phniconcolor',
		array(
		    'label'   		=> __('Phone Icon Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phnbg Colo1r
	$headerphnbgcolor1 = esc_html__('#fff', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phnbgcolor1',
    	array(
			'default' => $headerphnbgcolor1,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phnbgcolor1',
		array(
		    'label'   		=> __('Phone BG Color 1','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phnbg Colo2r
	$headerphnbgcolor2 = esc_html__('#fff', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phnbgcolor2',
    	array(
			'default' => $headerphnbgcolor2,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phnbgcolor2',
		array(
		    'label'   		=> __('Phone BG Color 2','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phnborder Colo2r
	$headerphnbordercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phnbordercolor',
    	array(
			'default' => $headerphnbordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phnbordercolor',
		array(
		    'label'   		=> __('Phone Border Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phntxt Color
	$headerphntxtcolor = esc_html__('#fff', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phntxtcolor',
    	array(
			'default' => $headerphntxtcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phntxtcolor',
		array(
		    'label'   		=> __('Phone Text Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header phntxthover Color
	$headerphntxthovercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_phntxthovercolor',
    	array(
			'default' => $headerphntxthovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_phntxthovercolor',
		array(
		    'label'   		=> __('Phone Text Hover Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header mailtxt Color
	$headermailtxtcolor = esc_html__('#fff', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_mailtxtcolor',
    	array(
			'default' => $headermailtxtcolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_mailtxtcolor',
		array(
		    'label'   		=> __('Mail Text Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header mailtxthover Color
	$headermailtxthovercolor = esc_html__('#fe0201', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_mailtxthovercolor',
    	array(
			'default' => $headermailtxthovercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_mailtxthovercolor',
		array(
		    'label'   		=> __('Mail Text Hover Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// header border Color
	$headerbordercolor = esc_html__('#fff', 'personal-lawyer' );
	$wp_customize->add_setting(
    	'header_bordercolor',
    	array(
			'default' => $headerbordercolor,
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'wp_kses_post',
			'priority'      => 3,
		)
	);	

	$wp_customize->add_control( 
		'header_bordercolor',
		array(
		    'label'   		=> __('Border Color','personal-lawyer'),
		    'section'		=> 'top_header',
			'type' 			=> 'color',
			'transport'         => $selective_refresh,
		)  
	);

	// layout setting

	$wp_customize->add_setting('personal_lawyer_header_section_width',array(
        'default' => 'Box Width',
        'sanitize_callback' => 'personallawyer_sanitize_choices',
    ));
    $wp_customize->add_control('personal_lawyer_header_section_width',array(
        'type' => 'select',
        'label' => __('Header Width','personal-lawyer'),
        'choices' => array (
            'Box Width' => __('Box Width','personal-lawyer'),
            'Full Width' => __('Full Width','personal-lawyer')
        ),
        'section' => 'top_header',
    ));

	


	$wp_customize->register_control_type('personallawyer_Tab_Control');
	$wp_customize->register_panel_type( 'personallawyer_WP_Customize_Panel' );
	$wp_customize->register_section_type( 'personallawyer_WP_Customize_Section' );



	

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



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






