<?php    
/**
 *makeup-lite Theme Customizer
 *
 * @package Makeup Lite
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function makeup_lite_customize_register( $wp_customize ) {	
	
	function makeup_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 makeup_lite_sanitize_checkbox( $checked ) {
		// Boolean check.
		return ( ( isset( $checked ) && true == $checked ) ? true : false );
	} 
	
	function makeup_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( 'makeup_lite_panel_section', array(
		'priority' => null,
		'capability' => 'edit_theme_options',
		'theme_supports' => '',
		'title' => __( 'Theme Options Panel', 'makeup-lite' ),		
	) );
	
	//Site Layout Options
	$wp_customize->add_section('makeup_lite_layout_option',array(
		'title' => __('Site Layout Options','makeup-lite'),			
		'priority' => 1,
		'panel' => 	'makeup_lite_panel_section',          
	));		
	
	$wp_customize->add_setting('makeup_lite_site_layout_options',array(
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
	));	 

	$wp_customize->add_control( 'makeup_lite_site_layout_options', array(
    	'section'   => 'makeup_lite_layout_option',    	 
		'label' => __('Check to Show Box Layout','makeup-lite'),
		'description' => __('If you want to show box layout please check the Box Layout Option.','makeup-lite'),
    	'type'      => 'checkbox'
     )); //Site Layout Options 
	
	$wp_customize->add_setting('makeup_lite_site_color_codes',array(
		'default' => '#ff6f61',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'makeup_lite_site_color_codes',array(
			'label' => __('Color Options','makeup-lite'),			
			'description' => __('More color options available in PRO Version','makeup-lite'),
			'section' => 'colors',
			'settings' => 'makeup_lite_site_color_codes'
		))
	);
	
	$wp_customize->add_setting('makeup_lite_site_hovercolor_codes',array(
		'default' => '#bf4b40',
		'sanitize_callback' => 'sanitize_hex_color'
	));
	
	$wp_customize->add_control(
		new WP_Customize_Color_Control($wp_customize,'makeup_lite_site_hovercolor_codes',array(
			'label' => __('Hover Color Options','makeup-lite'),			
			'description' => __('More color options in PRO Version','makeup-lite'),
			'section' => 'colors',
			'settings' => 'makeup_lite_site_hovercolor_codes'
		))
	);		
	
	//Header Right Contact info section
	$wp_customize->add_section('makeup_lite_headerinfo_part',array(
		'title' => __('Header Right Contact info','makeup-lite'),				
		'priority' => null,
		'panel' => 	'makeup_lite_panel_section',
	));	
	
	$wp_customize->add_setting('makeup_lite_header_phoneno',array(
		'default' => null,
		'sanitize_callback' => 'makeup_lite_sanitize_phone_number'	
	));
	
	$wp_customize->add_control('makeup_lite_header_phoneno',array(	
		'type' => 'text',
		'label' => __('enter phone number here','makeup-lite'),
		'section' => 'makeup_lite_headerinfo_part',
		'setting' => 'makeup_lite_header_phoneno'
	));	
	
	
	$wp_customize->add_setting('makeup_lite_header_emailid',array(
		'sanitize_callback' => 'sanitize_email'
	));
	
	$wp_customize->add_control('makeup_lite_header_emailid',array(
		'type' => 'email',
		'label' => __('enter email id here.','makeup-lite'),
		'section' => 'makeup_lite_headerinfo_part'
	));	
	
	
	$wp_customize->add_setting('makeup_lite_show_header_contactarea',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_show_header_contactarea', array(
	   'settings' => 'makeup_lite_show_header_contactarea',
	   'section'   => 'makeup_lite_headerinfo_part',
	   'label'     => __('Check To show This Section','makeup-lite'),
	   'type'      => 'checkbox'
	 ));//Show Header Contact section
	 
	 
	 //Header Social icons
	$wp_customize->add_section('makeup_lite_social_sections',array(
		'title' => __('Header social icons','makeup-lite'),
		'description' => __( 'Add social icons link here to display icons in header.', 'makeup-lite' ),			
		'priority' => null,
		'panel' => 	'makeup_lite_panel_section', 
	));
	
	$wp_customize->add_setting('makeup_lite_facebook_link',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'	
	));
	
	$wp_customize->add_control('makeup_lite_facebook_link',array(
		'label' => __('Add facebook link here','makeup-lite'),
		'section' => 'makeup_lite_social_sections',
		'setting' => 'makeup_lite_facebook_link'
	));	
	
	$wp_customize->add_setting('makeup_lite_twitter_link',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('makeup_lite_twitter_link',array(
		'label' => __('Add twitter link here','makeup-lite'),
		'section' => 'makeup_lite_social_sections',
		'setting' => 'makeup_lite_twitter_link'
	));
	
	$wp_customize->add_setting('makeup_lite_googleplus_link',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('makeup_lite_googleplus_link',array(
		'label' => __('Add google plus link here','makeup-lite'),
		'section' => 'makeup_lite_social_sections',
		'setting' => 'makeup_lite_googleplus_link'
	));
	
	$wp_customize->add_setting('makeup_lite_linkedin_link',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('makeup_lite_linkedin_link',array(
		'label' => __('Add linkedin link here','makeup-lite'),
		'section' => 'makeup_lite_social_sections',
		'setting' => 'makeup_lite_linkedin_link'
	));
	
	$wp_customize->add_setting('makeup_lite_instagram_link',array(
		'default' => null,
		'sanitize_callback' => 'esc_url_raw'
	));
	
	$wp_customize->add_control('makeup_lite_instagram_link',array(
		'label' => __('Add instagram link here','makeup-lite'),
		'section' => 'makeup_lite_social_sections',
		'setting' => 'makeup_lite_instagram_link'
	));
	
	$wp_customize->add_setting('makeup_lite_show_social_sections',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_show_social_sections', array(
	   'settings' => 'makeup_lite_show_social_sections',
	   'section'   => 'makeup_lite_social_sections',
	   'label'     => __('Check To show This Section','makeup-lite'),
	   'type'      => 'checkbox'
	 ));//Show Header Social icons area
	
	
	// Header Slider Section		
	$wp_customize->add_section( 'makeup_lite_frontpage_slider_section', array(
		'title' => __('Homepage Slider Sections', 'makeup-lite'),
		'priority' => null,
		'description' => __('Default image size for slider is 1400 x 653 pixel.','makeup-lite'), 
		'panel' => 	'makeup_lite_panel_section',           			
    ));
	
	$wp_customize->add_setting('makeup_lite_frontslidebx1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('makeup_lite_frontslidebx1',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 1:','makeup-lite'),
		'section' => 'makeup_lite_frontpage_slider_section'
	));	
	
	$wp_customize->add_setting('makeup_lite_frontslidebx2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('makeup_lite_frontslidebx2',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 2:','makeup-lite'),
		'section' => 'makeup_lite_frontpage_slider_section'
	));	
	
	$wp_customize->add_setting('makeup_lite_frontslidebx3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control('makeup_lite_frontslidebx3',array(
		'type' => 'dropdown-pages',
		'label' => __('Select page for slider 3:','makeup-lite'),
		'section' => 'makeup_lite_frontpage_slider_section'
	));	// Slider Section Options	
	
	$wp_customize->add_setting('makeup_lite_frontslide_moretext',array(
		'default' => null,
		'sanitize_callback' => 'sanitize_text_field'	
	));
	
	$wp_customize->add_control('makeup_lite_frontslide_moretext',array(	
		'type' => 'text',
		'label' => __('enter slider Read more button name here','makeup-lite'),
		'section' => 'makeup_lite_frontpage_slider_section',
		'setting' => 'makeup_lite_frontslide_moretext'
	)); // Slider Read More Button Text
	
	$wp_customize->add_setting('makeup_lite_show_frontslide_section',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_show_frontslide_section', array(
	    'settings' => 'makeup_lite_show_frontslide_section',
	    'section'   => 'makeup_lite_frontpage_slider_section',
	     'label'     => __('Check To Show This Section','makeup-lite'),
	   'type'      => 'checkbox'
	 ));//Show Front Slider Section	
	 
	 
	 //Left Two Column Services area
	$wp_customize->add_section('makeup_lite_twocolumn_servicespart', array(
		'title' => __('Two Column Services Part','makeup-lite'),
		'description' => __('Select pages from the dropdown for services area','makeup-lite'),
		'priority' => null,
		'panel' => 	'makeup_lite_panel_section',          
	));	
	
	$wp_customize->add_setting('makeup_lite_2column_pagebx1',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'makeup_lite_2column_pagebx1',array(
		'type' => 'dropdown-pages',			
		'section' => 'makeup_lite_twocolumn_servicespart',
	));		
	
	$wp_customize->add_setting('makeup_lite_2column_pagebx2',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'makeup_lite_2column_pagebx2',array(
		'type' => 'dropdown-pages',			
		'section' => 'makeup_lite_twocolumn_servicespart',
	));
	
	$wp_customize->add_setting('makeup_lite_2column_pagebx3',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'makeup_lite_2column_pagebx3',array(
		'type' => 'dropdown-pages',			
		'section' => 'makeup_lite_twocolumn_servicespart',
	));
	
	$wp_customize->add_setting('makeup_lite_2column_pagebx4',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'makeup_lite_2column_pagebx4',array(
		'type' => 'dropdown-pages',			
		'section' => 'makeup_lite_twocolumn_servicespart',
	));	
	
	$wp_customize->add_setting('makeup_lite_show_2column_pagebx',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_show_2column_pagebx', array(
	   'settings' => 'makeup_lite_show_2column_pagebx',
	   'section'   => 'makeup_lite_twocolumn_servicespart',
	   'label'     => __('Check To Show This Section','makeup-lite'),
	   'type'      => 'checkbox'
	 ));//Show four box Services Area
	 
	 
	 //Welcome Right Section 
	$wp_customize->add_section('makeup_lite_welcome_sections', array(
		'title' => __('Welcome Section','makeup-lite'),
		'description' => __('Select Pages from the dropdown for welcome section','makeup-lite'),
		'priority' => null,
		'panel' => 	'makeup_lite_panel_section',          
	));		
	
	$wp_customize->add_setting('makeup_lite_page_for_welcometosite',array(
		'default' => '0',			
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'makeup_lite_sanitize_dropdown_pages'
	));
 
	$wp_customize->add_control(	'makeup_lite_page_for_welcometosite',array(
		'type' => 'dropdown-pages',			
		'section' => 'makeup_lite_welcome_sections',
	));	
	
	
	$wp_customize->add_setting('makeup_lite_show_welcometosite',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_show_welcometosite', array(
	    'settings' => 'makeup_lite_show_welcometosite',
	    'section'   => 'makeup_lite_welcome_sections',
	    'label'     => __('Check To Show This Section','makeup-lite'),
	    'type'      => 'checkbox'
	));//Show Welcome Area
	 
	//Sidebar Settings
	$wp_customize->add_section('makeup_lite_sidebar_options', array(
		'title' => __('Sidebar Options','makeup-lite'),		
		'priority' => null,
		'panel' => 	'makeup_lite_panel_section',          
	));	
	
	$wp_customize->add_setting('makeup_lite_hidesidebar_from_homepage',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_hidesidebar_from_homepage', array(
	   'settings' => 'makeup_lite_hidesidebar_from_homepage',
	   'section'   => 'makeup_lite_sidebar_options',
	   'label'     => __('Check to hide sidebar from latest post page','makeup-lite'),
	   'type'      => 'checkbox'
	 ));// Hide sidebar from latest post page
	 
	 
	 $wp_customize->add_setting('makeup_lite_hidesidebar_singlepost',array(
		'default' => false,
		'sanitize_callback' => 'makeup_lite_sanitize_checkbox',
		'capability' => 'edit_theme_options',
	));	 
	
	$wp_customize->add_control( 'makeup_lite_hidesidebar_singlepost', array(
	   'settings' => 'makeup_lite_hidesidebar_singlepost',
	   'section'   => 'makeup_lite_sidebar_options',
	   'label'     => __('Check to hide sidebar from single post','makeup-lite'),
	   'type'      => 'checkbox'
	 ));// hide sidebar single post	 

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

function makeup_lite_custom_css(){ 
?>
	<style type="text/css"> 					
        a, .poststyle_list h2 a:hover,
        #sidebar ul li a:hover,						
        .poststyle_list h3 a:hover,		
        .postmeta a:hover,			
        .button:hover,
		.ftr_social_icons a:hover,			
		.blog_postmeta a:hover,
		.wel2column h4 a:hover,
		.site-footer ul li a:hover, 
		.site-footer ul li.current_page_item a		
            { color:<?php echo esc_html( get_theme_mod('makeup_lite_site_color_codes','#ff6f61')); ?>;}					 
            
        .pagination ul li .current, .pagination ul li a:hover, 
        #commentform input#submit:hover,		
        .nivo-controlNav a.active,
		.sd-search input, .sd-top-bar-nav .sd-search input,			
		a.blogreadmore,	
		.twocolumnbx:hover,
		#hdrnavigator,
		.site-navigation .menu ul,
		h3.widget-title,
		.woocommerce div.product form.cart .button,
		.nivo-caption .slide_morebtn,
		.learnmore:hover,
		.copyrigh-wrapper:before,
		.infobox a.get_an_enquiry:hover,
		.welcome_contentwrap .btnstyle1,													
        #sidebar .search-form input.search-submit,				
        .wpcf7 input[type='submit'],				
        nav.pagination .page-numbers.current,		
		.blogreadbtn:hover,		
		.navigation_bar:after,		
        .toggle a	
            { background-color:<?php echo esc_html( get_theme_mod('makeup_lite_site_color_codes','#ff6f61')); ?>;}
			
		
		.tagcloud a:hover,		
		.hdr_social a:hover,		
		.welcome_contentwrap p,
		h3.widget-title::after,		
		blockquote	        
            { border-color:<?php echo esc_html( get_theme_mod('makeup_lite_site_color_codes','#ff6f61')); ?>;}
			
	/*Hover CSS Cover*/		
		.nivo-caption .slide_morebtn: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
			{ background-color:<?php echo esc_html( get_theme_mod('makeup_lite_site_hovercolor_codes','#bf4b40')); ?>;}	
			
	
			
         	
    </style> 
<?php                                                              
}
         
add_action('wp_head','makeup_lite_custom_css');	 

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