How to resolve Uninitialized string offset: 0 in error?

Asked

Viewed 332 times

0

using a wordpress plugin Yoast ends up giving this error in some posts, a post that is giving error is the:

https://www.escolaedti.com.br/indicadores-inadimplencia/amp/

in it we can see the message:

"Notice: Uninitialized string offset: 0 in /home/escolaedti/public_html/wp-content/plugins/wordpress-seo/frontend/class-twitter.php on line 495"

I copied the snippet that says where the bug is.

protected function image_output( $img, $tag = false ) {
        if ( $tag ) {
            _deprecated_argument( __METHOD__, 'WPSEO 2.4' );
        }
        /**
         * Filter: 'wpseo_twitter_image' - Allow changing the Twitter Card image
         *
         * @api string $img Image URL string
         */
        $img = apply_filters( 'wpseo_twitter_image', $img );
        if ( WPSEO_Utils::is_url_relative( $img ) === true && $img[0] === '/' ) {
            $parsed_url = wp_parse_url( home_url() );
            $img        = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $img;
        }
        $escaped_img = esc_url( $img );
        if ( in_array( $escaped_img, $this->shown_images, true ) ) {
            return false;
        }
        if ( is_string( $escaped_img ) && $escaped_img !== '' ) {
            $this->output_metatag( 'image', $escaped_img, true );
            array_push( $this->shown_images, $escaped_img );
            return true;
        }
        return false;
    }

line 495:

if ( WPSEO_Utils::is_url_relative( $img ) === true && $img[0] === '/' ) {

I noticed this error after we started switching from http to https.

  • how can I fix this mistake?

  • You can edit your question if you forget something, you don’t need to post it as a comment.

  • thanks for the comment but do not understand how it could help me to solve my problem, you would know answer the question?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.