mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
Editor: Add Nonce Endpoint
This is a follow up to #47843, implementing a PHP endpoint and inline scripts after the editor package updates. The action was originally added in https://github.com/WordPress/gutenberg/pull/16683. Fixes #48076. git-svn-id: https://develop.svn.wordpress.org/trunk@46253 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -651,26 +651,19 @@ function wp_default_packages_inline_scripts( &$scripts ) {
|
||||
}
|
||||
$scripts->add_inline_script(
|
||||
'wp-api-fetch',
|
||||
sprintf(
|
||||
implode(
|
||||
"\n",
|
||||
array(
|
||||
'( function() {',
|
||||
' var nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
|
||||
' wp.apiFetch.use( nonceMiddleware );',
|
||||
' wp.hooks.addAction(',
|
||||
' "heartbeat.tick",',
|
||||
' "core/api-fetch/create-nonce-middleware",',
|
||||
' function( response ) {',
|
||||
' if ( response[ "rest_nonce" ] ) {',
|
||||
' nonceMiddleware.nonce = response[ "rest_nonce" ];',
|
||||
' }',
|
||||
' }',
|
||||
' );',
|
||||
'} )();',
|
||||
)
|
||||
join(
|
||||
array(
|
||||
sprintf(
|
||||
'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
|
||||
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
|
||||
),
|
||||
'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
|
||||
sprintf(
|
||||
'wp.apiFetch.nonceEndpoint = "%s";',
|
||||
admin_url( 'admin-ajax.php?action=rest-nonce' )
|
||||
),
|
||||
),
|
||||
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
|
||||
"\n"
|
||||
),
|
||||
'after'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user