mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Check post locks with heartbeat and display modal notifications when a post is locked or a user takes over editing, props dh-shredder, see #23697
git-svn-id: https://develop.svn.wordpress.org/trunk@23661 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+14
-3
@@ -147,6 +147,12 @@ case 'edit':
|
||||
if ( 'trash' == $post->post_status )
|
||||
wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') );
|
||||
|
||||
if ( !empty( $_GET['get-post-lock'] ) ) {
|
||||
wp_set_post_lock( $post_id );
|
||||
wp_redirect( get_edit_post_link( $post_id, 'url' ) );
|
||||
exit();
|
||||
}
|
||||
|
||||
$post_type = $post->post_type;
|
||||
if ( 'post' == $post_type ) {
|
||||
$parent_file = "edit.php";
|
||||
@@ -165,15 +171,15 @@ case 'edit':
|
||||
$post_new_file = "post-new.php?post_type=$post_type";
|
||||
}
|
||||
|
||||
if ( $last = wp_check_post_lock( $post->ID ) ) {
|
||||
add_action('admin_notices', '_admin_notice_post_locked' );
|
||||
} else {
|
||||
if ( ! wp_check_post_lock( $post->ID ) ) {
|
||||
$active_post_lock = wp_set_post_lock( $post->ID );
|
||||
|
||||
if ( 'attachment' !== $post_type )
|
||||
wp_enqueue_script('autosave');
|
||||
}
|
||||
|
||||
add_action( 'admin_footer', '_admin_notice_post_locked' );
|
||||
|
||||
$title = $post_type_object->labels->edit_item;
|
||||
$post = get_post($post_id, OBJECT, 'edit');
|
||||
|
||||
@@ -217,6 +223,11 @@ case 'trash':
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to move this item to the Trash.') );
|
||||
|
||||
if ( $user_id = wp_check_post_lock( $post_id ) ) {
|
||||
$user = get_userdata( $user_id );
|
||||
wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
|
||||
}
|
||||
|
||||
if ( ! wp_trash_post($post_id) )
|
||||
wp_die( __('Error in moving to Trash.') );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user