wp_is_post_autosave() – Determines if the specified post is an autosave.

You appear to be a bot. Output may be restricted

Description

Determines if the specified post is an autosave.

Usage

$int|false = wp_is_post_autosave( $post );

Parameters

$post
( int|WP_Post ) required – Post ID or post object.

Returns

int|false ID of autosave's parent on success, false if not a revision.

Source

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

1 to 12 of 12
function wp_is_post_autosave( $post ) {
  $post = wp_get_post_revision( $post );
  if ( ! $post ) {
    return false;
  }

  if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) {
    return (int) $post->post_parent;
  }

  return false;
}
 

 View on GitHub View on Trac