Script Loader: In wp_default_packages_inline_scripts(), make sure the root URL middleware is registered before using the media middleware.

This allows for requests to retry post-processing large images using the `post-process` REST API endpoint to work as expected.

Props azaozz, mikeschroder, TimothyBlynJacobs, epiqueras, johnbillion, youknowriad.
Fixes #48542.

git-svn-id: https://develop.svn.wordpress.org/trunk@46703 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-11-11 15:08:43 +00:00
parent fdeb2ff358
commit e4edcf9845

View File

@ -649,6 +649,14 @@ function wp_default_packages_inline_scripts( &$scripts ) {
if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
$scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
}
$scripts->add_inline_script(
'wp-api-fetch',
sprintf(
'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
esc_url_raw( get_rest_url() )
),
'after'
);
$scripts->add_inline_script(
'wp-api-fetch',
implode(
@ -668,15 +676,6 @@ function wp_default_packages_inline_scripts( &$scripts ) {
),
'after'
);
$scripts->add_inline_script(
'wp-api-fetch',
sprintf(
'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
esc_url_raw( get_rest_url() )
),
'after'
);
$scripts->add_inline_script(
'wp-data',
implode(