WP_REST_Revisions_Controller::get_revision

Advertisement

Summery Summery

Get the revision, if the ID is valid.

Syntax Syntax

WP_REST_Revisions_Controller::get_revision( int $id )

Parameters Parameters

$id

(Required) Supplied ID.

Return Return

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

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

			'rest_post_invalid_id',
			__( 'Invalid 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;
	}

	/**

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.2 Introduced.

Advertisement

Leave a Reply