wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



rest_sanitize_boolean › WordPress Function

Depuis4.7.0
Dépréciéen/a
rest_sanitize_boolean ( $value )
Paramètres:
  • (bool|string|int) $value The value being evaluated.
    Requis: Oui
Retourne:
  • (bool) Returns the proper associated boolean value.
Défini(e) dans:
Codex:

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



Source

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;
}