<?php
function laxity_header_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	/*=========================================
	Header Navigation
	=========================================*/
	$wp_customize->add_section(
        'header_navigation',
        array(
        	'priority'      => 4,
            'title' 		=> __('Logo Right Content','laxity'),
			'panel'  		=> 'header_section',
		)
    );
	
	// Contact Info Head
	$wp_customize->add_setting(
		'nav_contact_info_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_text',
			'priority'  => 3
		)
	);

	$wp_customize->add_control(
	'nav_contact_info_head',
		array(
			'type' => 'hidden',
			'label' => __('Contact Info','laxity'),
			'section' => 'header_navigation',
		)
	);
	
	//  Hide/Show  // 
	$wp_customize->add_setting( 
		'hs_nav_contact_info' , 
			array(
			'default' => '1',
			'capability' => 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_select',
			'priority'      => 4,
		) 
	);
	
	$wp_customize->add_control(
	'hs_nav_contact_info', 
		array(
			'label'	      => esc_html__( 'Hide / Show Section', 'laxity' ),
			'section'     => 'header_navigation',
			'type'           => 'radio',
			'choices'        => 
			array(
				'1' => 'Show',
				'0'  => 'Hide'
			) 		
		) 
	);
	
	// Contact Info Head
	$wp_customize->add_setting(
		'nav_contact_info1_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_text',
			'priority'  => 5
		)
	);

	$wp_customize->add_control(
	'nav_contact_info1_head',
		array(
			'type' => 'hidden',
			'label' => __('Contact Info First','laxity'),
			'section' => 'header_navigation',
		)
	);
	
	
	// Icon 1
	$wp_customize->add_setting(
    	'nav_ct_info1_icon',
    	array(
			'default' => 'fa-clock-o',
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 6
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info1_icon',
		array(
		    'label'   => __('Icon','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	// Title 1
	$wp_customize->add_setting(
    	'nav_ct_info1_ttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 7,
			'transport'         => $selective_refresh,
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info1_ttl',
		array(
		    'label'   => __('Title','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	// Subtitle 1
	$wp_customize->add_setting(
    	'nav_ct_info1_subttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 8,
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info1_subttl',
		array(
		    'label'   => __('Subtitle','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	// Contact Info Head
	$wp_customize->add_setting(
		'nav_contact_info2_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_text',
			'priority'  => 11
		)
	);
	
	$wp_customize->add_control(
	'nav_contact_info2_head',
		array(
			'type' => 'hidden',
			'label' => __('Contact Info Second','laxity'),
			'section' => 'header_navigation',
		)
	);
	
	// Icon 1
	$wp_customize->add_setting(
    	'nav_ct_info2_icon',
    	array(
			'default' => 'fa-phone',
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 12
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info2_icon',
		array(
		    'label'   => __('Icon','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	// Title 2
	$wp_customize->add_setting(
    	'nav_ct_info2_ttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 13,
			'transport'         => $selective_refresh,
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info2_ttl',
		array(
		    'label'   => __('Title','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	// Subtitle 2
	$wp_customize->add_setting(
    	'nav_ct_info2_subttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 14
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info2_subttl',
		array(
		    'label'   => __('Subtitle','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	// Contact Info Head
	$wp_customize->add_setting(
		'nav_contact_info3_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_text',
			'priority'  => 16
		)
	);

	$wp_customize->add_control(
	'nav_contact_info3_head',
		array(
			'type' => 'hidden',
			'label' => __('Contact Info Third','laxity'),
			'section' => 'header_navigation',
		)
	);
	
	
	// Icon 1
	$wp_customize->add_setting(
    	'nav_ct_info3_icon',
    	array(
			'default' => 'fa-clock-o',
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 17
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info3_icon',
		array(
		    'label'   => __('Icon','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	// Title 2
	$wp_customize->add_setting(
    	'nav_ct_info3_ttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 18,
			'transport'         => $selective_refresh,
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info3_ttl',
		array(
		    'label'   => __('Title','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	// Subtitle 3
	$wp_customize->add_setting(
    	'nav_ct_info3_subttl',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'  => 19
		)
	);	

	$wp_customize->add_control( 
		'nav_ct_info3_subttl',
		array(
		    'label'   => __('Subtitle','laxity'),
		    'section' => 'header_navigation',
			'type' => 'text'
		)  
	);
	
	
	/*=========================================
	Contact Info 2
	=========================================*/
	$wp_customize->add_section(
        'hdr_nav_contact_info2',
        array(
        	'priority'      => 4,
            'title' 		=> __('Contact Info 2','laxity'),
			'panel'  		=> 'header_section',
		)
    );
	
	// Contact Info Head
	$wp_customize->add_setting(
		'nav_contact_infos2_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_text',
			'priority'  => 11
		)
	);

	$wp_customize->add_control(
	'nav_contact_infos2_head',
		array(
			'type' => 'hidden',
			'label' => __('Contact Info 2','laxity'),
			'section' => 'hdr_nav_contact_info2',
		)
	);
	
	//  Hide/Show  // 
	$wp_customize->add_setting( 
		'hs_nav_contact_info2' , 
			array(
			'default' => '1',
			'capability' => 'edit_theme_options',
			'sanitize_callback' => 'specia_sanitize_select',
			'priority'      => 12,
		) 
	);
	
	$wp_customize->add_control(
	'hs_nav_contact_info2', 
		array(
			'label'	      => esc_html__( 'Hide / Show Section', 'laxity' ),
			'section'     => 'hdr_nav_contact_info2',
			'type'        => 'radio',
			'choices'        => 
			array(
				'1' => 'Show',
				'0'  => 'Hide'
			) 
		) 
	);		
	
	// Icon
	$wp_customize->add_setting(
    	'hdr_nav_contact_icon2',
    	array(
	        'default'			=> 'fa-hourglass-end',
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'priority'      => 13,

		)
	);	
	
	$wp_customize->add_control(
		'hdr_nav_contact_icon2',
		array(
		    'label'   		=> __('Icon','laxity'),
			'type' => 'text',
		    'section' 		=> 'hdr_nav_contact_info2',
		)  
	);
	
	// Title
	$wp_customize->add_setting(
    	'hdr_nav_contact_ttl2',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'transport'         => $selective_refresh,
			'priority'      => 14,
		)
	);	

	$wp_customize->add_control( 
		'hdr_nav_contact_ttl2',
		array(
		    'label'   => __('Title','laxity'),
		    'section' => 'hdr_nav_contact_info2',
			'type' => 'text',
		)  
	);
	
	
	// Subtitle
	$wp_customize->add_setting(
    	'hdr_nav_contact_subttl2',
    	array(
			'sanitize_callback' => 'specia_sanitize_html',
			'capability' => 'edit_theme_options',
			'transport'         => $selective_refresh,
			'priority'      => 15,
		)
	);	

	$wp_customize->add_control( 
		'hdr_nav_contact_subttl2',
		array(
		    'label'   => __('Subtitle','laxity'),
		    'section' => 'hdr_nav_contact_info2',
			'type' => 'text',
		)  
	);
	
	// Link
	$wp_customize->add_setting(
    	'hdr_nav_contact_link2',
    	array(
			'sanitize_callback' => 'specia_sanitize_url',
			'capability' => 'edit_theme_options',
			'priority'      => 16,
		)
	);	

	$wp_customize->add_control( 
		'hdr_nav_contact_link2',
		array(
		    'label'   => __('Link','laxity'),
		    'section' => 'hdr_nav_contact_info2',
			'type' => 'text',
		)  
	);
}

add_action( 'customize_register', 'laxity_header_setting' );

// Header section selective refresh
function laxity_home_header_section_partials( $wp_customize ){
	
	//nav_ct_info1_ttl
	$wp_customize->selective_refresh->add_partial( 'nav_ct_info1_ttl', array(
		'selector'            => '.header-info .widget_first .text',
		'settings'            => 'nav_ct_info1_ttl',
		'render_callback'  => 'laxity_nav_ct_info1_ttl_render_callback',	
	) );
	
	//nav_ct_info2_ttl
	$wp_customize->selective_refresh->add_partial( 'nav_ct_info2_ttl', array(
		'selector'            => '.header-info .widget_second .text',
		'settings'            => 'nav_ct_info2_ttl',
		'render_callback'  => 'laxity_nav_ct_info2_ttl_render_callback',	
	) );
	
	//nav_ct_info3_ttl
	$wp_customize->selective_refresh->add_partial( 'nav_ct_info3_ttl', array(
		'selector'            => '.header-info .widget_third .text',
		'settings'            => 'nav_ct_info3_ttl',
		'render_callback'  => 'laxity_nav_ct_info3_ttl_render_callback',	
	) );
	
	//hdr_nav_contact_ttl2
	$wp_customize->selective_refresh->add_partial( 'hdr_nav_contact_ttl2', array(
		'selector'            => '.navigator-wrapper .menu-right .contact-area .text',
		'settings'            => 'hdr_nav_contact_ttl2',
		'render_callback'  => 'laxity_hdr_nav_contact_ttl2_render_callback',	
	) );
	
	//hdr_nav_contact_subttl2
	$wp_customize->selective_refresh->add_partial( 'hdr_nav_contact_subttl2', array(
		'selector'            => '.navigator-wrapper .menu-right .contact-area .title',
		'settings'            => 'hdr_nav_contact_subttl2',
		'render_callback'  => 'laxity_hdr_nav_contact_subttl2_render_callback',	
	) );
	}

add_action( 'customize_register', 'laxity_home_header_section_partials' );



// nav_ct_info1_ttl
function laxity_nav_ct_info1_ttl_render_callback() {
	return get_theme_mod( 'nav_ct_info1_ttl' );
}

// nav_ct_info2_ttl
function laxity_nav_ct_info2_ttl_render_callback() {
	return get_theme_mod( 'nav_ct_info2_ttl' );
}

// nav_ct_info3_ttl
function laxity_nav_ct_info3_ttl_render_callback() {
	return get_theme_mod( 'nav_ct_info3_ttl' );
}

// hdr_nav_contact_ttl2
function laxity_hdr_nav_contact_ttl2_render_callback() {
	return get_theme_mod( 'hdr_nav_contact_ttl2' );
}

// hdr_nav_contact_subttl2
function laxity_hdr_nav_contact_subttl2_render_callback() {
	return get_theme_mod( 'hdr_nav_contact_subttl2' );
}