Changeset 24273
- Timestamp:
- 05/16/2013 03:47:09 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/misc.php
r24209 r24273 624 624 } 625 625 626 $response['wp-refresh-post-lock'] = $send; 627 } 628 629 return $response; 630 } 631 add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); 632 633 /** 634 * Check nonce expiration on the New/Edit Post screen and refresh if needed 635 * 636 * @since 3.6 637 */ 638 function wp_refresh_post_nonces( $response, $data, $screen_id ) { 639 if ( 'post' == $screen_id && array_key_exists( 'wp-refresh-post-nonces', $data ) ) { 640 $received = $data['wp-refresh-post-nonces']; 641 642 if ( ! $post_id = absint( $received['post_id'] ) ) 643 return $response; 644 645 if ( ! current_user_can('edit_post', $post_id) ) 646 return $response; 647 626 648 if ( ! empty( $received['post_nonce'] ) && 2 === wp_verify_nonce( $received['post_nonce'], 'update-post_' . $post_id ) ) { 627 $ send['update_nonces'] = array(649 $response['wp-refresh-post-nonces'] = array( 628 650 'replace-autosavenonce' => wp_create_nonce('autosave'), 629 651 'replace-getpermalinknonce' => wp_create_nonce('getpermalink'), … … 634 656 ); 635 657 } 636 637 $response['wp-refresh-post-lock'] = $send;638 658 } 639 659 640 660 return $response; 641 661 } 642 add_filter( 'heartbeat_received', 'wp_refresh_post_ lock', 10, 3 );662 add_filter( 'heartbeat_received', 'wp_refresh_post_nonces', 10, 3 ); 643 663 644 664 /** -
trunk/wp-admin/js/post.js
r24209 r24273 255 255 var lock = $('#active_post_lock').val(), 256 256 post_id = $('#post_ID').val(), 257 post_nonce = $('#_wpnonce').val(),258 257 send = {}; 259 258 … … 265 264 if ( lock ) 266 265 send['lock'] = lock; 267 268 if ( post_nonce )269 send['post_nonce'] = post_nonce;270 266 271 267 data['wp-refresh-post-lock'] = send; … … 320 316 }); 321 317 318 }(jQuery)); 319 320 (function($) { 321 var check, timeout; 322 323 function schedule() { 324 check = false; 325 window.clearTimeout( timeout ); 326 timeout = window.setTimeout( function(){ check = 1; }, 3600000 ); 327 } 328 329 $(document).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) { 330 var nonce, post_id; 331 332 if ( check ) { 333 if ( ( post_id = $('#post_ID').val() ) && ( nonce = $('#_wpnonce').val() ) ) { 334 data['wp-refresh-post-nonces'] = { 335 post_id: post_id, 336 post_nonce: nonce 337 }; 338 } 339 check = 2; 340 } 341 }).on( 'heartbeat-tick.wp-refresh-nonces', function( e, data ) { 342 if ( check === 2 ) 343 schedule(); 344 345 if ( data['wp-refresh-post-nonces'] ) { 346 $.each( data['wp-refresh-post-nonces'], function( selector, value ) { 347 if ( selector.match(/^replace-/) ) 348 $( '#' + selector.replace('replace-', '') ).val( value ); 349 }); 350 } 351 }).ready( function() { 352 schedule(); 353 }); 322 354 }(jQuery)); 323 355 -
trunk/wp-includes/js/wp-auth-check.js
r24271 r24273 73 73 check = false; 74 74 window.clearTimeout( timeout ); 75 timeout = window.setTimeout( function(){ check = true; }, 180000 ); // 3 min.75 timeout = window.setTimeout( function(){ check = 1; }, 180000 ); // 3 min. 76 76 } 77 77 78 78 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) { 79 if ( check )79 if ( check === 2 ) 80 80 schedule(); 81 81 … … 104 104 if ( check || ! empty ) 105 105 data['wp-auth-check'] = 1; 106 107 if ( check ) 108 check = 2; 106 109 }); 107 110 });
Note: See TracChangeset
for help on using the changeset viewer.