Advertisements

wp_get_post_revision

Definition:
function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {}

Gets a post revision.

Parameters

  • int|object $post: Post ID or post object
  • string $output: Optional. OBJECT, ARRAY_A, or ARRAY_N.
  • string $filter: Optional sanitation filter. @see sanitize_post()
  • &$post

Return values

returns:Null if error or post object if success

Source code

function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {

	$null = null;

	if ( !$revision = get_post( $post, OBJECT, $filter ) )

		return $revision;

	if ( 'revision' !== $revision->post_type )

		return $null;



	if ( $output == OBJECT ) {

		return $revision;

	} elseif ( $output == ARRAY_A ) {

		$_revision = get_object_vars($revision);

		return $_revision;

	} elseif ( $output == ARRAY_N ) {

		$_revision = array_values(get_object_vars($revision));

		return $_revision;

	}



	return $revision;

}

3733

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: