Ticket #48076: nonce-1.diff
File nonce-1.diff, 2.1 KB (added by , 6 years ago) |
---|
-
src/wp-admin/admin-ajax.php
53 53 'autocomplete-user', 54 54 'dashboard-widgets', 55 55 'logged-in', 56 'rest-nonce', 56 57 ); 57 58 58 59 $core_actions_post = array( -
src/wp-admin/includes/ajax-actions.php
5268 5268 5269 5269 wp_send_json_success( $all_sizes ); 5270 5270 } 5271 5272 /** 5273 * Ajax handler to renew the REST API nonce. 5274 * 5275 * @since 5.3.0 5276 */ 5277 function wp_ajax_rest_nonce() { 5278 exit( wp_create_nonce( 'wp_rest' ) ); 5279 } -
src/wp-includes/script-loader.php
651 651 } 652 652 $scripts->add_inline_script( 653 653 'wp-api-fetch', 654 sprintf( 655 implode( 656 "\n", 657 array( 658 '( function() {', 659 ' var nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', 660 ' wp.apiFetch.use( nonceMiddleware );', 661 ' wp.hooks.addAction(', 662 ' "heartbeat.tick",', 663 ' "core/api-fetch/create-nonce-middleware",', 664 ' function( response ) {', 665 ' if ( response[ "rest_nonce" ] ) {', 666 ' nonceMiddleware.nonce = response[ "rest_nonce" ];', 667 ' }', 668 ' }', 669 ' );', 670 '} )();', 671 ) 654 join( array( 655 sprintf( 656 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', 657 ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) 672 658 ), 673 ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) 674 ), 659 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );', 660 sprintf( 661 'wp.apiFetch.nonceEndpoint = "%s";', 662 admin_url( 'admin-ajax.php?action=rest-nonce' ) 663 ), 664 ), "\n" ), 675 665 'after' 676 666 ); 677 667 $scripts->add_inline_script(