Wordpress: «Предупреждение: недопустимое смещение строки» в нескольких местах - PullRequest
1 голос
/ 03 марта 2020

Надеюсь, вы, ребята, можете помочь мне здесь. Что происходит с этими проблемами в моей установке WordPress, смотрите блок ошибок и ссылки на код.

Ошибки:

Warning: Illegal string offset 'domain' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 583

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 587

Warning: Illegal string offset 'singular' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'plural' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'domain' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 583

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 587

Warning: Illegal string offset 'singular' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'plural' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Код:

function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
    if ( $nooped_plural['domain'] ) {
        $domain = $nooped_plural['domain'];
    }

    if ( $nooped_plural['context'] ) {
        return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
    } else {
        return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
    }
}

1 Ответ

1 голос
/ 03 марта 2020

Warning: Illegal string offset 'something' сообщение означает, что вы пытаетесь получить доступ к значению $someVar['something'], но оно не существует.

Чтобы избежать этого, вы всегда должны использовать isset($someVar['something']), чтобы проверить, если индекс существует (или нет) в данной переменной.

...