wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



rest_sanitize_boolean › WordPress Function

Od4.7.0
Przestarzałyn/a
rest_sanitize_boolean ( $value )
Parametry:
  • (bool|string|int) $value The value being evaluated.
    Wymagane: Tak
Powrót:
  • (bool) Returns the proper associated boolean value.
Zdefiniowane na:
Codex:

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



Źródło

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