<?php
/**
* Custom Functions.
*
* @package OTT Vlogger
*/

if( !function_exists( 'ott_vlogger_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function ott_vlogger_sanitize_sidebar_option( $ott_vlogger_input ){

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

            return $ott_vlogger_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'ott_vlogger_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function ott_vlogger_sanitize_checkbox( $ott_vlogger_checked ) {

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

	}

endif;


if ( ! function_exists( 'ott_vlogger_sanitize_select' ) ) :

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

endif;

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