wp_get_post_revisions() – Returns all revisions of specified post.

You appear to be a bot. Output may be restricted

Description

Returns all revisions of specified post.

Usage

$WP_Post[]|int[] = wp_get_post_revisions( $post, $args );

Parameters

$post
( int|WP_Post ) optional – Optional. Post ID or WP_Post object. Default is global `$post`.
$args
( array|null ) optional – Optional. Arguments for retrieving post revisions. Default null.

Returns

WP_Post[]|int[] Array of revision objects or IDs, or an empty array if none.

Source

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

1 to 35 of 35
function wp_get_post_revisions( $post = 0, $args = null ) {
  $post = get_post( $post );

  if ( ! $post || empty( $post->ID ) ) {
    return array();
  }

  $defaults = array(
    'order'         => 'DESC',
    'orderby'       => 'date ID',
    'check_enabled' => true,
  );
  $args     = wp_parse_args( $args, $defaults );

  if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) {
    return array();
  }

  $args = array_merge(
    $args,
    array(
      'post_parent' => $post->ID,
      'post_type'   => 'revision',
      'post_status' => 'inherit',
    )
  );

  $revisions = get_children( $args );

  if ( ! $revisions ) {
    return array();
  }

  return $revisions;
}
 

 View on GitHub View on Trac