<!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>[23725] trunk/wp-admin: Post locks: add Preview button when post is locked, fix the suggested places, 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/23725">23725</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-03-15 21:09:20 +0000 (Fri, 15 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Post locks: add Preview button when post is locked, fix the suggested places, 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="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminjspostjs">trunk/wp-admin/js/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 (23724 => 23725)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-03-15 19:19:53 UTC (rev 23724)
+++ trunk/wp-admin/css/wp-admin.css        2013-03-15 21:09:20 UTC (rev 23725)
</span><span class="lines">@@ -3430,8 +3430,8 @@
</span><span class="cx">         margin: 25px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#notification-dialog .post-locked-message a.button-primary {
-        margin: 0 10px;
</del><ins>+#notification-dialog .post-locked-message a.button {
+        margin-right: 10px;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #notification-dialog .post-locked-avatar {
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (23724 => 23725)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2013-03-15 19:19:53 UTC (rev 23724)
+++ trunk/wp-admin/includes/post.php        2013-03-15 21:09:20 UTC (rev 23725)
</span><span class="lines">@@ -1198,34 +1198,48 @@
</span><span class="cx">  * @return none
</span><span class="cx">  */
</span><span class="cx"> function _admin_notice_post_locked() {
</span><del>-        global $post_ID;
</del><ins>+        if ( ! $post = get_post() )
+                return;
</ins><span class="cx"> 
</span><del>-        if ( !empty( $post_ID ) &amp;&amp; ( $user = wp_check_post_lock( $post_ID ) ) ) {
</del><ins>+        if ( $user = wp_check_post_lock( $post-&gt;ID ) ) {
</ins><span class="cx">                 $user = get_userdata( $user );
</span><del>-                $locked = apply_filters( 'show_post_locked_dialog', true, $post_ID, $user );
</del><ins>+                $locked = apply_filters( 'show_post_locked_dialog', true, $post, $user );
</ins><span class="cx">         } else {
</span><span class="cx">                 $locked = false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        $class = $locked ? '' : ' class=&quot;hidden&quot;';
+
</ins><span class="cx">         ?&gt;
</span><del>-        &lt;div id=&quot;notification-dialog-wrap&quot;&lt;?php if ( ! $locked ) echo ' style=&quot;display:none&quot;'; ?&gt;&gt;
</del><ins>+        &lt;div id=&quot;notification-dialog-wrap&quot;&lt;?php echo $class; ?&gt;&gt;
</ins><span class="cx">         &lt;div id=&quot;notification-dialog-background&quot;&gt;&lt;/div&gt;
</span><span class="cx">         &lt;div id=&quot;notification-dialog&quot;&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx"> 
</span><span class="cx">         if ( $locked ) {
</span><ins>+                $preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post-&gt;ID ) ) );
+
+                if ( 'publish' == $post-&gt;post_status || $user-&gt;ID != $post-&gt;post_author ) {
+                        // Latest content is in autosave
+                        $nonce = wp_create_nonce( 'post_preview_' . $post-&gt;ID );
+                        $preview_link = add_query_arg( array( 'preview_id' =&gt; $post-&gt;ID, 'preview_nonce' =&gt; $nonce ), $preview_link );
+                }
+
+                $preview_link = apply_filters( 'preview_post_link', $preview_link );
+
</ins><span class="cx">                 ?&gt;
</span><span class="cx">                 &lt;div class=&quot;post-locked-message&quot;&gt;
</span><span class="cx">                 &lt;div class=&quot;post-locked-avatar&quot;&gt;&lt;?php echo get_avatar( $user-&gt;ID, 64 ); ?&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;p&gt;&lt;?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user-&gt;display_name ) ); ?&gt;&lt;/p&gt;
</span><span class="cx">                 &lt;p&gt;
</span><span class="cx">                 &lt;a class=&quot;button&quot; href=&quot;&lt;?php echo esc_url( wp_get_referer() ); ?&gt;&quot;&gt;&lt;?php _e('Go back'); ?&gt;&lt;/a&gt;
</span><ins>+                &lt;a class=&quot;button&quot; href=&quot;&lt;?php echo esc_url( $preview_link ); ?&gt;&quot;&gt;&lt;?php _e('Preview'); ?&gt;&lt;/a&gt;
</ins><span class="cx">                 &lt;?php
</span><span class="cx"> 
</span><del>-                // Allow plugins to prevent some users taking over
-                if ( apply_filters( 'post_lock_take_over', true, $post_ID, $user ) ) {
</del><ins>+                // Allow plugins to prevent some users overriding the post lock
+                if ( apply_filters( 'override_post_lock', true, $post, $user ) ) {
</ins><span class="cx">                         ?&gt;
</span><del>-                        &lt;a class=&quot;button button-primary&quot; href=&quot;&lt;?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post_ID, 'url' ) ) ); ?&gt;&quot;&gt;&lt;?php _e('Take over'); ?&gt;&lt;/a&gt;
</del><ins>+                        &lt;a class=&quot;button button-primary&quot; href=&quot;&lt;?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post-&gt;ID, 'url' ) ) ); ?&gt;&quot;&gt;&lt;?php _e('Take over'); ?&gt;&lt;/a&gt;
</ins><span class="cx">                         &lt;?php
</span><span class="cx">                 }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminjspostjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/post.js (23724 => 23725)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/post.js        2013-03-15 19:19:53 UTC (rev 23724)
+++ trunk/wp-admin/js/post.js        2013-03-15 21:09:20 UTC (rev 23725)
</span><span class="lines">@@ -279,7 +279,7 @@
</span><span class="cx">                                 autosave();
</span><span class="cx">                                 wrap.find('p.currently-editing').text( received.lock_error.text );
</span><span class="cx">                                 
</span><del>-                                if ( received.lock_error.avatar_src &amp;&amp; /^https?:\/\/[a-z0-9]+?\.gravatar\.com\/avatar/.test( received.lock_error.avatar_src ) ) {
</del><ins>+                                if ( received.lock_error.avatar_src ) {
</ins><span class="cx">                                         avatar = $('&lt;img class=&quot;avatar avatar-64 photo&quot; width=&quot;64&quot; height=&quot;64&quot; /&gt;').attr( 'src', received.lock_error.avatar_src.replace(/&amp;amp;/g, '&amp;') );
</span><span class="cx">                                         wrap.find('div.post-locked-avatar').empty().append( avatar );
</span><span class="cx">                                 }
</span></span></pre>
</div>
</div>

</body>
</html>