<?php
/**
* Custom Functions.
*
* @package Multi Sports Club
*/

if( !function_exists( 'multi_sports_club_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function multi_sports_club_sanitize_sidebar_option( $multi_sports_club_input ){

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

            return $multi_sports_club_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'multi_sports_club_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function multi_sports_club_sanitize_checkbox( $multi_sports_club_checked ) {

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

	}

endif;


if ( ! function_exists( 'multi_sports_club_sanitize_select' ) ) :

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

endif;

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