wp_validate_boolean( mixed $value ): bool
Filters/validates a variable as a boolean.
Description
Alternative to filter_var( $value, FILTER_VALIDATE_BOOLEAN )
.
Parameters
-
$value
mixed Required -
Boolean value to validate.
Return
bool Whether the value is validated.
Source
File: wp-includes/functions.php
.
View all references
function wp_validate_boolean( $value ) {
if ( is_bool( $value ) ) {
return $value;
}
if ( is_string( $value ) && 'false' === strtolower( $value ) ) {
return false;
}
return (bool) $value;
}
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
wp_validate_boolean() tests: