rest_is_object()WP 5.5.0

Determines if a given value is object-like.

Хуков нет.

Возвращает

true|false. True if object like, otherwise false.

Использование

rest_is_object( $maybe_object );
$maybe_object(разное) (обязательный)
The value being evaluated.

Список изменений

С версии 5.5.0 Введена.

Код rest_is_object() WP 6.5.2

function rest_is_object( $maybe_object ) {
	if ( '' === $maybe_object ) {
		return true;
	}

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

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

	return is_array( $maybe_object );
}