<?php
/**
* Custom Functions.
*
* @package Cargo And Shipping Company
*/

if( !function_exists( 'cargo_and_shipping_company_sanitize_sidebar_option' ) ) :

    // Sidebar Option Sanitize.
    function cargo_and_shipping_company_sanitize_sidebar_option( $cargo_and_shipping_company_input ){

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

            return $cargo_and_shipping_company_input;

        }

        return;

    }

endif;

if ( ! function_exists( 'cargo_and_shipping_company_sanitize_checkbox' ) ) :

	/**
	 * Sanitize checkbox.
	 */
	function cargo_and_shipping_company_sanitize_checkbox( $cargo_and_shipping_company_checked ) {

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

	}

endif;


if ( ! function_exists( 'cargo_and_shipping_company_sanitize_select' ) ) :

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

endif;