WordPress.org

Make WordPress Core

Changeset 48841


Ignore:
Timestamp:
08/22/2020 12:03:01 AM (2 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r48700 r48841  
    126126    $meta_box_url
    127127);
    128 wp_localize_script( 'wp-editor', '_wpMetaBoxUrl', $meta_box_url );
     128wp_add_inline_script(
     129    'wp-editor',
     130    sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ),
     131    'before'
     132);
    129133
    130134
Note: See TracChangeset for help on using the changeset viewer.