wp_restore_post_revision [ WordPress Function ]
wp_restore_post_revision ( $revision_id, $fields = null )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_get_post_revision, wp_delete_post_revision, wp_is_post_revision, wp_get_post_revisions, wp_save_post_revision
Restores a post to the specified revision.
Can restore a past revision using all fields of the post revision, or only selected fields.
Source
<?php
function wp_restore_post_revision( $revision_id, $fields = null ) {
if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) )
return $revision;
if ( !is_array( $fields ) )
$fields = array_keys( _wp_post_revision_fields() );
$update = array();
foreach( array_intersect( array_keys( $revision ), $fields ) as $field )
$update[$field] = $revision[$field];
if ( !$update )
return false;
$update['ID'] = $revision['post_parent'];
$update = add_magic_quotes( $update ); //since data is from db
$post_id = wp_update_post( $update );
if ( is_wp_error( $post_id ) )
return $post_id;
if ( $post_id )
do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );
return $post_id;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- wp_restore_post_revision Wordpress hook details -- Adam Brown ...
wp_restore_post_revision. WordPress version history for wp_restore_post_revision. This database has information for all major versions from WP 1.2.1 through ...
adambrown.info - age WordPress * @subpackage Post_Revisions * @since 2.6.0 ...
function wp_restore_post_revision( $revision_id, $fields = null ) { if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) return $revision; if ( !is_array( ...
slobtostud.com - Saving Post Meta Field Revisions in WordPress · Ludicrous
Apr 27, 2012 ... For this we hook into the wp_restore_post_revision action and update the meta field to the version stored at the revision we're reverting to.
lud.icro.us - Wordpress - custom fields are not restored to previous revisions ...
Jun 29, 2011... could save the meta when the revision is made using _wp_put_post_revision and you can restore the meta using wp_restore_post_revision .
wordpress.stackexchange.com