From 803ea2541ee81997b6dd81fdc72ad00bfaa49465 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Mon, 6 May 2013 09:49:13 +0000 Subject: [PATCH] Revisions: Update `_edit_last` when restoring a post. props redpixelstudios. fixes #20982. git-svn-id: https://develop.svn.wordpress.org/trunk@24178 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/revision.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/wp-includes/revision.php b/wp-includes/revision.php index ed5b76d2ce..fe9c607638 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -372,19 +372,22 @@ function wp_restore_post_revision( $revision_id, $fields = null ) { set_post_format( $update['ID'], get_post_meta( $revision['ID'], '_revision_post_format', true ) ); $post_id = wp_update_post( $update ); - if ( is_wp_error( $post_id ) ) + if ( ! $post_id || is_wp_error( $post_id ) ) return $post_id; - if ( $post_id ) - do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); - + // Add restore from details $restore_details = array( 'restored_revision_id' => $revision_id, - 'restored_by_user' => get_current_user_id(), - 'restored_time' => time() + 'restored_by_user' => get_current_user_id(), + 'restored_time' => time() ); update_post_meta( $post_id, '_post_restored_from', $restore_details ); + // Update last edit user + update_post_meta( $post_id, '_edit_last', get_current_user_id() ); + + do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); + return $post_id; }