Array and string offset access syntax with curly braces is no longer supported in script-loader.php

  Kiến thức lập trình

This is the problem:

[11-Jun-2024 13:48:46 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /home1/xxxxxx/public_html/wp-includes/script-loader.php on line 706

In script-loader.php on line 706 we have this code:

( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) ||

Full piece of code is:

    // Do "by hand" translation from PHP array to js object.
// Prevents breakage in some custom settings.
$init_obj = '';
foreach ( $tinymce_settings as $key => $value ) {
    if ( is_bool( $value ) ) {
        $val       = $value ? 'true' : 'false';
        $init_obj .= $key . ':' . $val . ',';
        continue;
    } elseif ( ! empty( $value ) && is_string( $value ) && (
        ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) ||
        ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) ||
        preg_match( '/^(?function ?(/', $value ) ) ) {
        $init_obj .= $key . ':' . $value . ',';
        continue;
    }
    $init_obj .= $key . ':"' . $value . '",';
}

$init_obj = '{' . trim( $init_obj, ' ,' ) . '}';

As I think, the solution is to update the code from php 7.4. to 8.1/2/3
But is it possible any short solution for that?

because I can’t go to the WP dashboard because of this error. Server stopped to work with php 7.4

LEAVE A COMMENT