Uma área de pesquisa sobre o WordPress para devs e autores do tema



rest_sanitize_boolean ›

Desde4.7.0
Obsoleton/a
rest_sanitize_boolean ( $value )
Parâmetros:
  • (bool|string|int) $value The value being evaluated.
    Required: Yes
Retorna:
  • (boolean) Returns the proper associated boolean value.
Definido em:
Codex:

Changes a boolean-like value into the proper boolean value.



Fonte

function rest_sanitize_boolean( $value ) {
	// String values are translated to `true`; make sure 'false' is false.
	if ( is_string( $value ) ) {
		$value = strtolower( $value );
		if ( in_array( $value, array( 'false', '0' ), true ) ) {
			$value = false;
		}
	}

	// Everything else will map nicely to boolean.
	return (bool) $value;
}