<?php
/**
* Custom Functions.
*
* @package Agriculture Farm Lite
*/

if( !function_exists( 'agriculture_farm_lite_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function agriculture_farm_lite_sanitize_sidebar_option( $agriculture_farm_lite_input ){

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

            return $agriculture_farm_lite_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'agriculture_farm_lite_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function agriculture_farm_lite_sanitize_checkbox( $agriculture_farm_lite_checked ) {

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

	}

endif;


if ( ! function_exists( 'agriculture_farm_lite_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function agriculture_farm_lite_sanitize_select( $agriculture_farm_lite_input, $agriculture_farm_lite_setting ) {
        $agriculture_farm_lite_input = sanitize_text_field( $agriculture_farm_lite_input );
        $agriculture_farm_lite_choices = $agriculture_farm_lite_setting->manager->get_control( $agriculture_farm_lite_setting->id )->choices;
        return ( array_key_exists( $agriculture_farm_lite_input, $agriculture_farm_lite_choices ) ? $agriculture_farm_lite_input : $agriculture_farm_lite_setting->default );
    }

endif;