Used By
Used By | Description |
---|---|
wp-includes/rest-api.php: rest_sanitize_value_from_schema() | Sanitize a value based on a schema. |
Changes a boolean-like value into the proper boolean value.
(bool|string|int) (Required) The value being evaluated.
(boolean) Returns the proper associated boolean value.
File: wp-includes/rest-api.php
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; }
Version | Description |
---|---|
4.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_sanitize_boolean