Changes a boolean-like value into the proper boolean value.
Parameters
$value
bool|string|intrequired- The value being evaluated.
Source
* Changes a boolean-like value into the proper boolean value.
*
* @since 4.7.0
*
* @param bool|string|int $value The value being evaluated.
* @return bool Returns the proper associated boolean value.
*/
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 ) ) {
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.