WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/12/2013 03:22:30 AM (7 years ago)
Author:
azaozz
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/post.php

    r23445 r23661  
    148148        wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') );
    149149
     150    if ( !empty( $_GET['get-post-lock'] ) ) {
     151        wp_set_post_lock( $post_id );
     152        wp_redirect( get_edit_post_link( $post_id, 'url' ) );
     153        exit();
     154    }
     155
    150156    $post_type = $post->post_type;
    151157    if ( 'post' == $post_type ) {
     
    166172    }
    167173
    168     if ( $last = wp_check_post_lock( $post->ID ) ) {
    169         add_action('admin_notices', '_admin_notice_post_locked' );
    170     } else {
     174    if ( ! wp_check_post_lock( $post->ID ) ) {
    171175        $active_post_lock = wp_set_post_lock( $post->ID );
    172176
     
    174178            wp_enqueue_script('autosave');
    175179    }
     180
     181    add_action( 'admin_footer', '_admin_notice_post_locked' );
    176182
    177183    $title = $post_type_object->labels->edit_item;
     
    217223    if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    218224        wp_die( __('You are not allowed to move this item to the Trash.') );
     225
     226    if ( $user_id = wp_check_post_lock( $post_id ) ) {
     227        $user = get_userdata( $user_id );
     228        wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
     229    }
    219230
    220231    if ( ! wp_trash_post($post_id) )
Note: See TracChangeset for help on using the changeset viewer.