Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_wp_post_revision_data() WordPress Function

The wp_post_revision_data() function retrieves a post revision. A post revision is a saved copy of a post or page.

_wp_post_revision_data( array|WP_Post $post = array(), bool $autosave = false ) #

Returns a post array ready to be inserted into the posts table as a post revision.


Parameters

$post

(array|WP_Post)(Optional) A post array or a WP_Post object to be processed for insertion as a post revision.

Default value: array()

$autosave

(bool)(Optional) Is the revision an autosave?

Default value: false


Top ↑

Return

(array) Post array ready to be inserted as a post revision.


Top ↑

Source

File: wp-includes/revision.php

function _wp_post_revision_data( $post = array(), $autosave = false ) {
	if ( ! is_array( $post ) ) {
		$post = get_post( $post, ARRAY_A );
	}

	$fields = _wp_post_revision_fields( $post );

	$revision_data = array();

	foreach ( array_intersect( array_keys( $post ), array_keys( $fields ) ) as $field ) {
		$revision_data[ $field ] = $post[ $field ];
	}

	$revision_data['post_parent']   = $post['ID'];
	$revision_data['post_status']   = 'inherit';
	$revision_data['post_type']     = 'revision';
	$revision_data['post_name']     = $autosave ? "$post[ID]-autosave-v1" : "$post[ID]-revision-v1"; // "1" is the revisioning system version.
	$revision_data['post_date']     = isset( $post['post_modified'] ) ? $post['post_modified'] : '';
	$revision_data['post_date_gmt'] = isset( $post['post_modified_gmt'] ) ? $post['post_modified_gmt'] : '';

	return $revision_data;
}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.