Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



rest_sanitize_object ›

Seit5.5.0
Veraltetn/v
rest_sanitize_object ( $maybe_object )
Parameter:
  • (mixed) $maybe_object The value being evaluated.
    Erforderlich: Ja
Gibt zurück:
  • (array) Returns the object extracted from the value.
Definiert in:
Codex:

Converts an object-like value to an object.



Quellcode

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