rest_is_boolean

The timeline below displays how wordpress function rest_is_boolean has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.6

/**
 * Determines if a given value is boolean-like.
 *
 * @since 4.7.0
 *
 * @param bool|string $maybe_bool The value being evaluated.
 * @return bool True if a boolean, otherwise false.
 */
function rest_is_boolean($maybe_bool)
{
    if (is_bool($maybe_bool)) {
        return true;
    }
    if (is_string($maybe_bool)) {
        $maybe_bool = strtolower($maybe_bool);
        $valid_boolean_values = array('false', 'true', '0', '1');
        return in_array($maybe_bool, $valid_boolean_values, true);
    }
    if (is_int($maybe_bool)) {
        return in_array($maybe_bool, array(0, 1), true);
    }
    return false;
}

WordPress Version: 4.7

/**
 * Determines if a given value is boolean-like.
 *
 * @since 4.7.0
 *
 * @param bool|string $maybe_bool The value being evaluated.
 * @return boolean True if a boolean, otherwise false.
 */
function rest_is_boolean($maybe_bool)
{
    if (is_bool($maybe_bool)) {
        return true;
    }
    if (is_string($maybe_bool)) {
        $maybe_bool = strtolower($maybe_bool);
        $valid_boolean_values = array('false', 'true', '0', '1');
        return in_array($maybe_bool, $valid_boolean_values, true);
    }
    if (is_int($maybe_bool)) {
        return in_array($maybe_bool, array(0, 1), true);
    }
    return false;
}