<?php
/**
* Custom Functions.
*
* @package Car Booking
*/

if( !function_exists( 'car_booking_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function car_booking_sanitize_sidebar_option( $car_booking_input ){

        $car_booking_metabox_options = array( 'global-sidebar','left-sidebar','right-sidebar','no-sidebar' );
        if( in_array( $car_booking_input,$car_booking_metabox_options ) ){

            return $car_booking_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'car_booking_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function car_booking_sanitize_checkbox( $car_booking_checked ) {

		return ( ( isset( $car_booking_checked ) && true === $car_booking_checked ) ? true : false );

	}

endif;


if ( ! function_exists( 'car_booking_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function car_booking_sanitize_select( $car_booking_input, $car_booking_setting ) {
        $car_booking_input = sanitize_text_field( $car_booking_input );
        $car_booking_choices = $car_booking_setting->manager->get_control( $car_booking_setting->id )->choices;
        return ( array_key_exists( $car_booking_input, $car_booking_choices ) ? $car_booking_input : $car_booking_setting->default );
    }

endif;