<?php
/**
 * travel-tour Theme Customizer
 *
 * @package Travel Tour
 */

require get_template_directory() . '/inc/google-fonts.php';

$panels   = array( 'general-panel', 'homepage-panel' );

$general_sections = array(
    'colors',
    'typography',
    'site-identity',
    'sidebar',
    'blog-list',
    'background',
    'footer',
    'general',
    'post-options'
);

$homepage_sections = array(
    'banner-section',
    'search-section',
    'info-section',
    'slider-section',
    'trips-section',
    'special-offer',
    'cta-section',
    'blog-section',
    'testimonial-section'
);

if( ! empty( $panels ) ) {
	foreach( $panels as $panel ){
	    require get_template_directory() . '/inc/customizer/panels/' . $panel . '.php';
	}
}

if( ! empty( $general_sections ) ) {
    foreach( $general_sections as $section ) {
        require get_template_directory() . '/inc/customizer/sections/general-panel/' . $section . '.php';
    }
}

if( ! empty( $homepage_sections ) ) {
	foreach( $homepage_sections as $section ) {
	    require get_template_directory() . '/inc/customizer/sections/homepage-sections/' . $section . '.php';
	}
}

if( fs_travel_tour()->is_free_plan() ) {
    require get_template_directory() . '/inc/customizer/sections/upgrade-to-pro.php';
}

require get_template_directory() . '/inc/customizer/sections/sort-homepage-section.php';

/**
 * Enqueue the customizer javascript.
 */
function travel_tour_customize_preview_js() {
    wp_enqueue_script(
        'travel-tour-customizer-preview',
        get_template_directory_uri() . '/js/customizer.js',
        array( 'jquery' ),
        TRAVEL_TOUR_VERSION,
        true
    );
}
add_action( 'customize_preview_init', 'travel_tour_customize_preview_js' );

/**
 * Binds Customizer CSS directives for free theme version.
 */
function travel_tour_customizer_css() {
    wp_enqueue_style(
        'travel_tour_customizer_css',
        get_template_directory_uri() . '/inc/css/customizer.css',
        array(),
        TRAVEL_TOUR_VERSION
    );
}
if ( fs_travel_tour()->is_free_plan() ) {
    add_action( 'customize_controls_enqueue_scripts', 'travel_tour_customizer_css' );
}

/**
 * Sanitization Functions
*/
require get_template_directory() . '/inc/customizer/sanitization-functions.php';