Changeset 33468
- Timestamp:
- 07/28/2015 10:06:52 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/admin-filters.php
r33011 r33468 59 59 add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); 60 60 add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); 61 add_filter( ' heartbeat_received', 'wp_refresh_post_nonces', 10, 3 );61 add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); 62 62 add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); 63 63 -
trunk/src/wp-admin/includes/ajax-actions.php
r33432 r33468 2572 2572 */ 2573 2573 function wp_ajax_heartbeat() { 2574 if ( empty( $_POST['_nonce'] ) ) 2575 wp_send_json_error(); 2576 2577 $response = array(); 2578 2579 if ( false === wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ) ) { 2580 // User is logged in but nonces have expired. 2581 $response['nonces_expired'] = true; 2582 wp_send_json($response); 2583 } 2574 if ( empty( $_POST['_nonce'] ) ) { 2575 wp_send_json_error(); 2576 } 2577 2578 $response = $data = array(); 2579 $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); 2584 2580 2585 2581 // screen_id is the same as $current_screen->id and the JS global 'pagenow'. 2586 if ( ! empty( $_POST['screen_id']) )2582 if ( ! empty( $_POST['screen_id'] ) ) { 2587 2583 $screen_id = sanitize_key($_POST['screen_id']); 2588 else2584 } else { 2589 2585 $screen_id = 'front'; 2590 2591 if ( ! empty($_POST['data']) ) { 2586 } 2587 2588 if ( ! empty( $_POST['data'] ) ) { 2592 2589 $data = wp_unslash( (array) $_POST['data'] ); 2593 2590 } 2591 2592 if ( 1 !== $nonce_state ) { 2593 $response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id ); 2594 2595 if ( false === $nonce_state ) { 2596 // User is logged in but nonces have expired. 2597 $response['nonces_expired'] = true; 2598 wp_send_json( $response ); 2599 } 2600 } 2601 2602 if ( ! empty( $data ) ) { 2594 2603 /** 2595 2604 * Filter the Heartbeat response received. … … 2629 2638 $response['server_time'] = time(); 2630 2639 2631 wp_send_json( $response);2640 wp_send_json( $response ); 2632 2641 } 2633 2642 -
trunk/src/wp-admin/includes/misc.php
r32672 r33468 772 772 $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); 773 773 774 if ( ! $post_id = absint( $received['post_id'] ) ) 774 if ( ! $post_id = absint( $received['post_id'] ) ) { 775 775 return $response; 776 777 if ( ! current_user_can( 'edit_post', $post_id ) || empty( $received['post_nonce'] ) ) 776 } 777 778 if ( ! current_user_can( 'edit_post', $post_id ) ) { 778 779 return $response; 779 780 if ( 2 === wp_verify_nonce( $received['post_nonce'], 'update-post_' . $post_id ) ) { 781 $response['wp-refresh-post-nonces'] = array( 782 'replace' => array( 783 'getpermalinknonce' => wp_create_nonce('getpermalink'), 784 'samplepermalinknonce' => wp_create_nonce('samplepermalink'), 785 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'), 786 '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ), 787 '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ), 788 ), 789 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ), 790 ); 791 } 780 } 781 782 $response['wp-refresh-post-nonces'] = array( 783 'replace' => array( 784 'getpermalinknonce' => wp_create_nonce('getpermalink'), 785 'samplepermalinknonce' => wp_create_nonce('samplepermalink'), 786 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'), 787 '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ), 788 '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ), 789 ), 790 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ), 791 ); 792 792 } 793 793 -
trunk/src/wp-admin/js/post.js
r33352 r33468 171 171 172 172 $(document).on( 'heartbeat-send.wp-refresh-nonces', function( e, data ) { 173 var nonce, post_id; 174 175 if ( check ) { 176 if ( ( post_id = $('#post_ID').val() ) && ( nonce = $('#_wpnonce').val() ) ) { 173 var post_id, 174 $authCheck = $('#wp-auth-check-wrap'); 175 176 if ( check || ( $authCheck.length && ! $authCheck.hasClass( 'hidden' ) ) ) { 177 if ( ( post_id = $('#post_ID').val() ) && $('#_wpnonce').val() ) { 177 178 data['wp-refresh-post-nonces'] = { 178 post_id: post_id, 179 post_nonce: nonce 179 post_id: post_id 180 180 }; 181 181 } -
trunk/src/wp-includes/js/heartbeat.js
r30293 r33468 390 390 if ( response.nonces_expired ) { 391 391 $document.trigger( 'heartbeat-nonces-expired' ); 392 return;393 392 } 394 393
Note: See TracChangeset
for help on using the changeset viewer.