Post locks: add Preview button when post is locked, fix the suggested places, see #23312

git-svn-id: http://core.svn.wordpress.org/trunk@23725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-03-15 21:09:20 +00:00
parent 7ed5d35d92
commit 99488cb638
3 changed files with 24 additions and 10 deletions

View File

@ -3430,8 +3430,8 @@ td.plugin-title p {
margin: 25px; margin: 25px;
} }
#notification-dialog .post-locked-message a.button-primary { #notification-dialog .post-locked-message a.button {
margin: 0 10px; margin-right: 10px;
} }
#notification-dialog .post-locked-avatar { #notification-dialog .post-locked-avatar {

View File

@ -1198,34 +1198,48 @@ function wp_set_post_lock( $post_id ) {
* @return none * @return none
*/ */
function _admin_notice_post_locked() { function _admin_notice_post_locked() {
global $post_ID; if ( ! $post = get_post() )
return;
if ( !empty( $post_ID ) && ( $user = wp_check_post_lock( $post_ID ) ) ) { if ( $user = wp_check_post_lock( $post->ID ) ) {
$user = get_userdata( $user ); $user = get_userdata( $user );
$locked = apply_filters( 'show_post_locked_dialog', true, $post_ID, $user ); $locked = apply_filters( 'show_post_locked_dialog', true, $post, $user );
} else { } else {
$locked = false; $locked = false;
} }
$class = $locked ? '' : ' class="hidden"';
?> ?>
<div id="notification-dialog-wrap"<?php if ( ! $locked ) echo ' style="display:none"'; ?>> <div id="notification-dialog-wrap"<?php echo $class; ?>>
<div id="notification-dialog-background"></div> <div id="notification-dialog-background"></div>
<div id="notification-dialog"> <div id="notification-dialog">
<?php <?php
if ( $locked ) { if ( $locked ) {
$preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );
if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
// Latest content is in autosave
$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
$preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
}
$preview_link = apply_filters( 'preview_post_link', $preview_link );
?> ?>
<div class="post-locked-message"> <div class="post-locked-message">
<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div> <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
<p><?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p> <p><?php esc_html_e( sprintf( __( 'This content is currently locked. If you take over, %s will be blocked from continuing to edit.' ), $user->display_name ) ); ?></p>
<p> <p>
<a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a> <a class="button" href="<?php echo esc_url( wp_get_referer() ); ?>"><?php _e('Go back'); ?></a>
<a class="button" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
<?php <?php
// Allow plugins to prevent some users taking over // Allow plugins to prevent some users overriding the post lock
if ( apply_filters( 'post_lock_take_over', true, $post_ID, $user ) ) { if ( apply_filters( 'override_post_lock', true, $post, $user ) ) {
?> ?>
<a class="button button-primary" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post_ID, 'url' ) ) ); ?>"><?php _e('Take over'); ?></a> <a class="button button-primary" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', get_edit_post_link( $post->ID, 'url' ) ) ); ?>"><?php _e('Take over'); ?></a>
<?php <?php
} }

View File

@ -279,7 +279,7 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
autosave(); autosave();
wrap.find('p.currently-editing').text( received.lock_error.text ); wrap.find('p.currently-editing').text( received.lock_error.text );
if ( received.lock_error.avatar_src && /^https?:\/\/[a-z0-9]+?\.gravatar\.com\/avatar/.test( received.lock_error.avatar_src ) ) { if ( received.lock_error.avatar_src ) {
avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr( 'src', received.lock_error.avatar_src.replace(/&amp;/g, '&') ); avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr( 'src', received.lock_error.avatar_src.replace(/&amp;/g, '&') );
wrap.find('div.post-locked-avatar').empty().append( avatar ); wrap.find('div.post-locked-avatar').empty().append( avatar );
} }