Editor: Use wp_add_inline_script() instead of wp_localize_script() to pass the _wpMetaBoxUrl value to the wp-editor script.

This fixes a PHP 8 "Only the first byte will be assigned to the string offset" warning on Edit Post screen.

The correct usage of `wp_localize_script()` is to pass an array of data, not a string.

Fixes #51108.
Built from https://develop.svn.wordpress.org/trunk@48841


git-svn-id: http://core.svn.wordpress.org/trunk@48603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-08-22 00:04:06 +00:00
parent 5918f7e11d
commit 23b4fd4a86
2 changed files with 6 additions and 2 deletions

View File

@ -125,7 +125,11 @@ $meta_box_url = add_query_arg(
),
$meta_box_url
);
wp_localize_script( 'wp-editor', '_wpMetaBoxUrl', $meta_box_url );
wp_add_inline_script(
'wp-editor',
sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ),
'before'
);
/*

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-48840';
$wp_version = '5.6-alpha-48841';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.