تابع ووکامرسی rest_is_boolean آیا مقدار داده شده مشابه boolean است ؟

تابع ووکامرسی rest_is_boolean – آیا مقدار داده شده مشابه boolean است ؟ بر اساس ==
Syntax – سینتکس
rest_is_boolean( $maybe_bool );
Parameters – پارامتر ها (1)
- 1- $maybe_bool
Usage – نحوه استفاده
if ( !function_exists( 'rest_is_boolean' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/vendor/wp-rest-functions.php';
}
// The maybe bool.
$maybe_bool = null;
// NOTICE! Understand what this does before running.
$result = rest_is_boolean($maybe_bool);
Defined – محل تعریف
/includes/vendor/wp-rest-functions.php
function rest_is_boolean( $maybe_bool ) {
if ( is_bool( $maybe_bool ) ) {
return true;
}
if ( is_string( $maybe_bool ) ) {
$maybe_bool = strtolower( $maybe_bool );
$valid_boolean_values = array(
'false',
'true',
'0',
'1',
);
return in_array( $maybe_bool, $valid_boolean_values, true );
}
if ( is_int( $maybe_bool ) ) {
return in_array( $maybe_bool, array( 0, 1 ), true );
}
return false;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر