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

git-svn-id: https://develop.svn.wordpress.org/trunk@23681 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2013-03-13 00:28:07 +00:00
parent eab76eac4a
commit 631980b5fa
10 changed files with 68 additions and 50 deletions

View File

@ -2425,12 +2425,13 @@ table.fixed {
.fixed .column-date,
.fixed .column-parent,
.fixed .column-links {
.fixed .column-links,
.fixed .column-author,
.fixed .column-format {
width: 10%;
}
.fixed .column-response,
.fixed .column-author,
.fixed .column-categories,
.fixed .column-tags,
.fixed .column-rel,
@ -2529,8 +2530,8 @@ table.fixed {
}
tr.wp-locked .locked-indicator {
background: url('../images/lock16.png') no-repeat;
margin: -2px 0 0 8px;
background: url('../images/lock.png') no-repeat;
margin: -2px 0 0 6px;
height: 16px;
width: 16px;
}
@ -2538,15 +2539,10 @@ tr.wp-locked .locked-indicator {
tr.wp-locked .check-column label,
tr.wp-locked .check-column input[type="checkbox"],
tr.wp-locked .row-actions .inline,
tr.wp-locked .row-actions .trash,
.lock-holder {
tr.wp-locked .row-actions .trash {
display: none;
}
tr.wp-locked .lock-holder {
display: inline;
}
.fixed .column-comments .sorting-indicator {
margin-top: 3px;
}
@ -9034,6 +9030,11 @@ a.widget-control-edit {
background-size: 18px 100px;
}
tr.wp-locked .locked-indicator {
background-image: url('../images/lock-2x.png');
background-size: 16px 16px;
}
th .comment-grey-bubble {
background-image: url('../images/comment-grey-bubble-2x.png');
background-size: 12px 12px;

View File

@ -145,7 +145,6 @@ if ( $doaction ) {
$wp_list_table->prepare_items();
wp_enqueue_script('inline-edit-post');
wp_enqueue_script('edit-post');
$title = $post_type_object->labels->name;

BIN
wp-admin/images/lock-2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

BIN
wp-admin/images/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 B

View File

@ -553,9 +553,15 @@ class WP_Posts_List_Table extends WP_List_Table {
echo "</strong>\n";
if ( $lock_holder && $can_edit_post && $post->post_status != 'trash' ) {
printf( '<span class="lock-holder">%s</span>',
esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ) );
if ( $can_edit_post && $post->post_status != 'trash' ) {
if ( $lock_holder ) {
$locked_avatar = get_avatar( $lock_holder->ID, 18 );
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
} else {
$locked_avatar = $locked_text = '';
}
echo '<span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span>\n";
}
if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )

View File

@ -566,16 +566,21 @@ add_action('admin_head', '_ipad_meta');
*
* @since 3.6
*/
function wp_check_locked_posts( $response, $data ) {
function wp_check_locked_posts( $response, $data, $screen_id ) {
$checked = array();
if ( array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
foreach ( $data['wp-check-locked'] as $key ) {
$post_id = (int) substr( $key, 5 );
if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) ) {
if ( $user = get_userdata( $user_id ) )
$checked[$key] = sprintf( __( '%s is currently editing' ), $user->display_name );
if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
$send = array();
if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
$send['avatar_src'] = $matches[1];
$send['text'] = sprintf( __( '%s is currently editing' ), $user->display_name );
$checked[$key] = $send;
}
}
}
@ -585,7 +590,7 @@ function wp_check_locked_posts( $response, $data ) {
return $response;
}
add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 2 );
add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
/**
* Check lock status on the New/Edit Post screen and refresh the lock

View File

@ -1,25 +0,0 @@
(function($){
$( document ).on( 'heartbeat-tick.wp-check-locked', function( e, data ) {
var locked = data['wp-check-locked'] || {};
$('#the-list tr').each( function(i, el) {
var key = el.id, row = $(el);
if ( locked.hasOwnProperty( key ) ) {
if ( ! row.hasClass('wp-locked') )
row.addClass('wp-locked').find('.column-title strong').after( $('<span class="lock-holder" />').text(locked[key]) );
row.find('.check-column checkbox').prop('checked', false);
} else if ( row.hasClass('wp-locked') ) {
row.removeClass('wp-locked').find('.column-title span.lock-holder').remove();
}
});
}).on( 'heartbeat-send.wp-check-locked', function( e, data ) {
var check = [];
$('#the-list tr').each( function(i, el) {
check.push( el.id );
});
data['wp-check-locked'] = check;
});
}(jQuery));

View File

@ -290,5 +290,39 @@ inlineEditPost = {
}
};
$(document).ready(function(){inlineEditPost.init();});
})(jQuery);
$( document ).ready( function(){ inlineEditPost.init(); } );
// Show/hide locks on posts
$( document ).on( 'heartbeat-tick.wp-check-locked', function( e, data ) {
var locked = data['wp-check-locked'] || {};
$('#the-list tr').each( function(i, el) {
var key = el.id, row = $(el), lock_data, avatar;
if ( locked.hasOwnProperty( key ) ) {
if ( ! row.hasClass('wp-locked') ) {
lock_data = locked[key];
row.addClass('wp-locked').find('.column-title .locked-text').text( lock_data.text );
row.find('.check-column checkbox').prop('checked', false);
if ( lock_data.avatar_src ) {
avatar = $('<img class="avatar avatar-18 photo" width="18" height="18" />').attr( 'src', lock_data.avatar_src.replace(/&amp;/g, '&') );
row.find('.column-title .locked-avatar').empty().append( avatar );
}
}
} else if ( row.hasClass('wp-locked') ) {
row.removeClass('wp-locked').find('.column-title .locked-text').empty();
row.find('.column-title .locked-avatar').empty();
}
});
}).on( 'heartbeat-send.wp-check-locked', function( e, data ) {
var check = [];
$('#the-list tr').each( function(i, el) {
check.push( el.id );
});
data['wp-check-locked'] = check;
});
}(jQuery));

View File

@ -419,9 +419,7 @@ function wp_default_scripts( &$scripts ) {
// @todo: Core no longer uses theme-preview.js. Remove?
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), false, 1 );
$scripts->add( 'edit-post', "/wp-admin/js/edit-post$suffix.js", array( 'heartbeat' ), false, 1 );
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'heartbeat' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'),
'ntdeltitle' => __('Remove From Bulk Edit'),