Post locks:

- Change from IDs to classes for the notification-dialog divs so they can be reused.
- Do not check post locks if the dialog's html is not present.
- Do not check post locks if there is only one user on a single site install.
See #23697.

git-svn-id: http://core.svn.wordpress.org/trunk@24304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-05-20 19:36:29 +00:00
parent ad4a081c0c
commit a26190eb2e
4 changed files with 27 additions and 25 deletions

View File

@ -3391,7 +3391,7 @@ td.plugin-title p {
border-style: solid;
}
#notification-dialog {
.notification-dialog {
position: fixed;
top: 30%;
left: 50%;
@ -3402,7 +3402,7 @@ td.plugin-title p {
z-index: 1000005;
}
#notification-dialog-background {
.notification-dialog-background {
position: fixed;
top: 0;
left: 0;
@ -3414,31 +3414,31 @@ td.plugin-title p {
z-index: 1000000;
}
#notification-dialog .post-locked-message,
#notification-dialog .post-taken-over {
#post-lock-dialog .post-locked-message,
#post-lock-dialog .post-taken-over {
margin: 25px;
}
#notification-dialog .post-locked-message a.button {
#post-lock-dialog .post-locked-message a.button {
margin-right: 10px;
}
#notification-dialog .post-locked-avatar {
#post-lock-dialog .post-locked-avatar {
float: left;
margin: 0 20px 20px 0;
}
#notification-dialog .wp-tab-first {
#post-lock-dialog .wp-tab-first {
outline: 0;
}
#notification-dialog .locked-saving img {
#post-lock-dialog .locked-saving img {
float: left;
margin-right: 3px;
}
#notification-dialog-wrap.saving .locked-saving,
#notification-dialog-wrap.saved .locked-saved {
#post-lock-dialog.saving .locked-saving,
#post-lock-dialog.saved .locked-saved {
display: inline;
}

View File

@ -1202,12 +1202,12 @@ function _admin_notice_post_locked() {
$locked = false;
}
$class = $locked ? '' : ' class="hidden"';
$hidden = $locked ? '' : ' hidden';
?>
<div id="notification-dialog-wrap"<?php echo $class; ?>>
<div id="notification-dialog-background"></div>
<div id="notification-dialog">
<div id="post-lock-dialog" class="notification-dialog-wrap<?php echo $hidden; ?>">
<div class="notification-dialog-background"></div>
<div class="notification-dialog">
<?php
if ( $locked ) {

View File

@ -256,7 +256,7 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
post_id = $('#post_ID').val(),
send = {};
if ( !post_id )
if ( ! post_id || ! $('#post-lock-dialog').length )
return;
send['post_id'] = post_id;
@ -276,7 +276,7 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
if ( received.lock_error ) {
// show "editing taken over" message
wrap = $('#notification-dialog-wrap');
wrap = $('#post-lock-dialog');
if ( wrap.length && ! wrap.is(':visible') ) {
if ( typeof autosave == 'function' ) {
@ -305,13 +305,6 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
} else if ( received.new_lock ) {
$('#active_post_lock').val( received.new_lock );
}
if ( received.update_nonces ) {
$.each( received.update_nonces, function( selector, value ) {
if ( selector.match(/^replace-/) )
$( '#' + selector.replace('replace-', '') ).val( value );
});
}
}
});
@ -359,7 +352,7 @@ jQuery(document).ready( function($) {
postboxes.add_postbox_toggles(pagenow);
// Post locks: contain focus inside the dialog. If the dialog is shown, focus the first item.
$('#notification-dialog').on( 'keydown', function(e) {
$('#post-lock-dialog .notification-dialog').on( 'keydown', function(e) {
if ( e.which != 9 )
return;

View File

@ -176,7 +176,16 @@ case 'edit':
wp_enqueue_script('autosave');
}
add_action( 'admin_footer', '_admin_notice_post_locked' );
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
if ( count( $check_users ) > 1 )
add_action( 'admin_footer', '_admin_notice_post_locked' );
unset( $check_users );
}
$title = $post_type_object->labels->edit_item;
$post = get_post($post_id, OBJECT, 'edit');