<?php    
/**
 *housing-lite Theme Customizer
 *
 * @package Housing Lite
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function housing_lite_customize_register( $wp_customize ) {	
	
	function housing_lite_sanitize_dropdown_pages( $page_id, $setting ) {
	  // Ensure $input is an absolute integer.
	  $page_id = absint( $page_id );
	
	  // If $page_id is an ID of a published page, return it; otherwise, return the default.
	  return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
	}

	function housing_lite_sanitize_checkbox( $checked ) {
		// Boolean check.
		return ( ( isset( $checked ) && true == $checked ) ? true : false );
	} 
	
	function housing_lite_sanitize_phone_number( $phone ) {
		// sanitize phone
		return preg_replace( '/[^\d+]/', '', $phone );
	} 
		
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	
	 //Panel for section & control
	$wp_customize->add_panel( 'housing_lite_themepanel_area', array(
		'priority' => null,
		'capability' => 'edit_theme_options',
		'theme_supports' => '',
		'title' => __( 'Theme Options Panel', 'housing-lite' ),		
	) );
	
	//Site Layout Options
	$wp_customize->add_section('housing_lite_layout_sections',array(
		'title' => __('Site Layout Options','housing-lite'),			
		'priority' => 1,
		'panel' => 	'housing_lite_themepanel_area',          
	));		
	
	$wp_customize->add_setting('housing_lite_boxlayoutoptions',array(
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'housing_lite_boxlayoutoptions', array(
    	'section'   => 'housing_lite_layout_sections',    	 
		'label' => __('Check to Show Box Layout','housing-lite'),
		'description' => __('If you want to show box layout please check the Box Layout Option.','housing-lite'),
    	'type'      => 'checkbox'
     )); //Site Layout Options 
	
	$wp_customize->add_setting('housing_lite_template_coloroptions',array(
		'default' => '#fc5a0a',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'housing_lite_template_coloroptions',array(
			'label' => __('Color Options','housing-lite'),			
			'description' => __('More color options available in PRO Version','housing-lite'),
			'section' => 'colors',
			'settings' => 'housing_lite_template_coloroptions'
		))
	);
	
	//header Contact info section
	$wp_customize->add_section('housing_lite_headercontactinfo_sections',array(
		'title' => __('Header Contact info Section','housing-lite'),				
		'priority' => null,
		'panel' => 	'housing_lite_themepanel_area',
	));	
	
	$wp_customize->add_setting('housing_lite_header_addressbar',array(
		'sanitize_callback' => 'sanitize_text_field'
	));
	
	$wp_customize->add_control('housing_lite_header_addressbar',array(
		'type' => 'text',
		'label' => __('enter contact address here.','housing-lite'),
		'section' => 'housing_lite_headercontactinfo_sections'
	));	
	
	$wp_customize->add_setting('housing_lite_phonenumber',array(
		'default' => null,
		'sanitize_callback' => 'housing_lite_sanitize_phone_number'	
	));
	
	$wp_customize->add_control('housing_lite_phonenumber',array(	
		'type' => 'text',
		'label' => __('enter phone number here','housing-lite'),
		'section' => 'housing_lite_headercontactinfo_sections',
		'setting' => 'housing_lite_phonenumber'
	));		
		
	
	$wp_customize->add_setting('housing_lite_show_contactinfo_sections',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_show_contactinfo_sections', array(
	   'settings' => 'housing_lite_show_contactinfo_sections',
	   'section'   => 'housing_lite_headercontactinfo_sections',
	   'label'     => __('Check To show This Section','housing-lite'),
	   'type'      => 'checkbox'
	 ));//Show Header Contact section
	 
	 
	 //Header Social icons
	$wp_customize->add_section('housing_lite_sociallinks_sections',array(
		'title' => __('Header Social Sections','housing-lite'),
		'description' => __( 'Add social icons link here to display icons in header.', 'housing-lite' ),			
		'priority' => null,
		'panel' => 	'housing_lite_themepanel_area', 
	));
	
	$wp_customize->add_setting('housing_lite_fbiconlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'	
	));
	
	$wp_customize->add_control('housing_lite_fbiconlink',array(
		'label' => __('Add facebook link here','housing-lite'),
		'section' => 'housing_lite_sociallinks_sections',
		'setting' => 'housing_lite_fbiconlink'
	));	
	
	$wp_customize->add_setting('housing_lite_twiconlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('housing_lite_twiconlink',array(
		'label' => __('Add twitter link here','housing-lite'),
		'section' => 'housing_lite_sociallinks_sections',
		'setting' => 'housing_lite_twiconlink'
	));
	
	$wp_customize->add_setting('housing_lite_gplusiconlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('housing_lite_gplusiconlink',array(
		'label' => __('Add google plus link here','housing-lite'),
		'section' => 'housing_lite_sociallinks_sections',
		'setting' => 'housing_lite_gplusiconlink'
	));
	
	$wp_customize->add_setting('housing_lite_linkediniconlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('housing_lite_linkediniconlink',array(
		'label' => __('Add linkedin link here','housing-lite'),
		'section' => 'housing_lite_sociallinks_sections',
		'setting' => 'housing_lite_linkediniconlink'
	));
	
	$wp_customize->add_setting('housing_lite_instagramiconlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('housing_lite_instagramiconlink',array(
		'label' => __('Add instagram link here','housing-lite'),
		'section' => 'housing_lite_sociallinks_sections',
		'setting' => 'housing_lite_instagramiconlink'
	));
	
	$wp_customize->add_setting('housing_lite_show_sociallink_sections',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_show_sociallink_sections', array(
	   'settings' => 'housing_lite_show_sociallink_sections',
	   'section'   => 'housing_lite_sociallinks_sections',
	   'label'     => __('Check To show This Section','housing-lite'),
	   'type'      => 'checkbox'
	 ));//Show Header Social icons area
	 
	 
	// Front Slider Section		
	$wp_customize->add_section( 'housing_lite_homeslider_section', array(
		'title' => __('Frontpage Slider Sections', 'housing-lite'),
		'priority' => null,
		'description' => __('Default image size for slider is 1400 x 752 pixel.','housing-lite'), 
		'panel' => 	'housing_lite_themepanel_area',           			
    ));
	
	$wp_customize->add_setting('housing_lite_sliderpge1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('housing_lite_sliderpge1',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 1:','housing-lite'),
		'section' => 'housing_lite_homeslider_section'
	));	
	
	$wp_customize->add_setting('housing_lite_sliderpge2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('housing_lite_sliderpge2',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 2:','housing-lite'),
		'section' => 'housing_lite_homeslider_section'
	));	
	
	$wp_customize->add_setting('housing_lite_sliderpge3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('housing_lite_sliderpge3',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 3:','housing-lite'),
		'section' => 'housing_lite_homeslider_section'
	));	// Homepage Slider Section
	
	$wp_customize->add_setting('housing_lite_sliderpgebutton',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('housing_lite_sliderpgebutton',array(	
		'type' => 'text',
		'label' => __('enter slider Read more button name here','housing-lite'),
		'section' => 'housing_lite_homeslider_section',
		'setting' => 'housing_lite_sliderpgebutton'
	)); // Home Slider Read More Button Text
	
	$wp_customize->add_setting('housing_lite_show_homeslider_section',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_show_homeslider_section', array(
	    'settings' => 'housing_lite_show_homeslider_section',
	    'section'   => 'housing_lite_homeslider_section',
	    'label'     => __('Check To Show This Section','housing-lite'),
	    'type'      => 'checkbox'
	 ));//Show Frontpage Slider Section	
	 
	 
	 
	  // About Us Sections
	$wp_customize->add_section('housing_lite_aboutus_sections', array(
		'title' => __('About Us Section','housing-lite'),
		'description' => __('Select Pages from the dropdown for about us section','housing-lite'),
		'priority' => null,
		'panel' => 	'housing_lite_themepanel_area',          
	));		
	
	$wp_customize->add_setting('housing_lite_aboutus_pgecolumn',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'housing_lite_aboutus_pgecolumn',array(
		'type' => 'dropdown-pages',			
		'section' => 'housing_lite_aboutus_sections',
	));		
	
	$wp_customize->add_setting('housing_lite_show_aboutus_pgecolumn',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_show_aboutus_pgecolumn', array(
	    'settings' => 'housing_lite_show_aboutus_pgecolumn',
	    'section'   => 'housing_lite_aboutus_sections',
	    'label'     => __('Check To Show This Section','housing-lite'),
	    'type'      => 'checkbox'
	));//Show About Sports Club 
	 
	 
	 //Three column Services Section
	$wp_customize->add_section('housing_lite_featuresservices_sections', array(
		'title' => __('Three column Services Section','housing-lite'),
		'description' => __('Select pages from the dropdown for 3 column services sections','housing-lite'),
		'priority' => null,
		'panel' => 	'housing_lite_themepanel_area',          
	));	
	
	
	$wp_customize->add_setting('housing_lite_shorttitletext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('housing_lite_shorttitletext',array(	
		'type' => 'text',
		'label' => __('enter short title for services','housing-lite'),
		'section' => 'housing_lite_featuresservices_sections',
		'setting' => 'housing_lite_shorttitletext'
	)); // short title text for services
	
	
	$wp_customize->add_setting('housing_lite_shortdesctext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('housing_lite_shortdesctext',array(	
		'type' => 'text',
		'label' => __('enter short description for services','housing-lite'),
		'section' => 'housing_lite_featuresservices_sections',
		'setting' => 'housing_lite_shortdesctext'
	)); // short title text for services
	
	
	$wp_customize->add_setting('housing_lite_features_pagecol1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'housing_lite_features_pagecol1',array(
		'type' => 'dropdown-pages',			
		'section' => 'housing_lite_featuresservices_sections',
	));		
	
	$wp_customize->add_setting('housing_lite_features_pagecol2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'housing_lite_features_pagecol2',array(
		'type' => 'dropdown-pages',			
		'section' => 'housing_lite_featuresservices_sections',
	));
	
	$wp_customize->add_setting('housing_lite_features_pagecol3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'housing_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'housing_lite_features_pagecol3',array(
		'type' => 'dropdown-pages',			
		'section' => 'housing_lite_featuresservices_sections',
	));	
	
	
	$wp_customize->add_setting('housing_lite_show_features_sections',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_show_features_sections', array(
	   'settings' => 'housing_lite_show_features_sections',
	   'section'   => 'housing_lite_featuresservices_sections',
	   'label'     => __('Check To Show This Section','housing-lite'),
	   'type'      => 'checkbox'
	 ));//Show Three column Services Section
	 
	 
	//Sidebar Settings
	$wp_customize->add_section('housing_lite_sidebar_options', array(
		'title' => __('Sidebar Options','housing-lite'),		
		'priority' => null,
		'panel' => 	'housing_lite_themepanel_area',          
	));	
	
	$wp_customize->add_setting('housing_lite_hidesidebar_from_homepage',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_hidesidebar_from_homepage', array(
	   'settings' => 'housing_lite_hidesidebar_from_homepage',
	   'section'   => 'housing_lite_sidebar_options',
	   'label'     => __('Check to hide sidebar from latest post page','housing-lite'),
	   'type'      => 'checkbox'
	 ));// Hide sidebar from latest post page
	 
	 
	 $wp_customize->add_setting('housing_lite_hidesidebar_singlepost',array(
		'default' => false,
		'sanitize_callback' => 'housing_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'housing_lite_hidesidebar_singlepost', array(
	   'settings' => 'housing_lite_hidesidebar_singlepost',
	   'section'   => 'housing_lite_sidebar_options',
	   'label'     => __('Check to hide sidebar from single post','housing-lite'),
	   'type'      => 'checkbox'
	 ));// hide sidebar single post	 

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

function housing_lite_custom_css(){ 
?>
	<style type="text/css"> 					
        a, .listview_blogstyle h2 a:hover,
        #sidebar ul li a:hover,						
        .listview_blogstyle h3 a:hover,		
        .postmeta a:hover,
		.site-navigation .menu a:hover,
		.site-navigation .menu a:focus,
		.site-navigation .menu ul a:hover,
		.site-navigation .menu ul a:focus,
		.site-navigation ul li a:hover, 
		.site-navigation ul li.current-menu-item a,
		.site-navigation ul li.current-menu-parent a.parent,
		.site-navigation ul li.current-menu-item ul.sub-menu li a:hover, 			
        .button:hover,
		.nivo-caption h2 span,
		h2.services_title span,			
		.blog_postmeta a:hover,		
		.site-footer ul li a:hover, 
		.site-footer ul li.current_page_item a		
            { color:<?php echo esc_html( get_theme_mod('housing_lite_template_coloroptions','#fc5a0a')); ?>;}					 
            
        .pagination ul li .current, .pagination ul li a:hover, 
        #commentform input#submit:hover,
		.orangetopstrip,
		.orangetopstrip:after,		
        .nivo-controlNav a.active,
		.sd-search input, .sd-top-bar-nav .sd-search input,			
		a.blogreadmore,			
		.nivo-caption .slide_morebtn,
		.learnmore:hover,		
		.copyrigh-wrapper:before,
		.infodtlbx a.get_an_enquiry:hover,									
        #sidebar .search-form input.search-submit,				
        .wpcf7 input[type='submit'],				
        nav.pagination .page-numbers.current,		
		.blogreadbtn,
		a.getanappointment,
		.widget-title-tab,		
        .toggle a	
            { background-color:<?php echo esc_html( get_theme_mod('housing_lite_template_coloroptions','#fc5a0a')); ?>;}
			
		
		.tagcloud a:hover,		
		.socialmedia a:hover,
		.site-footer h5::after,
		.aboutus_thumbox:after,
		.shortdesc_right,
		h3.widget-title		
            { border-color:<?php echo esc_html( get_theme_mod('housing_lite_template_coloroptions','#fc5a0a')); ?>;}
			
					
		 button:focus,
		input[type="button"]:focus,
		input[type="reset"]:focus,
		input[type="submit"]:focus,
		input[type="text"]:focus,
		input[type="email"]:focus,
		input[type="url"]:focus,
		input[type="password"]:focus,
		input[type="search"]:focus,
		input[type="number"]:focus,
		input[type="tel"]:focus,
		input[type="range"]:focus,
		input[type="date"]:focus,
		input[type="month"]:focus,
		input[type="week"]:focus,
		input[type="time"]:focus,
		input[type="datetime"]:focus,
		input[type="datetime-local"]:focus,
		input[type="color"]:focus,
		textarea:focus,
		#templatelayout a:focus
            { box-shadow: inset 0 0 3px <?php echo esc_html( get_theme_mod('housing_lite_template_coloroptions','#fc5a0a')); ?>;}				
	
    </style> 
<?php                                                                                        
}
         
add_action('wp_head','housing_lite_custom_css');	 

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function housing_lite_customize_preview_js() {
	wp_enqueue_script( 'housing_lite_customizer', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '19062019', true );
}
add_action( 'customize_preview_init', 'housing_lite_customize_preview_js' );