Definition:
function _wp_put_post_revision( $post = null, $autosave = false ) {}
Inserts post data into the posts table as a post revision.
Parameters
- int|object|array $post: Post ID, post object OR post array.
- bool $autosave: Optional. Is the revision an autosave?
Return values
returns:Null or 0 if error, new revision ID if success.
Defined actions
- _wp_put_post_revision
do_action( '_wp_put_post_revision', $revision_id );
Source code
function _wp_put_post_revision( $post = null, $autosave = false ) {
if ( is_object($post) )
$post = get_object_vars( $post );
elseif ( !is_array($post) )
$post = get_post($post, ARRAY_A);
if ( !$post || empty($post['ID']) )
return;
if ( isset($post['post_type']) && 'revision' == $post['post_type'] )
return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) );
$post = _wp_post_revision_fields( $post, $autosave );
$post = add_magic_quotes($post); //since data is from db
$revision_id = wp_insert_post( $post );
if ( is_wp_error($revision_id) )
return $revision_id;
if ( $revision_id )
do_action( '_wp_put_post_revision', $revision_id );
return $revision_id;
}
4411

February 12, 2011 


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