• Resolved ollycross

    (@ollycross)


    This plugin is throwing a deprecation error in my site’s title element:

    Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /var/www/html/assets/plugins/wordpress-seo/frontend/class-frontend.php

    This is the code that produces the error:

    wordpress-seo/frontend/class-frontend.php:562
    
    if ( defined( 'ICL_LANGUAGE_CODE' ) && false !== strpos( $title, ICL_LANGUAGE_CODE ) ) {
        $title = str_replace( ' @' . ICL_LANGUAGE_CODE, '', $title );
    }

    If ICL_LANGUAGE_CODE is null (if for example, you have installed WPML but not yet set it up), this code throws the deprecated error.

    I suggest that a check be put in to ensure that ICL_LANGUAGE_CODE is not only defined but is also not null (or just not empty) to prevent this error. As far as I can see you don’t want it executing the block if ICL_LANGUAGE_CODE is empty anyway:

    if ( defined( 'ICL_LANGUAGE_CODE' ) && !empty(ICL_LANGUAGE_CODE) && false !== strpos( $title, ICL_LANGUAGE_CODE ) ) {

    • This topic was modified 5 years ago by ollycross.
    • This topic was modified 5 years ago by ollycross.
Viewing 1 replies (of 1 total)
  • Plugin Support amboutwe

    (@amboutwe)

    Please submit an issue report to our GitHub repository for Yoast SEO. You will need an account to create a new issue.

    Please provide as much information about the issue and don’t forget to include the URL to this conversation in the issue report!

Viewing 1 replies (of 1 total)
  • The topic ‘Deprecated code’ is closed to new replies.