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



rest_sanitize_object › WordPress Function

Od5.5.0
Przestarzałyn/a
rest_sanitize_object ( $maybe_object )
Parametry:
  • (mixed) $maybe_object The value being evaluated.
    Wymagane: Tak
Powrót:
  • (array) Returns the object extracted from the value as an associative array.
Zdefiniowane na:
Codex:

Converts an object-like value to an array.



Źródło

function rest_sanitize_object( $maybe_object ) {
	if ( '' === $maybe_object ) {
		return array();
	}

	if ( $maybe_object instanceof stdClass ) {
		return (array) $maybe_object;
	}

	if ( $maybe_object instanceof JsonSerializable ) {
		$maybe_object = $maybe_object->jsonSerialize();
	}

	if ( ! is_array( $maybe_object ) ) {
		return array();
	}

	return $maybe_object;
}