Make WordPress Core

Changeset 23681


Ignore:
Timestamp:
03/13/2013 12:28:07 AM (12 years ago)
Author:
azaozz
Message:

Post locks on the posts list screen: new icons for the lock, props empireoflight, show avatar for the user currently editing, props dh-shredder, see #23312

Location:
trunk
Files:
2 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/wp-admin.css

    r23661 r23681  
    24262426.fixed .column-date,
    24272427.fixed .column-parent,
    2428 .fixed .column-links {
     2428.fixed .column-links,
     2429.fixed .column-author,
     2430.fixed .column-format {
    24292431    width: 10%;
    24302432}
    24312433
    24322434.fixed .column-response,
    2433 .fixed .column-author,
    24342435.fixed .column-categories,
    24352436.fixed .column-tags,
     
    25302531
    25312532tr.wp-locked .locked-indicator {
    2532     background: url('../images/lock16.png') no-repeat;
    2533     margin: -2px 0 0 8px;
     2533    background: url('../images/lock.png') no-repeat;
     2534    margin: -2px 0 0 6px;
    25342535    height: 16px;
    25352536    width: 16px;
     
    25392540tr.wp-locked .check-column input[type="checkbox"],
    25402541tr.wp-locked .row-actions .inline,
    2541 tr.wp-locked .row-actions .trash,
    2542 .lock-holder {
     2542tr.wp-locked .row-actions .trash {
    25432543    display: none;
    2544 }
    2545 
    2546 tr.wp-locked .lock-holder {
    2547     display: inline;
    25482544}
    25492545
     
    90359031    }
    90369032
     9033    tr.wp-locked .locked-indicator  {
     9034        background-image: url('../images/lock-2x.png');
     9035        background-size: 16px 16px;
     9036    }
     9037
    90379038    th .comment-grey-bubble {
    90389039        background-image: url('../images/comment-grey-bubble-2x.png');
  • trunk/wp-admin/edit.php

    r23563 r23681  
    146146
    147147wp_enqueue_script('inline-edit-post');
    148 wp_enqueue_script('edit-post');
    149148
    150149$title = $post_type_object->labels->name;
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r23560 r23681  
    554554                echo "</strong>\n";
    555555
    556                 if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
    557                     printf( '<span class="lock-holder">%s</span>',
    558                         esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ) );
     556                if ( $can_edit_post && $post->post_status != 'trash' ) {
     557                    if ( $lock_holder ) {
     558                        $locked_avatar = get_avatar( $lock_holder->ID, 18 );
     559                        $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
     560                    } else {
     561                        $locked_avatar = $locked_text = '';
     562                    }
     563
     564                    echo '<span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span>\n";
    559565                }
    560566
  • trunk/wp-admin/includes/misc.php

    r23661 r23681  
    567567 * @since 3.6
    568568 */
    569 function wp_check_locked_posts( $response, $data ) {
     569function wp_check_locked_posts( $response, $data, $screen_id ) {
    570570    $checked = array();
    571571
    572     if ( array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
     572    if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
    573573        foreach ( $data['wp-check-locked'] as $key ) {
    574574            $post_id = (int) substr( $key, 5 );
    575575
    576             if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) ) {
    577                 if ( $user = get_userdata( $user_id ) )
    578                     $checked[$key] = sprintf( __( '%s is currently editing' ), $user->display_name );
     576            if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
     577                $send = array();
     578
     579                if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
     580                    $send['avatar_src'] = $matches[1];
     581
     582                $send['text'] = sprintf( __( '%s is currently editing' ), $user->display_name );
     583                $checked[$key] = $send;
    579584            }
    580585        }
     
    586591    return $response;
    587592}
    588 add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 2 );
     593add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
    589594
    590595/**
  • trunk/wp-admin/js/inline-edit-post.js

    r23444 r23681  
    291291};
    292292
    293 $(document).ready(function(){inlineEditPost.init();});
    294 })(jQuery);
     293$( document ).ready( function(){ inlineEditPost.init(); } );
     294
     295// Show/hide locks on posts
     296$( document ).on( 'heartbeat-tick.wp-check-locked', function( e, data ) {
     297    var locked = data['wp-check-locked'] || {};
     298
     299    $('#the-list tr').each( function(i, el) {
     300        var key = el.id, row = $(el), lock_data, avatar;
     301
     302        if ( locked.hasOwnProperty( key ) ) {
     303            if ( ! row.hasClass('wp-locked') ) {
     304                lock_data = locked[key];
     305                row.addClass('wp-locked').find('.column-title .locked-text').text( lock_data.text );
     306                row.find('.check-column checkbox').prop('checked', false);
     307
     308                if ( lock_data.avatar_src ) {
     309                    avatar = $('<img class="avatar avatar-18 photo" width="18" height="18" />').attr( 'src', lock_data.avatar_src.replace(/&amp;/g, '&') );
     310                    row.find('.column-title .locked-avatar').empty().append( avatar );
     311                }
     312            }
     313        } else if ( row.hasClass('wp-locked') ) {
     314            row.removeClass('wp-locked').find('.column-title .locked-text').empty();
     315            row.find('.column-title .locked-avatar').empty();
     316        }
     317    });
     318}).on( 'heartbeat-send.wp-check-locked', function( e, data ) {
     319    var check = [];
     320
     321    $('#the-list tr').each( function(i, el) {
     322        check.push( el.id );
     323    });
     324
     325    data['wp-check-locked'] = check;
     326});
     327
     328}(jQuery));
  • trunk/wp-includes/script-loader.php

    r23589 r23681  
    420420        $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), false, 1 );
    421421
    422         $scripts->add( 'edit-post', "/wp-admin/js/edit-post$suffix.js", array( 'heartbeat' ), false, 1 );
    423 
    424         $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
     422        $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'heartbeat' ), false, 1 );
    425423        did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
    426424            'error' => __('Error while saving the changes.'),
Note: See TracChangeset for help on using the changeset viewer.