<?php
/**
 * Customizer callback functions.
 * 
 * Contains callback functions used to render and manage customizer settings and controls.
 *
 * @package Yaatra
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

    if ( ! function_exists( 'yaatra_cb_has_enable_preloader' ) ) :

        /**
         * Active callback: check if preloader option is enabled.
         *
         * @since 1.0.0
         *
         * @param WP_Customize_Control $control WP_Customize_Control instance.
         *
         * @return bool Whether the control is active to the current preview.
         */
        function yaatra_cb_has_enable_preloader( $control ) {

            $setting = $control->manager->get_setting( 'yaatra_preloader_enable' );

            if ( ! $setting ) {
                return false;
            }

            return (bool) $setting->value();
        }

    endif;

/*---------------------------------- Frontpage Settings Panel Callback ------------------------*/

    if ( ! function_exists( 'yaatra_front_banner_option_active_callback' ) ) :

        /**
         * Active callback: check if front banner option is enabled.
         *
         * @since 1.0.0
         *
         * @param WP_Customize_Control $control Control instance.
         * @return bool
         */
        function yaatra_front_banner_option_active_callback( $control ) {

            $setting = $control->manager->get_setting( 'yaatra_front_banner_option' );

            if ( ! $setting ) {
                return false;
            }

            return (bool) $setting->value();
        }
        
    endif;

/*---------------------------------- Innerpage Panel Callback ---------------------------------*/

    if ( ! function_exists( 'yaatra_cb_has_enable_single_posts_related' ) ) :

        /**
         * Active callback: check if single posts related section option is enabled.
         *
         * @since 1.0.0
         *
         * @param WP_Customize_Control $control WP_Customize_Control instance.
         *
         * @return bool Whether the control is active to the current preview.
         */
        function yaatra_cb_has_enable_single_posts_related( $control ) {

            $setting = $control->manager->get_setting( 'yaatra_enable_related_posts' );

            if ( ! $setting ) {
                return false;
            }

            return (bool) $setting->value();
        }

    endif;