<?php    
/**
 *home-guard Theme Customizer
 *
 * @package Home Guard
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function home_guard_customize_register( $wp_customize ) {	
	
	function home_guard_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 home_guard_sanitize_checkbox( $checked ) {
		// Boolean check.
		return ( ( isset( $checked ) && true == $checked ) ? true : false );
	} 
	
	function home_guard_sanitize_phone_number( $phone ) {
		// sanitize phone
		return preg_replace( '/[^\d+]/', '', $phone );
	} 
	
	
	function home_guard_sanitize_excerptrange( $number, $setting ) {	
		// Ensure input is an absolute integer.
		$number = absint( $number );	
		// Get the input attributes associated with the setting.
		$atts = $setting->manager->get_control( $setting->id )->input_attrs;	
		// Get minimum number in the range.
		$min = ( isset( $atts['min'] ) ? $atts['min'] : $number );	
		// Get maximum number in the range.
		$max = ( isset( $atts['max'] ) ? $atts['max'] : $number );	
		// Get step.
		$step = ( isset( $atts['step'] ) ? $atts['step'] : 1 );	
		// If the number is within the valid range, return it; otherwise, return the default
		return ( $min <= $number && $number <= $max && is_int( $number / $step ) ? $number : $setting->default );
	}

	function home_guard_sanitize_number_absint( $number, $setting ) {
		// Ensure $number is an absolute integer (whole number, zero or greater).
		$number = absint( $number );		
		// If the input is an absolute integer, return it; otherwise, return the default
		return ( $number ? $number : $setting->default );
	}
	
	// Ensure is an absolute integer
	function home_guard_sanitize_choices( $input, $setting ) {
		global $wp_customize; 
		$control = $wp_customize->get_control( $setting->id ); 
		if ( array_key_exists( $input, $control->choices ) ) {
			return $input;
		} else {
			return $setting->default;
		}
	}
	
		
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	
	$wp_customize->selective_refresh->add_partial( 'blogname', array(
		'selector' => '.logo h1 a',
		'render_callback' => 'home_guard_customize_partial_blogname',
	) );
	$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
		'selector' => '.logo p',
		'render_callback' => 'home_guard_customize_partial_blogdescription',
	) );
		
	 	
	 //Panel for section & control
	$wp_customize->add_panel( 'home_guard_panelsettings', array(
		'priority' => 4,
		'capability' => 'edit_theme_options',
		'theme_supports' => '',
		'title' => __( 'Home Guard Theme Settings', 'home-guard' ),		
	) );

	$wp_customize->add_section('home_guard_layoutstyle',array(
		'title' => __('Layout Style','home-guard'),			
		'priority' => 1,
		'panel' => 	'home_guard_panelsettings',          
	));		
	
	$wp_customize->add_setting('home_guard_layoutoption',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_layoutoption', array(
    	'section'   => 'home_guard_layoutstyle',    	 
		'label' => __('Check to Show Box Layout','home-guard'),
		'description' => __('check for box layout','home-guard'),
    	'type'      => 'checkbox'
     )); //Box Layout Options 
	
	$wp_customize->add_setting('home_guard_colorscheme',array(
		'default' => '#57b857',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'home_guard_colorscheme',array(
			'label' => __('Color Scheme','home-guard'),			
			'section' => 'colors',
			'settings' => 'home_guard_colorscheme'
		))
	);
	
	$wp_customize->add_setting('home_guard_menufontcolor',array(
		'default' => '#333333',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'home_guard_menufontcolor',array(
			'label' => __('Navigation font Color','home-guard'),			
			'section' => 'colors',
			'settings' => 'home_guard_menufontcolor'
		))
	);
	
	
	$wp_customize->add_setting('home_guard_menufontactivecolor',array(
		'default' => '#57b857',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'home_guard_menufontactivecolor',array(
			'label' => __('Navigation Hover/Active Color','home-guard'),			
			'section' => 'colors',
			'settings' => 'home_guard_menufontactivecolor'
		))
	);
	
	 //Header Contact details
	$wp_customize->add_section('home_guard_hdrcontactdetails',array(
		'title' => __('Header Contact Details','home-guard'),				
		'priority' => null,
		'panel' => 	'home_guard_panelsettings',
	));	
	
	
	$wp_customize->add_setting('home_guard_emailid',array(
		'sanitize_callback' => 'sanitize_email'
	));
	
	$wp_customize->add_control('home_guard_emailid',array(
		'type' => 'email',
		'label' => __('enter email id here.','home-guard'),
		'section' => 'home_guard_hdrcontactdetails'
	));		
	
	
	$wp_customize->add_setting('home_guard_phoneno',array(
		'default' => null,
		'sanitize_callback' => 'home_guard_sanitize_phone_number'	
	));
	
	$wp_customize->add_control('home_guard_phoneno',array(	
		'type' => 'text',
		'label' => __('Enter phone number here','home-guard'),
		'section' => 'home_guard_hdrcontactdetails',
		'setting' => 'home_guard_phoneno'
	));	
		
	$wp_customize->add_setting('home_guard_topfblink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'	
	));
	
	$wp_customize->add_control('home_guard_topfblink',array(
		'label' => __('Add facebook link here','home-guard'),
		'section' => 'home_guard_hdrcontactdetails',
		'setting' => 'home_guard_topfblink'
	));	
	
	$wp_customize->add_setting('home_guard_toptwlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('home_guard_toptwlink',array(
		'label' => __('Add twitter link here','home-guard'),
		'section' => 'home_guard_hdrcontactdetails',
		'setting' => 'home_guard_toptwlink'
	));

	
	$wp_customize->add_setting('home_guard_topinlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('home_guard_topinlink',array(
		'label' => __('Add linkedin link here','home-guard'),
		'section' => 'home_guard_hdrcontactdetails',
		'setting' => 'home_guard_topinlink'
	));
	
	$wp_customize->add_setting('home_guard_topigramlink',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('home_guard_topigramlink',array(
		'label' => __('Add instagram link here','home-guard'),
		'section' => 'home_guard_hdrcontactdetails',
		'setting' => 'home_guard_topigramlink'
	));
	
	
	$wp_customize->add_setting('home_guard_show_hdinfodetails',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'home_guard_show_hdinfodetails', array(
	   'settings' => 'home_guard_show_hdinfodetails',
	   'section'   => 'home_guard_hdrcontactdetails',
	   'label'     => __('Check To show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show Contact Details Sections
	
	 	
	//Frontpage  Section		
	$wp_customize->add_section( 'home_guard_frontslider_sections', array(
		'title' => __('Frontapage Slider Sections', 'home-guard'),
		'priority' => null,
		'description' => __('Default image size for slider is 1400 x 670 pixel.','home-guard'), 
		'panel' => 	'home_guard_panelsettings',           			
    ));
	
	$wp_customize->add_setting('home_guard_frontslider_pge1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('home_guard_frontslider_pge1',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slide 1:','home-guard'),
		'section' => 'home_guard_frontslider_sections'
	));	
	
	$wp_customize->add_setting('home_guard_frontslider_pge2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('home_guard_frontslider_pge2',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slide 2:','home-guard'),
		'section' => 'home_guard_frontslider_sections'
	));	
	
	$wp_customize->add_setting('home_guard_frontslider_pge3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('home_guard_frontslider_pge3',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slide 3:','home-guard'),
		'section' => 'home_guard_frontslider_sections'
	));	//frontpage Slider Section	
	
	//Slider Excerpt Length
	$wp_customize->add_setting( 'home_guard_excerpt_length_frontslider', array(
		'default'              => 15,
		'type'                 => 'theme_mod',		
		'sanitize_callback'    => 'home_guard_sanitize_excerptrange',		
	) );
	$wp_customize->add_control( 'home_guard_excerpt_length_frontslider', array(
		'label'       => __( 'Slider Excerpt length','home-guard' ),
		'section'     => 'home_guard_frontslider_sections',
		'type'        => 'range',
		'settings'    => 'home_guard_excerpt_length_frontslider','input_attrs' => array(
			'step'             => 1,
			'min'              => 0,
			'max'              => 50,
		),
	) );	
	
	$wp_customize->add_setting('home_guard_frontslider_pge_btntext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_frontslider_pge_btntext',array(	
		'type' => 'text',
		'label' => __('enter button name here','home-guard'),
		'section' => 'home_guard_frontslider_sections',
		'setting' => 'home_guard_frontslider_pge_btntext'
	)); // slider read more button text
	
	$wp_customize->add_setting('home_guard_show_frontslider_sections',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'home_guard_show_frontslider_sections', array(
	    'settings' => 'home_guard_show_frontslider_sections',
	    'section'   => 'home_guard_frontslider_sections',
	    'label'     => __('Check To Show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show Header Slider Settings	
	 
	 
	 //Three page Services Sections
	$wp_customize->add_section('home_guard_fix3page_sections', array(
		'title' => __('Three Page Column Sections','home-guard'),
		'description' => __('Select pages from the dropdown for three column sections','home-guard'),
		'priority' => null,
		'panel' => 	'home_guard_panelsettings',          
	));	
		
	$wp_customize->add_setting('home_guard_fix3page_column1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_fix3page_column1',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_fix3page_sections',
	));		
	
	$wp_customize->add_setting('home_guard_fix3page_column2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_fix3page_column2',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_fix3page_sections',
	));
	
	$wp_customize->add_setting('home_guard_fix3page_column3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_fix3page_column3',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_fix3page_sections',
	));		

	$wp_customize->add_setting( 'home_guard_fix3pagecolumn_excerpt_length', array(
		'default'              => 0,
		'type'                 => 'theme_mod',		
		'sanitize_callback'    => 'home_guard_sanitize_excerptrange',		
	) );
	$wp_customize->add_control( 'home_guard_fix3pagecolumn_excerpt_length', array(
		'label'       => __( 'four page box excerpt length','home-guard' ),
		'section'     => 'home_guard_fix3page_sections',
		'type'        => 'range',
		'settings'    => 'home_guard_fix3pagecolumn_excerpt_length','input_attrs' => array(
			'step'             => 1,
			'min'              => 0,
			'max'              => 50,
		),
	) );	
	
	$wp_customize->add_setting('home_guard_show_fix3page_sections',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));		
	
	$wp_customize->add_control( 'home_guard_show_fix3page_sections', array(
	   'settings' => 'home_guard_show_fix3page_sections',
	   'section'   => 'home_guard_fix3page_sections',
	   'label'     => __('Check To Show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show three page column sections
	 
	 
	 //Best Solution For Security System Sections
	$wp_customize->add_section('home_guard_security_solution_system', array(
		'title' => __('Best Solution For Security System Sections','home-guard'),
		'description' => __('Select pages from the dropdown for Best Solution For Security System','home-guard'),
		'priority' => null,
		'panel' => 	'home_guard_panelsettings',          
	));	
		
	$wp_customize->add_setting('home_guard_securitysolution',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_securitysolution',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_security_solution_system',
	));	

	$wp_customize->add_setting( 'home_guard_securitysolution_excerpt_length', array(
		'default'              => 30,
		'type'                 => 'theme_mod',		
		'sanitize_callback'    => 'home_guard_sanitize_excerptrange',		
	) );
	$wp_customize->add_control( 'home_guard_securitysolution_excerpt_length', array(
		'label'       => __( 'page excerpt length','home-guard' ),
		'section'     => 'home_guard_security_solution_system',
		'type'        => 'range',
		'settings'    => 'home_guard_securitysolution_excerpt_length','input_attrs' => array(
			'step'             => 1,
			'min'              => 0,
			'max'              => 50,
		),
	) );
	
	$wp_customize->add_setting('home_guard_callustextfor2sec',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_callustextfor2sec',array(	
		'type' => 'text',
		'label' => __('Enter call us text here','home-guard'),
		'section' => 'home_guard_security_solution_system',
		'setting' => 'home_guard_callustextfor2sec'
	));	
	
	$wp_customize->add_setting('home_guard_phonefor2sec',array(
		'default' => null,
		'sanitize_callback' => 'home_guard_sanitize_phone_number'	
	));
	
	$wp_customize->add_control('home_guard_phonefor2sec',array(	
		'type' => 'text',
		'label' => __('Enter phone number here','home-guard'),
		'section' => 'home_guard_security_solution_system',
		'setting' => 'home_guard_phonefor2sec'
	));	
		
	
	$wp_customize->add_setting('home_guard_show_securitysolution',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));		
	
	$wp_customize->add_control( 'home_guard_show_securitysolution', array(
	   'settings' => 'home_guard_show_securitysolution',
	   'section'   => 'home_guard_security_solution_system',
	   'label'     => __('Check To Show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show Best Solution For Security System Sections
	 
	 
	 //Six Column Circle Services Sections
	$wp_customize->add_section('home_guard_sixcolumnservices_sections', array(
		'title' => __('Six Column Circle Services Sections','home-guard'),
		'description' => __('Select pages from the dropdown for six column section','home-guard'),
		'priority' => null,
		'panel' => 	'home_guard_panelsettings',          
	));	
		
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg1',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));		
	
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg2',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));
	
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg3',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));	
	
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg4',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg4',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));	
	
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg5',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg5',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));	
	
	$wp_customize->add_setting('home_guard_sixcolumnservices_pg6',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'home_guard_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'home_guard_sixcolumnservices_pg6',array(
		'type' => 'dropdown-pages',			
		'section' => 'home_guard_sixcolumnservices_sections',
	));		

	$wp_customize->add_setting( 'home_guard_sixcolumnservices_excerpt_length', array(
		'default'              => 0,
		'type'                 => 'theme_mod',		
		'sanitize_callback'    => 'home_guard_sanitize_excerptrange',		
	) );
	$wp_customize->add_control( 'home_guard_sixcolumnservices_excerpt_length', array(
		'label'       => __( 'excerpt length','home-guard' ),
		'section'     => 'home_guard_sixcolumnservices_sections',
		'type'        => 'range',
		'settings'    => 'home_guard_sixcolumnservices_excerpt_length','input_attrs' => array(
			'step'             => 1,
			'min'              => 0,
			'max'              => 50,
		),
	) );	
	
	$wp_customize->add_setting('home_guard_show_sixcolumnservices_sections',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));		
	
	$wp_customize->add_control( 'home_guard_show_sixcolumnservices_sections', array(
	   'settings' => 'home_guard_show_sixcolumnservices_sections',
	   'section'   => 'home_guard_sixcolumnservices_sections',
	   'label'     => __('Check To Show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show Six column page sections
	 
	 
	  //Footer Sections
	$wp_customize->add_section('home_guard_footer_section', array(
		'title' => __('Footer Section','home-guard'),
		'description' => __('footer contact ingo','home-guard'),
		'priority' => null,
		'panel' => 	'home_guard_panelsettings',          
	));	
	
	$wp_customize->add_setting('home_guard_footlocationtext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_footlocationtext',array(	
		'type' => 'text',
		'label' => __('Enter location text here','home-guard'),
		'section' => 'home_guard_footer_section',
		'setting' => 'home_guard_footlocationtext'
	));	
	
	$wp_customize->add_setting('home_guard_footaddress',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_footaddress',array(	
		'type' => 'text',
		'label' => __('Enter footer address here','home-guard'),
		'section' => 'home_guard_footer_section',
		'setting' => 'home_guard_footaddress'
	));	
	
	$wp_customize->add_setting('home_guard_footmailustext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_footmailustext',array(	
		'type' => 'text',
		'label' => __('Enter mail us text here','home-guard'),
		'section' => 'home_guard_footer_section',
		'setting' => 'home_guard_footmailustext'
	));	
	
	
	$wp_customize->add_setting('home_guard_footemailadd',array(
		'sanitize_callback' => 'sanitize_email'
	));
	
	$wp_customize->add_control('home_guard_footemailadd',array(
		'type' => 'email',
		'label' => __('enter email address for footer','home-guard'),
		'section' => 'home_guard_footer_section'
	));	
	
	
	$wp_customize->add_setting('home_guard_footofficehrstext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_footofficehrstext',array(	
		'type' => 'text',
		'label' => __('Enter office hrs text here','home-guard'),
		'section' => 'home_guard_footer_section',
		'setting' => 'home_guard_footofficehrstext'
	));
	
	$wp_customize->add_setting('home_guard_footofficetiming',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('home_guard_footofficetiming',array(	
		'type' => 'text',
		'label' => __('Enter office timing here','home-guard'),
		'section' => 'home_guard_footer_section',
		'setting' => 'home_guard_footofficetiming'
	));	
		
	
	$wp_customize->add_setting('home_guard_show_footer_section',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));		
	
	$wp_customize->add_control( 'home_guard_show_footer_section', array(
	   'settings' => 'home_guard_show_footer_section',
	   'section'   => 'home_guard_footer_section',
	   'label'     => __('Check To Show This Section','home-guard'),
	   'type'      => 'checkbox'
	 ));//Show Footer Sections
	 
	 
	 //Blog Posts Settings
	$wp_customize->add_panel( 'home_guard_blogsettings_panel', array(
		'priority' => 3,
		'capability' => 'edit_theme_options',
		'theme_supports' => '',
		'title' => __( 'Blog Posts Settings', 'home-guard' ),		
	) );
	
	$wp_customize->add_section('home_guard_blogmeta_options',array(
		'title' => __('Blog Meta Options','home-guard'),			
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel', 	         
	));		
	
	$wp_customize->add_setting('home_guard_hide_blogdate',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_hide_blogdate', array(
    	'label' => __('Check to hide post date','home-guard'),	
		'section'   => 'home_guard_blogmeta_options', 
		'setting' => 'home_guard_hide_blogdate',		
    	'type'      => 'checkbox'
     )); //Blog Date
	 
	 
	 $wp_customize->add_setting('home_guard_hide_postcats',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_hide_postcats', array(
		'label' => __('Check to hide post category','home-guard'),	
    	'section'   => 'home_guard_blogmeta_options',		
		'setting' => 'home_guard_hide_postcats',		
    	'type'      => 'checkbox'
     )); //blogposts category	 
	 
	 
	 $wp_customize->add_section('home_guard_postfeatured_image',array(
		'title' => __('Posts Featured image','home-guard'),			
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel', 	         
	));		
	
	$wp_customize->add_setting('home_guard_hide_postfeatured_image',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_hide_postfeatured_image', array(
		'label' => __('Check to hide post featured image','home-guard'),
    	'section'   => 'home_guard_postfeatured_image',		
		'setting' => 'home_guard_hide_postfeatured_image',	
    	'type'      => 'checkbox'
     )); //Posts featured image
	 
	 
	 $wp_customize->add_setting('home_guard_blogimg_fullwidth',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_blogimg_fullwidth', array(
		'label' => __('Check to featured image Full Width','home-guard'),
    	'section'   => 'home_guard_postfeatured_image',		
		'setting' => 'home_guard_blogimg_fullwidth',	
    	'type'      => 'checkbox'
     )); //posts featured full
	 
	  
	 $wp_customize->add_section('home_guard_postmorebtn',array(
		'title' => __('Posts Read More Button','home-guard'),			
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel', 	         
	 ));	
	 
	 $wp_customize->add_setting('home_guard_postmorebuttontext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	)); //blog read more button text
	
	$wp_customize->add_control('home_guard_postmorebuttontext',array(	
		'type' => 'text',
		'label' => __('Read more button text for blog posts','home-guard'),
		'section' => 'home_guard_postmorebtn',
		'setting' => 'home_guard_postmorebuttontext'
	)); //Post read more button text	
	
	$wp_customize->add_section('home_guard_postcontent_settings',array(
		'title' => __('Posts Excerpt Options','home-guard'),			
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel', 	         
	 ));	 
	 
	$wp_customize->add_setting( 'home_guard_postexcerptrange', array(
		'default'              => 30,
		'type'                 => 'theme_mod',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'home_guard_sanitize_excerptrange',		
	) );
	
	$wp_customize->add_control( 'home_guard_postexcerptrange', array(
		'label'       => __( 'Excerpt length','home-guard' ),
		'section'     => 'home_guard_postcontent_settings',
		'type'        => 'range',
		'settings'    => 'home_guard_postexcerptrange','input_attrs' => array(
			'step'             => 1,
			'min'              => 0,
			'max'              => 50,
		),
	) );

    $wp_customize->add_setting('home_guard_postsfullcontent_options',array(
        'default' => 'Excerpt',     
        'sanitize_callback' => 'home_guard_sanitize_choices'
	));
	
	$wp_customize->add_control('home_guard_postsfullcontent_options',array(
        'type' => 'select',
        'label' => __('Posts Content','home-guard'),
        'section' => 'home_guard_postcontent_settings',
        'choices' => array(
        	'Content' => __('Content','home-guard'),
            'Excerpt' => __('Excerpt','home-guard'),
            'No Content' => __('No Excerpt','home-guard')
        ),
	) ); 
	
	
	$wp_customize->add_section('home_guard_postsinglemeta',array(
		'title' => __('Posts Single Settings','home-guard'),			
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel', 	         
	));	
	
	$wp_customize->add_setting('home_guard_hide_postdate_fromsingle',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_hide_postdate_fromsingle', array(
    	'label' => __('Check to hide post date from single','home-guard'),	
		'section'   => 'home_guard_postsinglemeta', 
		'setting' => 'home_guard_hide_postdate_fromsingle',		
    	'type'      => 'checkbox'
     )); //Hide Posts date from single
	 
	 
	 $wp_customize->add_setting('home_guard_hide_postcats_fromsingle',array(
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'home_guard_hide_postcats_fromsingle', array(
		'label' => __('Check to hide post category from single','home-guard'),	
    	'section'   => 'home_guard_postsinglemeta',		
		'setting' => 'home_guard_hide_postcats_fromsingle',		
    	'type'      => 'checkbox'
     )); //Hide blogposts category single
	 
	 
	 //Sidebar Settings
	$wp_customize->add_section('home_guard_sidebarsettings', array(
		'title' => __('Sidebar Settings','home-guard'),		
		'priority' => null,
		'panel' => 	'home_guard_blogsettings_panel',          
	));		
	 
	$wp_customize->add_setting('home_guard_hidesidebar_blogposts',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'home_guard_hidesidebar_blogposts', array(
	   'settings' => 'home_guard_hidesidebar_blogposts',
	   'section'   => 'home_guard_sidebarsettings',
	   'label'     => __('Check to hide sidebar from homepage','home-guard'),
	   'type'      => 'checkbox'
	 ));//hide sidebar blog posts 
	
		 
	 $wp_customize->add_setting('home_guard_hidesidebar_singleposts',array(
		'default' => false,
		'sanitize_callback' => 'home_guard_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'home_guard_hidesidebar_singleposts', array(
	   'settings' => 'home_guard_hidesidebar_singleposts',
	   'section'   => 'home_guard_sidebarsettings',
	   'label'     => __('Check to hide sidebar from single post','home-guard'),
	   'type'      => 'checkbox'
	 ));// Hide sidebar single post	 
		 
}
add_action( 'customize_register', 'home_guard_customize_register' );

function home_guard_custom_css(){ 
?>
	<style type="text/css"> 					
        a,
        #sidebar ul li a:hover,
		#sidebar ol li a:hover,							
        .hg-blog-list h3 a:hover,
		.site-footer ul li a:hover, 
		.site-footer ul li.current_page_item a,		
        .postmeta a:hover,
		.aboutliststyle ul li::before,
		h4.sub_title,			 			
        .button:hover,
		.fix3column h4 a:hover,		
		h2.services_title span,			
		.hg-blog-meta a:hover,
		.hg-blog-meta a:focus,
		blockquote::before	
            { color:<?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?>;}					 
            
        .pagination ul li .current, .pagination ul li a:hover, 
        #commentform input#submit:hover,
		.fix3column.highlight,
		.fix3column:hover a.morehg:after,
		.security-phoneBX,
		.sixcirclecolumn:hover .thumbbx,		
        .nivo-controlNav a.active,
		.sd-search input, .sd-top-bar-nav .sd-search input,			
		a.blogreadmore,
		.hdr-topstrip,
		.copyrigh-wrapper:before,										
        #sidebar .search-form input.search-submit,				
        .wpcf7 input[type='submit'],				
        nav.pagination .page-numbers.current,		
		.morebutton,	
		.nivo-directionNav a:hover,	
		.nivo-caption .slidermorebtn:hover		
            { background-color:<?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?>;}
			
			
		.fix3column:hover        	
            { background-color:<?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?> !important;}	
			
		
		.tagcloud a:hover,
		.logo::after,
		.fix3column:hover .PageColumnBG,
		blockquote
            { border-color:<?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?>;}
			
		.sixcirclecolumn:hover .thumbbx:before
            { border-top-color:<?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?>;}				
			
		#SiteWrapper a:focus,
		input[type="date"]:focus,
		input[type="search"]:focus,
		input[type="number"]:focus,
		input[type="tel"]:focus,
		input[type="button"]:focus,
		input[type="month"]:focus,
		button:focus,
		input[type="text"]:focus,
		input[type="email"]:focus,
		input[type="range"]:focus,		
		input[type="password"]:focus,
		input[type="datetime"]:focus,
		input[type="week"]:focus,
		input[type="submit"]:focus,
		input[type="datetime-local"]:focus,		
		input[type="url"]:focus,
		input[type="time"]:focus,
		input[type="reset"]:focus,
		input[type="color"]:focus,
		textarea:focus
            { border:1px solid <?php echo esc_html( get_theme_mod('home_guard_colorscheme','#57b857')); ?>;}	
			
		
		.site-navigation a,
		.site-navigation ul li.current_page_parent ul.sub-menu li a,
		.site-navigation ul li.current_page_parent ul.sub-menu li.current_page_item ul.sub-menu li a,
		.site-navigation ul li.current-menu-ancestor ul.sub-menu li.current-menu-item ul.sub-menu li a  			
            { color:<?php echo esc_html( get_theme_mod('home_guard_menufontcolor','#333333')); ?>;}	
			
		
		.site-navigation ul.nav-menu .current_page_item > a,
		.site-navigation ul.nav-menu .current-menu-item > a,
		.site-navigation ul.nav-menu .current_page_ancestor > a,
		.site-navigation ul.nav-menu .current-menu-ancestor > a, 
		.site-navigation .nav-menu a:hover,
		.site-navigation .nav-menu a:focus,
		.site-navigation .nav-menu ul a:hover,
		.site-navigation .nav-menu ul a:focus,
		.site-navigation ul li a:hover, 
		.site-navigation ul li.current-menu-item a,			
		.site-navigation ul li.current_page_parent ul.sub-menu li.current-menu-item a,
		.site-navigation ul li.current_page_parent ul.sub-menu li a:hover,
		.site-navigation ul li.current-menu-item ul.sub-menu li a:hover,
		.site-navigation ul li.current-menu-ancestor ul.sub-menu li.current-menu-item ul.sub-menu li a:hover 		 			
            { color:<?php echo esc_html( get_theme_mod('home_guard_menufontactivecolor','#57b857')); ?>;}
			
		.hdrtopcart .cart-count
            { background-color:<?php echo esc_html( get_theme_mod('home_guard_menufontactivecolor','#57b857')); ?>;}		
			
		#SiteWrapper .site-navigation a:focus		 			
            { border:1px solid <?php echo esc_html( get_theme_mod('home_guard_menufontactivecolor','#57b857')); ?>;}	
	
    </style> 
<?php                                                                                                                                                                                      
}
         
add_action('wp_head','home_guard_custom_css');	 

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