diff --git src/wp-admin/includes/misc.php src/wp-admin/includes/misc.php
index fac9fd5d26..63446c5bfe 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 1355154c6d..6263530950 100644
|
|
function wp_default_packages_scripts( &$scripts ) { |
501 | 501 | function wp_default_packages_inline_scripts( &$scripts ) { |
502 | 502 | global $wp_locale; |
503 | 503 | |
| 504 | if ( isset( $scripts->registered['wp-api-fetch'] ) ) { |
| 505 | $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks'; |
| 506 | } |
504 | 507 | $scripts->add_inline_script( |
505 | 508 | 'wp-api-fetch', |
506 | 509 | sprintf( |
507 | | 'wp.apiFetch.use( wp.apiFetch.createNonceMiddleware( "%s" ) );', |
| 510 | implode( |
| 511 | "\n", |
| 512 | array( |
| 513 | '( function() {', |
| 514 | ' var nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );', |
| 515 | ' wp.apiFetch.use( nonceMiddleware );', |
| 516 | ' wp.hooks.addAction(', |
| 517 | ' "heartbeat.tick",', |
| 518 | ' "core/api-fetch/create-nonce-middleware",', |
| 519 | ' function( response ) {', |
| 520 | ' if ( response[ "rest_nonce" ] ) {', |
| 521 | ' nonceMiddleware.nonce = response[ "rest_nonce" ];', |
| 522 | ' }', |
| 523 | ' }', |
| 524 | ' )', |
| 525 | '} )()', |
| 526 | ) |
| 527 | ), |
508 | 528 | ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ) |
509 | 529 | ), |
510 | 530 | 'after' |