Separate the nonces update from checking the post lock. Fix scheduling the logged out check. See #23697, see #23295.
git-svn-id: http://core.svn.wordpress.org/trunk@24273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f72b7c967
commit
2f0c58960a
|
@ -623,8 +623,30 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
|||
$send['new_lock'] = implode( ':', $new_lock );
|
||||
}
|
||||
|
||||
$response['wp-refresh-post-lock'] = $send;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
|
||||
|
||||
/**
|
||||
* Check nonce expiration on the New/Edit Post screen and refresh if needed
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
||||
if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
|
||||
$received = $data['wp-refresh-post-nonces'];
|
||||
|
||||
if ( ! $post_id = absint( $received['post_id'] ) )
|
||||
return $response;
|
||||
|
||||
if ( ! current_user_can('edit_post', $post_id) )
|
||||
return $response;
|
||||
|
||||
if ( ! empty( $received['post_nonce'] ) && 2 === wp_verify_nonce( $received['post_nonce'], 'update-post_' . $post_id ) ) {
|
||||
$send['update_nonces'] = array(
|
||||
$response['wp-refresh-post-nonces'] = array(
|
||||
'replace-autosavenonce' => wp_create_nonce('autosave'),
|
||||
'replace-getpermalinknonce' => wp_create_nonce('getpermalink'),
|
||||
'replace-samplepermalinknonce' => wp_create_nonce('samplepermalink'),
|
||||
|
@ -633,13 +655,11 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
|||
'replace-_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
|
||||
);
|
||||
}
|
||||
|
||||
$response['wp-refresh-post-lock'] = $send;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_nonces', 10, 3 );
|
||||
|
||||
/**
|
||||
* Output the HTML for restoring the post data from DOM storage
|
||||
|
|
|
@ -254,7 +254,6 @@ WPRemoveThumbnail = function(nonce){
|
|||
$(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
|
||||
var lock = $('#active_post_lock').val(),
|
||||
post_id = $('#post_ID').val(),
|
||||
post_nonce = $('#_wpnonce').val(),
|
||||
send = {};
|
||||
|
||||
if ( !post_id )
|
||||
|
@ -265,9 +264,6 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
|
|||
if ( lock )
|
||||
send['lock'] = lock;
|
||||
|
||||
if ( post_nonce )
|
||||
send['post_nonce'] = post_nonce;
|
||||
|
||||
data['wp-refresh-post-lock'] = send;
|
||||
});
|
||||
|
||||
|
@ -321,6 +317,42 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
|
|||
|
||||
}(jQuery));
|
||||
|
||||
(function($) {
|
||||
var check, timeout;
|
||||
|
||||
function schedule() {
|
||||
check = false;
|
||||
window.clearTimeout( timeout );
|
||||
timeout = window.setTimeout( function(){ check = 1; }, 3600000 );
|
||||
}
|
||||
|
||||
$(document).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) {
|
||||
var nonce, post_id;
|
||||
|
||||
if ( check ) {
|
||||
if ( ( post_id = $('#post_ID').val() ) && ( nonce = $('#_wpnonce').val() ) ) {
|
||||
data['wp-refresh-post-nonces'] = {
|
||||
post_id: post_id,
|
||||
post_nonce: nonce
|
||||
};
|
||||
}
|
||||
check = 2;
|
||||
}
|
||||
}).on( 'heartbeat-tick.wp-refresh-nonces', function( e, data ) {
|
||||
if ( check === 2 )
|
||||
schedule();
|
||||
|
||||
if ( data['wp-refresh-post-nonces'] ) {
|
||||
$.each( data['wp-refresh-post-nonces'], function( selector, value ) {
|
||||
if ( selector.match(/^replace-/) )
|
||||
$( '#' + selector.replace('replace-', '') ).val( value );
|
||||
});
|
||||
}
|
||||
}).ready( function() {
|
||||
schedule();
|
||||
});
|
||||
}(jQuery));
|
||||
|
||||
jQuery(document).ready( function($) {
|
||||
var stamp, visibility, sticky = '', last = 0, co = $('#content');
|
||||
|
||||
|
|
|
@ -72,11 +72,11 @@
|
|||
function schedule() {
|
||||
check = false;
|
||||
window.clearTimeout( timeout );
|
||||
timeout = window.setTimeout( function(){ check = true; }, 180000 ); // 3 min.
|
||||
timeout = window.setTimeout( function(){ check = 1; }, 180000 ); // 3 min.
|
||||
}
|
||||
|
||||
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
|
||||
if ( check )
|
||||
if ( check === 2 )
|
||||
schedule();
|
||||
|
||||
if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
|
||||
|
@ -103,6 +103,9 @@
|
|||
|
||||
if ( check || ! empty )
|
||||
data['wp-auth-check'] = 1;
|
||||
|
||||
if ( check )
|
||||
check = 2;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue