<?php
/**
 * relax spa Theme Customizer
 *
 * @package relax_spa
 */

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

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

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

$relax_spa_general_sections = array( 'colors', 'typography', 'sidebar', 'background', 'footer' );
$relax_spa_header_sections = array(  'site-identity', 'social-media', 'general-info');
if( class_exists( 'The_Bootstrap_Themes_Companion' ) ) {
    $relax_spa_homepage_sections = array(  'banner', 'services', 'who-we-are', 'counter', 'why-choose-us', 'testimonial', 'teams', 'offer', 'price' );
} else{
    $relax_spa_homepage_sections = array(  'banner', 'services', 'who-we-are', 'counter', 'why-choose-us', 'offer', );

}

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

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

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


if( fs_relax_spa()->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';



/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function relax_spa_customize_preview_js() {
	wp_enqueue_script(
        'relax_spa_customizer',
        get_theme_file_uri( '/inc/js/customizer.js' ),
        array( 'customize-preview', 'customize-selective-refresh' ),
        RELAX_SPA_VERSION,
        true
    );
}
add_action( 'customize_preview_init', 'relax_spa_customize_preview_js' );


function relax_spa_customizer_scripts() {
    wp_enqueue_script(
        'relax_spa_customize',
        get_template_directory_uri() . '/inc/js/customize.js',
        array( 'jquery' ),
        RELAX_SPA_VERSION,
        true
    );

    $array = array(
        'home' => get_home_url(),
    );
    wp_localize_script( 'relax_spa_customize', 'data', $array );
}
add_action( 'customize_controls_enqueue_scripts', 'relax_spa_customizer_scripts' );

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

/**
 * Render Callback Functions
*/
require get_template_directory() . '/inc/customizer/render-functions.php';

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