wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
rest_is_boolean › WordPress Function
Seit4.7.0
Veraltetn/v
› rest_is_boolean ( $maybe_bool )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Determines if a given value is boolean-like.
Ähnliche Funktionen: rest_sanitize_boolean, rest_is_object, rest_is_array, rest_is_integer, wp_validate_boolean
Quellcode
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;
}