<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23681] trunk: 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</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23681">23681</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-03-13 00:28:07 +0000 (Wed, 13 Mar 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/23312">#23312</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludesclasswppostslisttablephp">trunk/wp-admin/includes/class-wp-posts-list-table.php</a></li>
<li><a href="#trunkwpadminincludesmiscphp">trunk/wp-admin/includes/misc.php</a></li>
<li><a href="#trunkwpadminjsinlineeditpostjs">trunk/wp-admin/js/inline-edit-post.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadminimageslock2xpng">trunk/wp-admin/images/lock-2x.png</a></li>
<li><a href="#trunkwpadminimageslockpng">trunk/wp-admin/images/lock.png</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkwpadminimageslock16png">trunk/wp-admin/images/lock16.png</a></li>
<li><a href="#trunkwpadminjseditpostjs">trunk/wp-admin/js/edit-post.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/css/wp-admin.css        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -2425,12 +2425,13 @@
</span><span class="cx">
</span><span class="cx"> .fixed .column-date,
</span><span class="cx"> .fixed .column-parent,
</span><del>-.fixed .column-links {
</del><ins>+.fixed .column-links,
+.fixed .column-author,
+.fixed .column-format {
</ins><span class="cx">         width: 10%;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .fixed .column-response,
</span><del>-.fixed .column-author,
</del><span class="cx"> .fixed .column-categories,
</span><span class="cx"> .fixed .column-tags,
</span><span class="cx"> .fixed .column-rel,
</span><span class="lines">@@ -2529,8 +2530,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> tr.wp-locked .locked-indicator {
</span><del>-        background: url('../images/lock16.png') no-repeat;
-        margin: -2px 0 0 8px;
</del><ins>+        background: url('../images/lock.png') no-repeat;
+        margin: -2px 0 0 6px;
</ins><span class="cx">         height: 16px;
</span><span class="cx">         width: 16px;
</span><span class="cx"> }
</span><span class="lines">@@ -2538,15 +2539,10 @@
</span><span class="cx"> tr.wp-locked .check-column label,
</span><span class="cx"> tr.wp-locked .check-column input[type="checkbox"],
</span><span class="cx"> tr.wp-locked .row-actions .inline,
</span><del>-tr.wp-locked .row-actions .trash,
-.lock-holder {
</del><ins>+tr.wp-locked .row-actions .trash {
</ins><span class="cx">         display: none;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-tr.wp-locked .lock-holder {
-        display: inline;
-}
-
</del><span class="cx"> .fixed .column-comments .sorting-indicator {
</span><span class="cx">         margin-top: 3px;
</span><span class="cx"> }
</span><span class="lines">@@ -9034,6 +9030,11 @@
</span><span class="cx">                 background-size: 18px 100px;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        tr.wp-locked .locked-indicator {
+                background-image: url('../images/lock-2x.png');
+                background-size: 16px 16px;
+        }
+
</ins><span class="cx">         th .comment-grey-bubble {
</span><span class="cx">                 background-image: url('../images/comment-grey-bubble-2x.png');
</span><span class="cx">                 background-size: 12px 12px;
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/edit.php        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -145,7 +145,6 @@
</span><span class="cx"> $wp_list_table->prepare_items();
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script('inline-edit-post');
</span><del>-wp_enqueue_script('edit-post');
</del><span class="cx">
</span><span class="cx"> $title = $post_type_object->labels->name;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminimageslock2xpng"></a>
<div class="binary"><h4>Added: trunk/wp-admin/images/lock-2x.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-admin/images/lock-2x.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkwpadminimageslockpng"></a>
<div class="binary"><h4>Added: trunk/wp-admin/images/lock.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-admin/images/lock.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkwpadminimageslock16png"></a>
<div class="binary"><h4>Deleted: trunk/wp-admin/images/lock16.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkwpadminincludesclasswppostslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-posts-list-table.php (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-posts-list-table.php        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/includes/class-wp-posts-list-table.php        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -553,9 +553,15 @@
</span><span class="cx">
</span><span class="cx">                                 echo "</strong>\n";
</span><span class="cx">
</span><del>-                                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 ) ) );
</del><ins>+                                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";
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
</span></span></pre></div>
<a id="trunkwpadminincludesmiscphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/misc.php (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/misc.php        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/includes/misc.php        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -566,16 +566,21 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 3.6
</span><span class="cx"> */
</span><del>-function wp_check_locked_posts( $response, $data ) {
</del><ins>+function wp_check_locked_posts( $response, $data, $screen_id ) {
</ins><span class="cx">         $checked = array();
</span><span class="cx">
</span><del>-        if ( array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
</del><ins>+        if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
</ins><span class="cx">                 foreach ( $data['wp-check-locked'] as $key ) {
</span><span class="cx">                         $post_id = (int) substr( $key, 5 );
</span><span class="cx">
</span><del>-                        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 );
</del><ins>+                        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;
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -585,7 +590,7 @@
</span><span class="cx">
</span><span class="cx">         return $response;
</span><span class="cx"> }
</span><del>-add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 2 );
</del><ins>+add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Check lock status on the New/Edit Post screen and refresh the lock
</span></span></pre></div>
<a id="trunkwpadminjseditpostjs"></a>
<div class="delfile"><h4>Deleted: trunk/wp-admin/js/edit-post.js (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/edit-post.js        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/js/edit-post.js        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -1,25 +0,0 @@
</span><del>-(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));
</del></span></pre></div>
<a id="trunkwpadminjsinlineeditpostjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/inline-edit-post.js (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/inline-edit-post.js        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-admin/js/inline-edit-post.js        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -290,5 +290,39 @@
</span><span class="cx">         }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-$(document).ready(function(){inlineEditPost.init();});
-})(jQuery);
</del><ins>+$( 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));
</ins></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (23680 => 23681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2013-03-12 22:44:55 UTC (rev 23680)
+++ trunk/wp-includes/script-loader.php        2013-03-13 00:28:07 UTC (rev 23681)
</span><span class="lines">@@ -419,9 +419,7 @@
</span><span class="cx">                 // @todo: Core no longer uses theme-preview.js. Remove?
</span><span class="cx">                 $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), false, 1 );
</span><span class="cx">
</span><del>-                $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 );
</del><ins>+                $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'heartbeat' ), false, 1 );
</ins><span class="cx">                 did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
</span><span class="cx">                         'error' => __('Error while saving the changes.'),
</span><span class="cx">                         'ntdeltitle' => __('Remove From Bulk Edit'),
</span></span></pre>
</div>
</div>
</body>
</html>