<?php
/**
* Custom Functions.
*
* @package Digital Media
*/

if( !function_exists( 'digital_media_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function digital_media_sanitize_sidebar_option( $digital_media_input ){

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

            return $digital_media_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'digital_media_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function digital_media_sanitize_checkbox( $digital_media_checked ) {

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

	}

endif;


if ( ! function_exists( 'digital_media_sanitize_select' ) ) :

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

endif;