<?php 

if ( ! defined( 'ABSPATH' ) ) {	exit; }

// 
add_action( 'after_setup_theme', 'hotelgalaxy_customizer_pro_settings'  );

function hotelgalaxy_customizer_pro_settings(){

	if(!defined('HG_PREMIUM_VERSION')){

		require_once trailingslashit( dirname( __FILE__ ) ) .'customizer/pro-customizer/pro-customizer.php';
	}
}

// 
add_action( 'customize_register', 'hotelgalaxy_set_customizer_helpers', 1 );

function hotelgalaxy_set_customizer_helpers() {

	require_once trailingslashit( get_template_directory() ) . 'inc/customizer/customizer-helpers.php';
}

if ( ! function_exists( 'hotelgalaxy_customize_register' ) ) {

	add_action( 'customize_register', 'hotelgalaxy_customize_register' );

	function hotelgalaxy_customize_register( $wp_customize ) {

		require_once trailingslashit( get_template_directory() ) . 'inc/customizer/customizer-helpers.php';

		$defaults = hotelgalaxy_get_default();	

		$color_default = hotelgalaxy_color_defaults();

		$default_images = hotelgalaxy_default_images();	


		if ( method_exists( $wp_customize, 'register_control_type' ) ) {		

			$wp_customize->register_control_type('Hotelgalaxy_Title_Control');

		}		
		

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/customizer-panels.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/site-information.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/infobar.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/primary-navigation.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/colors.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/services.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/home-slider.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/room-section.php';		

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/home-blog.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/shortcode.php';		

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/icon-callout.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/footer.php';	

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/blog.php';

		if( !defined('HG_BACKGROUND_ADDON_VERSION') ){

			require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/background_image.php';
		}
	}
}



if ( ! function_exists( 'hotelgalaxy_customize_register_typography' ) ) {

	add_action( 'customize_register', 'hotelgalaxy_customize_register_typography' );

	function hotelgalaxy_customize_register_typography( $wp_customize ) {

		if( function_exists('hg_premium_customize_register_fonts' )){
			return;
		}

		require_once trailingslashit( get_template_directory() ) . 'inc/customizer/customizer-helpers.php';

		$default_font = hotelgalaxy_default_fonts();

		if ( method_exists( $wp_customize, 'register_control_type' ) ) {

			$wp_customize->register_control_type( 'HotelGalaxy_Typography_Control' );

			$wp_customize->register_control_type('Hotelgalaxy_Range_Slider_Control');

			$wp_customize->register_control_type('Hotelgalaxy_Title_Control');

		}	

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/typography_body.php';

		require_once trailingslashit( dirname( __FILE__ ) ) . 'customizer/customizer-sections/typography_heading.php';
	}
}


if(! function_exists('hotelgalaxy_customizer_partials')){

	add_action( 'customize_register', 'hotelgalaxy_customizer_partials' );

	function hotelgalaxy_customizer_partials( WP_Customize_Manager $wp_customize ) {

    // Abort if selective refresh is not available.
		if ( ! isset( $wp_customize->selective_refresh ) ) {
			return;
		}

		if ( $wp_customize->get_control( 'blogname' ) ) {
			$wp_customize->get_control( 'blogname' )->priority = 2;
			$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
		}

		if ( $wp_customize->get_control( 'blogdescription' ) ) {
			$wp_customize->get_control( 'blogdescription' )->priority = 4;
			$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
		}				

		if ( $wp_customize->get_control( 'custom_logo' ) ) {
			$wp_customize->get_setting( 'custom_logo' )->transport = 'refresh';
		}

		$wp_customize->selective_refresh->add_partial( 'blogname', array(
			'selector' => '.main-title a',
			'render_callback' => 'hotelgalaxy_customize_partial_blogname',
		) );

		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
			'selector' => '.site-description',
			'render_callback' => 'hotelgalaxy_customize_partial_blogdescription',
		) );


		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[information_title_1]', array(
			'selector' => '#info-1',
			'render_callback' => function(){ return $default['information_title_1']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[information_title_2]', array(
			'selector' => '#info-2',
			'render_callback' => function(){ return $default['information_title_2']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[socialmedia_icon_1]', array(
			'selector' => '.info-bar .user-social',
			'render_callback' => function(){ return $default['socialmedia_icon_1']; },
		) );

		// menu search icon

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[is_menubar_search_icon]', array(
			'selector' => 'a.header_search_btn',
			'render_callback' => function(){ return $default['is_menubar_search_icon']; },
		) );		

		// slider button
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[slider_button_text]', array(
			'selector' => '#hg-main-slider a#read-more',
			'render_callback' => function(){ return $default['slider_button_text']; },
		) );

		// service header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_service_section_header]', array(
			'selector' => '#main-home-service .section-header h2',
			'render_callback' => function(){ return $default['home_service_section_header']; },
		) );

		// service sub header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_service_section_sub_header]', array(
			'selector' => '#main-home-service .section-header .sub-header',
			'render_callback' => function(){ return $default['home_service_section_sub_header']; },
		) );

		// service more button
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_service_button_text]', array(
			'selector' => '#main-home-service aside #read-more',
			'render_callback' => function(){ return $default['home_service_button_text']; },
		) );

		// room header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_room_section_header]', array(
			'selector' => '#main-home-room .section-header h2',
			'render_callback' => function(){ return $default['home_room_section_header']; },
		) );

		// room sub header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_room_section_sub_header]', array(
			'selector' => '#main-home-room .section-header .sub-header',
			'render_callback' => function(){ return $default['home_room_section_sub_header']; },
		) );

		// room more button
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[room_button_text]', array(
			'selector' => '.room-content-area a#read-more',
			'render_callback' => function(){ return $default['room_button_text']; },
		) );

		// blog header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_blog_section_header]', array(
			'selector' => '#main-home-blog .section-header h2',
			'render_callback' => function(){ return $default['home_blog_section_header']; },
		) );

		// blog sub header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_blog_section_sub_header]', array(
			'selector' => '#main-home-blog .section-header .sub-header',
			'render_callback' => function(){ return $default['home_blog_section_sub_header']; },
		) );

		// contact header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_shortcode_section_header]', array(
			'selector' => '#main-home-shortcode .section-header h2',
			'render_callback' => function(){ return $default['home_shortcode_section_header']; },
		) );

		// contact sub header
		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[home_shortcode_section_sub_header]', array(
			'selector' => '#main-home-shortcode .section-header .sub-header',
			'render_callback' => function(){ return $default['home_shortcode_section_sub_header']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[footer_collout_title_1]', array(
			'selector' => '.icon-callout-area #footer-icon-callout-1',
			'render_callback' => function(){ return $default['footer_collout_title_1']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[footer_collout_title_2]', array(
			'selector' => '.icon-callout-area #footer-icon-callout-2',
			'render_callback' => function(){ return $default['footer_collout_title_2']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[footer_collout_title_3]', array(
			'selector' => '.icon-callout-area #footer-icon-callout-3',
			'render_callback' => function(){ return $default['footer_collout_title_3']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[footer_collout_title_4]', array(
			'selector' => '.icon-callout-area #footer-icon-callout-4',
			'render_callback' => function(){ return $default['footer_collout_title_4']; },
		) );

		$wp_customize->selective_refresh->add_partial( 'hotel_galaxy_option[back_to_top]', array(
			'selector' => 'a.scroll-top',
			'render_callback' => function(){ return $default['back_to_top']; },
		) );


	}
}



?>