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

@@ -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