<?php
/**
* Custom Functions.
*
* @package Green Nursery
*/

if( !function_exists( 'green_nursery_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function green_nursery_sanitize_sidebar_option( $green_nursery_input ){

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

            return $green_nursery_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'green_nursery_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function green_nursery_sanitize_checkbox( $green_nursery_checked ) {

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

	}

endif;


if ( ! function_exists( 'green_nursery_sanitize_select' ) ) :

    /**
     * Sanitize select.
     */
    function green_nursery_sanitize_select( $green_nursery_input, $green_nursery_setting ) {
        $green_nursery_input = sanitize_text_field( $green_nursery_input );
        $green_nursery_choices = $green_nursery_setting->manager->get_control( $green_nursery_setting->id )->choices;
        return ( array_key_exists( $green_nursery_input, $green_nursery_choices ) ? $green_nursery_input : $green_nursery_setting->default );
    }

endif;