wp_validate_boolean( mixed $var )
Filter/validate a variable as a boolean.
Description
Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN )
.
Parameters
- $var
-
(Required) Boolean value to validate.
Return
(bool) Whether the value is validated.
Source
File: wp-includes/functions.php
function wp_validate_boolean( $var ) {
if ( is_bool( $var ) ) {
return $var;
}
if ( is_string( $var ) && 'false' === strtolower( $var ) ) {
return false;
}
return (bool) $var;
}
Changelog
Version | Description |
---|---|
WP-4.0.0 | Introduced. |