rest_is_boolean

Determines if a given value is boolean-like.

Description

rest_is_boolean( $maybe_bool ); 

Parameters (1)

0. $maybe_bool
The maybe bool.

Usage

  1. if ( !function_exists( 'rest_is_boolean' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/vendor/wp-rest-functions.php'; 
  3.  
  4. // The maybe bool. 
  5. $maybe_bool = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = rest_is_boolean($maybe_bool); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/vendor/wp-rest-functions.php  
  1. function rest_is_boolean( $maybe_bool ) { 
  2. if ( is_bool( $maybe_bool ) ) { 
  3. return true; 
  4.  
  5. if ( is_string( $maybe_bool ) ) { 
  6. $maybe_bool = strtolower( $maybe_bool ); 
  7.  
  8. $valid_boolean_values = array( 
  9. 'false',  
  10. 'true',  
  11. '0',  
  12. '1',  
  13. ); 
  14.  
  15. return in_array( $maybe_bool, $valid_boolean_values, true ); 
  16.  
  17. if ( is_int( $maybe_bool ) ) { 
  18. return in_array( $maybe_bool, array( 0, 1 ), true ); 
  19.  
  20. return false;