<?php
/**
* Custom Functions.
*
* @package Local Supermarket
*/

if( !function_exists( 'local_supermarket_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function local_supermarket_sanitize_sidebar_option( $local_supermarket_input ){

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

            return $local_supermarket_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'local_supermarket_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function local_supermarket_sanitize_checkbox( $local_supermarket_checked ) {

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

	}

endif;


if ( ! function_exists( 'local_supermarket_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function local_supermarket_sanitize_select( $local_supermarket_input, $local_supermarket_setting ) {
        $local_supermarket_input = sanitize_text_field( $local_supermarket_input );
        $local_supermarket_choices = $local_supermarket_setting->manager->get_control( $local_supermarket_setting->id )->choices;
        return ( array_key_exists( $local_supermarket_input, $local_supermarket_choices ) ? $local_supermarket_input : $local_supermarket_setting->default );
    }

endif;