From 23b4fd4a86436cc5f31125cd75b4ba1f8327c395 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 22 Aug 2020 00:04:06 +0000 Subject: [PATCH] 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 --- wp-admin/edit-form-blocks.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-admin/edit-form-blocks.php b/wp-admin/edit-form-blocks.php index c1c37487ef..3e4fd40e7f 100644 --- a/wp-admin/edit-form-blocks.php +++ b/wp-admin/edit-form-blocks.php @@ -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' +); /* diff --git a/wp-includes/version.php b/wp-includes/version.php index 554cf7c8b3..a8fdb969ef 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.