On this page
wp_validate_boolean( mixed $var ): bool
Filters/validates a variable as a boolean.
Description
Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN ).
Parameters
$varmixed 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( $var ) {
if ( is_bool( $var ) ) {
return $var;
}
if ( is_string( $var ) && 'false' === strtolower( $var ) ) {
return false;
}
return (bool) $var;
}
Related
Used By
| Used By | Description |
|---|---|
| get_term_parents_list() wp-includes/category-template.php | Retrieves term parents with separator. |
| wp_xmlrpc_server::_toggle_sticky() wp-includes/class-wp-xmlrpc-server.php | Encapsulate the logic for sticking a post and determining if the user has permission to do so |
| wp_video_shortcode() wp-includes/media.php | Builds the Video shortcode output. |
| wp_playlist_shortcode() wp-includes/media.php | Builds the Playlist shortcode output. |
| wp_audio_shortcode() wp-includes/media.php | Builds the Audio shortcode output. |
Changelog
| Version | Description |
|---|---|
| 4.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_validate_boolean