<?php
/**
* Custom Functions.
*
* @package Omega Blogger
*/

if( !function_exists( 'omega_blogger_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function omega_blogger_sanitize_sidebar_option( $omega_blogger_input ){

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

            return $omega_blogger_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'omega_blogger_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function omega_blogger_sanitize_checkbox( $omega_blogger_checked ) {

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

	}

endif;


if ( ! function_exists( 'omega_blogger_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function omega_blogger_sanitize_select( $omega_blogger_input, $omega_blogger_setting ) {
        $omega_blogger_input = sanitize_text_field( $omega_blogger_input );
        $omega_blogger_choices = $omega_blogger_setting->manager->get_control( $omega_blogger_setting->id )->choices;
        return ( array_key_exists( $omega_blogger_input, $omega_blogger_choices ) ? $omega_blogger_input : $omega_blogger_setting->default );
    }

endif;

/*Radio Button sanitization*/
function omega_blogger_sanitize_choices( $omega_blogger_input, $omega_blogger_setting ) {
    global $wp_customize;
    $omega_blogger_control = $wp_customize->get_control( $omega_blogger_setting->id );
    if ( array_key_exists( $omega_blogger_input, $omega_blogger_control->choices ) ) {
        return $omega_blogger_input;
    } else {
        return $omega_blogger_setting->default;
    }
}