<?php
/**
* Custom Functions.
*
* @package Beauty Parlour Salon
*/

if( !function_exists( 'beauty_parlour_salon_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function beauty_parlour_salon_sanitize_sidebar_option( $beauty_parlour_salon_input ){

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

            return $beauty_parlour_salon_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'beauty_parlour_salon_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function beauty_parlour_salon_sanitize_checkbox( $beauty_parlour_salon_checked ) {

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

	}

endif;


if ( ! function_exists( 'beauty_parlour_salon_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function beauty_parlour_salon_sanitize_select( $beauty_parlour_salon_input, $beauty_parlour_salon_setting ) {
        $beauty_parlour_salon_input = sanitize_text_field( $beauty_parlour_salon_input );
        $choices = $beauty_parlour_salon_setting->manager->get_control( $beauty_parlour_salon_setting->id )->choices;
        return ( array_key_exists( $beauty_parlour_salon_input, $choices ) ? $beauty_parlour_salon_input : $beauty_parlour_salon_setting->default );
    }

endif;

/*Radio Button sanitization*/
function beauty_parlour_salon_sanitize_choices( $input, $setting ) {
    global $wp_customize;
    $control = $wp_customize->get_control( $setting->id );
    if ( array_key_exists( $input, $control->choices ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}