mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Autosave to the browser's sessionStorage, compare this autosave to the post content on page load and let the user restore it when the data is not the same. First run, see #23220
git-svn-id: https://develop.svn.wordpress.org/trunk@23683 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -632,3 +632,29 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||
return $response;
|
||||
}
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
|
||||
|
||||
/**
|
||||
* Output the HTML for restoring the post data from DOM storage
|
||||
*
|
||||
* @since 3.6
|
||||
* @access private
|
||||
*/
|
||||
function _local_storage_notice() {
|
||||
$screen = get_current_screen();
|
||||
if ( ! $screen || 'post' != $screen->id )
|
||||
return;
|
||||
|
||||
?>
|
||||
<div id="local-storage-notice" class="hidden">
|
||||
<p class="local-restore">
|
||||
<?php _e('The backup of this post in your browser is different from the version below.'); ?>
|
||||
<a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
|
||||
</p>
|
||||
<p class="undo-restore hidden">
|
||||
<?php _e('Post restored successfully.'); ?>
|
||||
<a class="undo-restore-backup" href="#"><?php _e('Undo.'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_footer', '_local_storage_notice' );
|
||||
|
||||
Reference in New Issue
Block a user