wp_get_post_revision() – Gets a post revision.

You appear to be a bot. Output may be restricted

Description

Gets a post revision.

Usage

$WP_Post|array|null = wp_get_post_revision( $post, $output, $filter );

Parameters

$post
( int|WP_Post ) required – Post ID or post object.
$output
( string ) optional default: OBJECT – Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively. Default OBJECT.
$filter
( string ) optional default: raw – Optional sanitization filter. See sanitize_post().

Returns

WP_Post|array|null WP_Post (or array) on success, or null on failure.

Source

File name: wordpress/wp-includes/revision.php


Lines:

1 to 24 of 24
function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) {
  $revision = get_post( $post, OBJECT, $filter );

  if ( ! $revision ) {
    return $revision;
  }

  if ( 'revision' !== $revision->post_type ) {
    return null;
  }

  if ( OBJECT === $output ) {
    return $revision;
  } elseif ( ARRAY_A === $output ) {
    $_revision = get_object_vars( $revision );
    return $_revision;
  } elseif ( ARRAY_N === $output ) {
    $_revision = array_values( get_object_vars( $revision ) );
    return $_revision;
  }

  return $revision;
}
 

 View on GitHub View on Trac