rest_is_object() WordPress Function

The rest_is_object() function is used to check whether an object is a rest object. This function is useful for checking whether an object is a rest object before performing any actions on it.

rest_is_object( mixed $maybe_object ) #

Determines if a given value is object-like.


Parameters

$maybe_object

(mixed)(Required)The value being evaluated.


Top ↑

Return

(bool) True if object like, otherwise false.


Top ↑

Source

File: wp-includes/rest-api.php

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


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More