Ticket #37569: 37569.diff
File 37569.diff, 3.2 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/admin-filters.php
55 55 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); 56 56 add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); 57 57 58 add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); 59 add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); 60 add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); 61 add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); 58 add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); 59 add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); 60 add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); 61 add_filter( 'heartbeat_received', 'rest_refresh_nonce_on_heartbeat', 10, 2 ); 62 add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); 62 63 63 64 add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' ); 64 65 -
src/wp-includes/js/wp-api-nonce.js
1 jQuery( function ($) { 2 $( document ).on( 'heartbeat-send', function ( e, data ) { 3 data['wp-refresh-rest-nonce'] = wpApiSettings.nonce; 4 }); 5 $( document ).on( 'heartbeat-tick', function ( e, data ) { 6 if ( 'wp-refresh-rest-nonce' in data ) { 7 wpApiSettings.nonce = data['wp-refresh-rest-nonce']; 8 } 9 }); 10 }); -
src/wp-includes/rest-api.php
721 721 } 722 722 723 723 /** 724 * Refresh the REST API nonce on heartbeat requests. 725 * 726 * @since 4.8 727 * 728 * @param array $response The Heartbeat response. 729 * @param array $data The $_POST data sent. 730 * @return array The Heartbeat response. 731 */ 732 function rest_refresh_nonce_on_heartbeat( $response, $data ) { 733 if ( array_key_exists( 'wp-refresh-rest-nonce', $data ) ) { 734 // Are we in the second tick? 735 if ( wp_verify_nonce( $data['wp-refresh-rest-nonce'] ) === 2 ) { 736 // Update nonce. 737 $response['wp-refresh-rest-nonce'] = wp_create_nonce( 'wp_rest' ); 738 } 739 } 740 741 return $response; 742 } 743 744 /** 724 745 * Collects cookie authentication status. 725 746 * 726 747 * Collects errors from wp_validate_auth_cookie for use by rest_cookie_check_errors. -
src/wp-includes/script-loader.php
510 510 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), 511 511 'versionString' => 'wp/v2/', 512 512 ) ); 513 $scripts->add( 'wp-api-nonce', "/wp-includes/js/wp-api-nonce$suffix.js", array( 'jquery', 'wp-api', 'heartbeat' ), false, 1 ); 513 514 514 515 if ( is_admin() ) { 515 516 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );