Used By
| Used By | Description |
|---|---|
| wp-includes/rest-api.php: rest_validate_value_from_schema() | Validate a value based on a schema. |
Determines if a given value is boolean-like.
(bool|string) (Required) The value being evaluated.
(boolean) True if a boolean, otherwise false.
File: wp-includes/rest-api.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;
} | Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_is_boolean