<?php
function electromix_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', 'electromix'),
		) 
	);
	/*=========================================
	Electromix Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','electromix'),
			'panel'  		=> 'header_section',
		)
    );
	
	
	
	// Typography
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		$wp_customize->add_setting(
		'logo_typography'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'logo_typography',
		array(
			'type' => 'hidden',
			'label' => __('Typography','electromix'),
			'section' => 'title_tagline',
			'priority' => 100,
		)
	);
	
	// Site Title Font Size// 
		$wp_customize->add_setting(
			'site_ttl_size',
			array(
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage'
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'site_ttl_size', 
			array(
				'label'      => __( 'Site Title Font Size', 'electromix' ),
				'section'  => 'title_tagline',
				'priority' => 101,
				 'media_query'   => true,
                'input_attr'    => array(
                    'mobile'  => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 24,
                    ),
                    'tablet'  => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 24,
                    ),
                    'desktop' => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 24,
                    ),
				)
			) ) 
		);

	// Site Description Font Size// 	
		$wp_customize->add_setting(
			'site_desc_size',
			array(
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage'
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'site_desc_size', 
			array(
				'label'      => __( 'Site Description Font Size', 'electromix' ),
				'section'  => 'title_tagline',
				'priority' => 102,
				 'media_query'   => true,
                'input_attr'    => array(
                    'mobile'  => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 16,
                    ),
                    'tablet'  => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 16,
                    ),
                    'desktop' => array(
                        'min'           => 0,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 16,
                    ),
                ),
			) ) 
		);
		
	// Pro Upgrade
	class  Electromix_typo__section_upgrade extends WP_Customize_Control {
		public function render_content() { 			
		?>
			<a class="customizer_typo_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="<?php echo electromix_premium_links(); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro For More','electromix'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'typo_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'electromix_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 103,
	));
	$wp_customize->add_control(
		new  Electromix_typo__section_upgrade(
		$wp_customize,
		'typo_upgrade_to_pro',
			array(
				'section'				=> 'title_tagline',
			)
		)
	);
	}
	
	/*=========================================
	Above Header Section
	=========================================*/
	$wp_customize->add_section(
        'above_header',
        array(
        	'priority'      => 2,
            'title' 		=> __('Above Header','electromix'),
			'panel'  		=> 'header_section',
		)
    );
	
	/*=========================================
		Header First
	=========================================*/
	$wp_customize->add_setting( 
		'above_header_first' , 
			array(
			'default' => 'custom',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_html',
		) 
	);
	
	$wp_customize->add_control(
	'above_header_first' , 
		array(
			'label'          => __( 'Section Left', 'electromix' ),
			'section'        => 'above_header',
			'type'           => 'hidden',
		) 
	);		
	
	// Header First Link // 
	$wp_customize->add_setting(
    	'enbale_tracking_first',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_html',
		)
	);	

	$wp_customize->add_control( 
		'enbale_tracking_first',
		array(
		    'label'   		=> __('Enable Track Link','electromix'),
		    'section'		=> 'above_header',
			'type' 			=> 'checkbox',
		)  
	);
	
	/*=========================================
	Header Second
	=========================================*/
	
	$wp_customize->add_setting( 
		'above_header_second' , 
			array(
			'default' => 'widget',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_html',
		) 
	);

	$wp_customize->add_control(
	'above_header_second' , 
		array(
			'label'          => __( 'Section Right', 'electromix' ),
			'section'        => 'above_header',
			'type'           => 'hidden',
		)
	);
	
	// Header third Link // 
	$wp_customize->add_setting(
    	'enbale_tracking_second',
    	array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_html',
		)
	);	

	$wp_customize->add_control( 
		'enbale_tracking_second',
		array(
		    'label'   		=> __('Enable Track Link','electromix'),
		    'section'		=> 'above_header',
			'type' 			=> 'checkbox',
		)  
	);
	/*=========================================
	Header Navigation
	=========================================*/	
	$wp_customize->add_section(
        'header_navigation',
        array(
        	'priority'      => 4,
            'title' 		=> __('Header Navigation','electromix'),
			'panel'  		=> 'header_section',
		)
    );
	
	if(class_exists('WooCommerce')):
	// Cart
	$wp_customize->add_setting(
		'hdr_nav_cart'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_nav_cart',
		array(
			'type' => 'hidden',
			'label' => __('Cart','electromix'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_cart' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_cart', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	// Account
	$wp_customize->add_setting(
		'hdr_nav_account'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_nav_account',
		array(
			'type' => 'hidden',
			'label' => __('Account','electromix'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_account' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_account', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	endif;
	
	// Contact
	$wp_customize->add_setting(
		'hdr_cnt'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_cnt',
		array(
			'type' => 'hidden',
			'label' => __('Contact','electromix'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_hdr_contact' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_hdr_contact', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	$wp_customize->add_setting(
		'hdr_contact_icon',
		array(
			'default' => 'fa-mobile',
			'sanitize_callback' => 'sanitize_text_field',
			'capability' => 'edit_theme_options',
		)
	);	

	$wp_customize->add_control(new Electromix_Icon_Picker_Control($wp_customize, 
		'hdr_contact_icon',
		array(
			'label'   		=> __('Icon','electromix'),
			'section' 		=> 'header_navigation',
			'iconset' => 'fa',
			
		))  
	);
	
	$wp_customize->add_setting( 
		'hdr_contact_ttl' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 1,
		) 
	);

	$wp_customize->add_control(
	'hdr_contact_ttl', 
		array(
			'label'	      => esc_html__( 'Contact Title', 'electromix' ),
			'section'     => 'header_navigation',
		) 
	);
		
		$wp_customize->add_setting( 
		'hdr_contact_subttl' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 1,
		) 
	);

	$wp_customize->add_control(
	'hdr_contact_subttl', 
		array(
			'label'	      => esc_html__( 'Contact Subtitle', 'electromix' ),
			'section'     => 'header_navigation',
		) 
	);
	
	if ( class_exists( 'Ecommerce_Comp_Customizer' ) ) {
	// Contact Info
	$wp_customize->add_setting(
		'hdr_nav_info_slider'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'hdr_nav_info_slider',
		array(
			'type' => 'hidden',
			'label' => __('Header Info Slider','electromix'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_hdr_info_slider' , 
			array(
			'default' => '1',	
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_hdr_info_slider', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);	
	
	/**
	* Customizer Repeater for add Support
	*/
		$wp_customize->add_setting( 'hdr_info_slides', 
			array(
			 'sanitize_callback' => 'electromix_repeater_sanitize',
			 'default' => get_default_hdr_slider()
			)
		);

		$wp_customize->add_control( 
			new Electromix_Repeater( $wp_customize, 
			'hdr_info_slides', 
				array(
					'label'   => esc_html__('Slide','electromix'),
					'section' => 'header_navigation',
					'add_field_label'                   => esc_html__( 'Add New Header Info', 'electromix' ),
					'item_name'                         => esc_html__( 'HeaderSlide', 'electromix' ),
					'customizer_repeater_title_control' => true,
					'customizer_repeater_text_control' => true,
					'customizer_repeater_icon_control' => true,
					'customizer_repeater_link_control' => true,
				) 
			) 
		);

		// Upgrade To Pro
		class  Electromix_header_info_section_upgrade extends WP_Customize_Control {
			public function render_content() { 	
				
			?>
				<a class="customizer_header_info_section_premium up-to-pro" style="padding:9px 0; text-align:center; display: none;" href="<?php echo electromix_premium_links(); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro For More','electromix'); ?></a>
				
			<?php }
		}
		
		$wp_customize->add_setting( 'electromix_header_info_upgrade_to_pro', array(
			'capability'			=> 'edit_theme_options',
			'electromix_sanitize_callback'	=> 'wp_filter_nohtml_kses',
			'priority' => 5,
		));
		$wp_customize->add_control(
			new  Electromix_header_info_section_upgrade(
			$wp_customize,
			'electromix_header_info_upgrade_to_pro',
				array(
					'section'				=> 'header_navigation',
				)
			)
		);
	}
	/*=========================================
	Browse Section
	=========================================*/	
	if(class_exists('WooCommerce')):
	$wp_customize->add_setting(
		'product_search_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 11,
		)
	);

	$wp_customize->add_control(
	'product_search_head',
		array(
			'type' => 'hidden',
			'label' => __('Product Search','electromix'),
			'section' => 'header_navigation',
		)
	);
	
	// Hide / Show 
	$wp_customize->add_setting( 
		'hs_product_search' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 12,
		) 
	);
	
	$wp_customize->add_control(
	'hs_product_search', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
		
	// Title
	$wp_customize->add_setting( 
		'most_phrase' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_html',
			'priority' => 3,
		) 
	);
	
	$wp_customize->add_control(
	'most_phrase', 
		array(
			'label'	      => esc_html__( 'Title', 'electromix' ),
			'section'     => 'header_navigation',
			'type'        => 'text'
		) 
	);	
	
	
	// Product Category
	$wp_customize->add_setting(
    'selected_product_categories',
		array(
		'capability' => 'edit_theme_options',
		'priority' => 5,
		'sanitize_callback' => 'electromix_sanitize_html',
		)
	);	
	$wp_customize->add_control( 
	'selected_product_categories', 
		array(
		'label'   => __('Enter Categories','electromix'),
		'section' => 'header_navigation',
		) 
	 );
	 endif;
	
	/*=========================================
	Sticky Header
	=========================================*/	
	$wp_customize->add_section(
        'sticky_header_set',
        array(
        	'priority'      => 4,
            'title' 		=> __('Sticky Header','electromix'),
			'panel'  		=> 'header_section',
		)
    );
	
	// Heading
	$wp_customize->add_setting(
		'sticky_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'sticky_head',
		array(
			'type' => 'hidden',
			'label' => __('Sticky Header','electromix'),
			'section' => 'sticky_header_set',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_sticky' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_sticky', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'electromix' ),
			'section'     => 'sticky_header_set',
			'type'        => 'checkbox'
		) 
	);		
}
add_action( 'customize_register', 'electromix_header_settings' );