<?php
function pet_bazaar_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', 'pet-bazaar'),
		) 
	);
	/*=========================================
	Pet Bazaar Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','pet-bazaar'),
			'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' => 'pet_bazaar_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'logo_typography',
		array(
			'type' => 'hidden',
			'label' => __('Typography','pet-bazaar'),
			'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', 'pet-bazaar' ),
				'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', 'pet-bazaar' ),
				'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  Petbazaar_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="https://sellerthemes.com/pet-bazaar-premium/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'typo_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 103,
	));
	$wp_customize->add_control(
		new  Petbazaar_typo__section_upgrade(
		$wp_customize,
		'typo_upgrade_to_pro',
			array(
				'section'				=> 'title_tagline',
			)
		)
	);
	}
	
	
	
	/*=========================================
	Header Navigation
	=========================================*/	
	$wp_customize->add_section(
        'header_navigation',
        array(
        	'priority'      => 4,
            'title' 		=> __('Header Navigation','pet-bazaar'),
			'panel'  		=> 'header_section',
		)
    );
	
	// Cart
	$wp_customize->add_setting(
		'hdr_nav_cart'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_nav_cart',
		array(
			'type' => 'hidden',
			'label' => __('Cart','pet-bazaar'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_cart' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_cart', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'pet-bazaar' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	
	// Contact
	$wp_customize->add_setting(
		'hdr_cnt'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_cnt',
		array(
			'type' => 'hidden',
			'label' => __('Contact','pet-bazaar'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_hdr_contact' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_hdr_contact', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'pet-bazaar' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	$wp_customize->add_setting( 
		'hdr_contact_ttl' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 1,
		) 
	);

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

	$wp_customize->add_control(
	'hdr_contact_subttl', 
		array(
			'label'	      => esc_html__( 'Contact Subtitle', 'pet-bazaar' ),
			'section'     => 'header_navigation',
		) 
	);
	
	// Button
	$wp_customize->add_setting(
		'hdr_button'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 7,
		)
	);

	$wp_customize->add_control(
	'hdr_button',
		array(
			'type' => 'hidden',
			'label' => __('Button','pet-bazaar'),
			'section' => 'header_navigation',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_hdr_btn' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 8,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_hdr_btn', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'pet-bazaar' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	$wp_customize->add_setting( 
		'header_button_label' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 1,
		) 
	);

	$wp_customize->add_control(
	'header_button_label', 
		array(
			'label'	      => esc_html__( 'Button Label', 'pet-bazaar' ),
			'section'     => 'header_navigation',
		) 
	);
		
		$wp_customize->add_setting( 
		'header_button_link' , 
			array(
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',
			'priority' => 1,
		) 
	);

	$wp_customize->add_control(
	'header_button_link', 
		array(
			'label'	      => esc_html__( 'Button Link', 'pet-bazaar' ),
			'section'     => 'header_navigation',
		) 
	);
	
	/*=========================================
	Browse Section
	=========================================*/	
	$wp_customize->add_setting(
		'product_search_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 11,
		)
	);

	$wp_customize->add_control(
	'product_search_head',
		array(
			'type' => 'hidden',
			'label' => __('Product Search','pet-bazaar'),
			'section' => 'header_navigation',
		)
	);
	
	// Hide / Show 
	$wp_customize->add_setting( 
		'hs_product_search' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 12,
		) 
	);
	
	$wp_customize->add_control(
	'hs_product_search', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'pet-bazaar' ),
			'section'     => 'header_navigation',
			'type'        => 'checkbox'
		) 
	);
	
	
	
	/*=========================================
	Sticky Header
	=========================================*/	
	$wp_customize->add_section(
        'sticky_header_set',
        array(
        	'priority'      => 4,
            'title' 		=> __('Sticky Header','pet-bazaar'),
			'panel'  		=> 'header_section',
		)
    );
	
	// Heading
	$wp_customize->add_setting(
		'sticky_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'sticky_head',
		array(
			'type' => 'hidden',
			'label' => __('Sticky Header','pet-bazaar'),
			'section' => 'sticky_header_set',
		)
	);
	$wp_customize->add_setting( 
		'hide_show_sticky' , 
			array(
			'default' => '1',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_checkbox',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'hide_show_sticky', 
		array(
			'label'	      => esc_html__( 'Hide/Show', 'pet-bazaar' ),
			'section'     => 'sticky_header_set',
			'type'        => 'checkbox'
		) 
	);		
	
	//  Sticky Header Logo // 
    $wp_customize->add_setting( 
    	'sticky_header_logo' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/logo'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'pet_bazaar_sanitize_url',	
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'sticky_header_logo' ,
		array(
			'label'          => esc_html__( 'Sticky Logo [If Exists]', 'pet-bazaar'),
			'section'        => 'sticky_header_set',
		) 
	));
	
	
// Pro Upgrade
	class  Petbazaar_sticky_logo__section_upgrade extends WP_Customize_Control {
		public function render_content() { 			
		?>
			<a class="customizer_sticky_logo_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="https://sellerthemes.com/pet-bazaar-premium/" target="_blank"><?php esc_html_e('Upgrade To Pro For More Features','pet-bazaar'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'sticky_logo_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'pet_bazaar_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Petbazaar_sticky_logo__section_upgrade(
		$wp_customize,
		'sticky_logo_upgrade_to_pro',
			array(
				'section'				=> 'sticky_header_set',
			)
		)
	);
}
add_action( 'customize_register', 'pet_bazaar_header_settings' );