<?php
/**
* Custom Functions.
*
* @package Omega Hair Salon
*/

if( !function_exists( 'omega_hair_salon_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function omega_hair_salon_sanitize_sidebar_option( $omega_hair_salon_input ){

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

            return $omega_hair_salon_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'omega_hair_salon_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function omega_hair_salon_sanitize_checkbox( $omega_hair_salon_checked ) {

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

	}

endif;


if ( ! function_exists( 'omega_hair_salon_sanitize_select' ) ) :

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

endif;

/*Radio Button sanitization*/
function omega_hair_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;
    }
}