wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
rest_sanitize_boolean › WordPress Function
Seit4.7.0
Veraltetn/v
› rest_sanitize_boolean ( $value )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Changes a boolean-like value into the proper boolean value.
Ähnliche Funktionen: rest_is_boolean, rest_sanitize_object, rest_sanitize_array, rest_sanitize_request_arg, sanitize_bookmark
Quellcode
function rest_sanitize_boolean( $value ) {
// String values are translated to `true`; make sure 'false' is false.
if ( is_string( $value ) ) {
$value = strtolower( $value );
if ( in_array( $value, array( 'false', '0' ), true ) ) {
$value = false;
}
}
// Everything else will map nicely to boolean.
return (bool) $value;
}