<?php
/**
* Custom Functions.
*
* @package Training Institute Academy
*/

if( !function_exists( 'training_institute_academy_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function training_institute_academy_sanitize_sidebar_option( $training_institute_academy_input ){

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

            return $training_institute_academy_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'training_institute_academy_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function training_institute_academy_sanitize_checkbox( $training_institute_academy_checked ) {

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

	}

endif;


if ( ! function_exists( 'training_institute_academy_sanitize_select' ) ) :

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

endif;

/*Radio Button sanitization*/
function training_institute_academy_sanitize_choices( $training_institute_academy_input, $training_institute_academy_setting ) {
    global $wp_customize;
    $training_institute_academy_control = $wp_customize->get_control( $training_institute_academy_setting->id );
    if ( array_key_exists( $training_institute_academy_input, $training_institute_academy_control->choices ) ) {
        return $training_institute_academy_input;
    } else {
        return $training_institute_academy_setting->default;
    }
}