<?php
/**
* Custom Functions.
*
* @package Online Learning LMS
*/

if( !function_exists( 'online_learning_lms_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function online_learning_lms_sanitize_sidebar_option( $online_learning_lms_input ){

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

            return $online_learning_lms_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'online_learning_lms_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function online_learning_lms_sanitize_checkbox( $online_learning_lms_checked ) {

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

	}

endif;


if ( ! function_exists( 'online_learning_lms_sanitize_select' ) ) :

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

endif;
