无法将空字符串分配给 Wordpress 中的字符串偏移量警告

Cannot assign an empty string to a string offset Warning in Wordpress

当我加载页面时,它显示以下警告:

Warning: Cannot assign an empty string to a string offset in C:xampp\htdocs\wordpress\smart-m\wp-includes\class.wp-scripts.php on line 447

我认为这不是逻辑问题。可能是由于 wordpress 造成的? 这是 wp-scripts.php 文件第 447

行的函数
public function localize( $handle, $object_name, $l10n ) {
        if ( $handle === 'jquery' )
            $handle = 'jquery-core';

        if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
            $after = $l10n['l10n_print_after'];
            unset($l10n['l10n_print_after']);
        }

        foreach ( (array) $l10n as $key => $value ) {
            if ( !is_scalar($value) )
                continue;

            $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
        }

        $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';

        if ( !empty($after) )
            $script .= "\n$after;";

        $data = $this->get_data( $handle, 'data' );

        if ( !empty( $data ) )
            $script = "$data\n$script";

        return $this->add_data( $handle, 'data', $script );
    }

这是 WP4.6.* 和 PHP7.1.

上出现的问题

请提供您的 PHP 和 WP 版本。但是,如果您是 运行 WP4.6 和 PHP7.1,请更新到 WP4.7 以解决此警告。

您可以删除此代码:

$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');

在你这样做之前,请复制你的原始文件