Make WordPress Core


Ignore:
Timestamp:
03/13/2013 12:28:07 AM (11 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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/**
Note: See TracChangeset for help on using the changeset viewer.