diff --git src/wp-admin/includes/misc.php src/wp-admin/includes/misc.php
index c580c25c92..4648efc4af 100644
|
|
function wp_refresh_post_nonces( $response, $data, $screen_id ) { |
1082 | 1082 | function wp_refresh_heartbeat_nonces( $response ) { |
1083 | 1083 | // Refresh the Rest API nonce. |
1084 | 1084 | $response['rest_nonce'] = wp_create_nonce( 'wp_rest' ); |
1085 | | // TEMPORARY: Compat with api-fetch library |
1086 | | $response['rest-nonce'] = $response['rest_nonce']; |
1087 | 1085 | |
1088 | 1086 | // Refresh the Heartbeat nonce. |
1089 | 1087 | $response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' ); |
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
index af65319791..3aee09ad6a 100644
|
|
function wp_default_packages_scripts( &$scripts ) { |
521 | 521 | function wp_default_packages_inline_scripts( &$scripts ) { |
522 | 522 | global $wp_locale; |
523 | 523 | |
| 524 | if ( isset( $scripts->registered['wp-api-fetch'] ) ) { |
| 525 | $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks'; |
| 526 | } |
524 | 527 | $scripts->add_inline_script( |
525 | 528 | 'wp-api-fetch', |
526 | 529 | sprintf( |
527 | | 'wp.apiFetch.use( wp.apiFetch.createNonceMiddleware( "%s" ) );', |
| 530 | implode( |
| 531 | "\n", |
| 532 | array( |
| 533 | '( function() {', |
| 534 | ' var nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', |
| 535 | ' wp.apiFetch.use( nonceMiddleware );', |
| 536 | ' wp.hooks.addAction(', |
| 537 | ' "heartbeat.tick",', |
| 538 | ' "core/api-fetch/create-nonce-middleware",', |
| 539 | ' function( response ) {', |
| 540 | ' if ( response[ "rest_nonce" ] ) {', |
| 541 | ' nonceMiddleware.nonce = response[ "rest_nonce" ];', |
| 542 | ' }', |
| 543 | ' }', |
| 544 | ' );', |
| 545 | '} )();', |
| 546 | ) |
| 547 | ), |
528 | 548 | ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) |
529 | 549 | ), |
530 | 550 | 'after' |