<?php
/**
* Custom Functions.
*
* @package Board Games
*/

if( !function_exists( 'board_games_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function board_games_sanitize_sidebar_option( $board_games_input ){

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

            return $board_games_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'board_games_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function board_games_sanitize_checkbox( $board_games_checked ) {

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

	}

endif;


if ( ! function_exists( 'board_games_sanitize_select' ) ) :

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

endif;

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