From 2e2ef9e538e0ef6334336f4d7879f9879debecff Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 22 Aug 2020 00:03:01 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@48841 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-blocks.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index c1c37487ef..3e4fd40e7f 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/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' +); /*