WP_REST_Global_Styles_Revisions_Controller::get_revision( int $id ): WP_Post|WP_Error

In this article

Gets the global styles revision, if the ID is valid.

Parameters

$idintrequired
Supplied ID.

Return

WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise.

Source

protected function get_revision( $id ) {
	$error = new WP_Error(
		'rest_post_invalid_id',
		__( 'Invalid global styles revision ID.' ),
		array( 'status' => 404 )
	);

	if ( (int) $id <= 0 ) {
		return $error;
	}

	$revision = get_post( (int) $id );
	if ( empty( $revision ) || empty( $revision->ID ) || 'revision' !== $revision->post_type ) {
		return $error;
	}

	return $revision;
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.