Make WordPress Core

Changeset 23487


Ignore:
Timestamp:
02/25/2013 11:17:10 PM (12 years ago)
Author:
azaozz
Message:

Post locks: use heartbeat to dynamically update locked posts on the Posts screen, first run, see #23312

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r23416 r23487  
    146146
    147147wp_enqueue_script('inline-edit-post');
     148wp_enqueue_script('edit-post');
    148149
    149150$title = $post_type_object->labels->name;
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r23396 r23487  
    556556                if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
    557557                    printf( '<span class="lock-holder">%s</span>',
    558                         esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name )  ) );
     558                        esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ) );
    559559                }
    560560
  • trunk/wp-admin/includes/misc.php

    r23416 r23487  
    562562}
    563563add_action('admin_head', '_ipad_meta');
     564
     565/**
     566 * Check lock status for posts displayed on the Posts screen
     567 *
     568 * @since 3.6
     569 */
     570function wp_check_locked_posts( $response, $data ) {
     571    $checked = array();
     572
     573    if ( array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
     574        foreach ( $data['wp-check-locked'] as $key ) {
     575            $post_id = (int) substr( $key, 5 );
     576
     577            if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) ) {
     578                if ( $user = get_userdata( $user_id ) )
     579                    $checked[$key] = sprintf( __( '%s is currently editing' ), $user->display_name );
     580            }
     581        }
     582    }
     583
     584    if ( ! empty( $checked ) )
     585        $response['wp-check-locked'] = $checked;
     586
     587    return $response;
     588}
     589add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 2 );
  • trunk/wp-includes/script-loader.php

    r23449 r23487  
    417417        $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), false, 1 );
    418418
     419        $scripts->add( 'edit-post', "/wp-admin/js/edit-post$suffix.js", array( 'heartbeat' ), false, 1 );
     420
    419421        $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
    420422        did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
Note: See TracChangeset for help on using the changeset viewer.