Deprecated code
-
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
isnull
(if for example, you have installed WPML but not yet set it up), this code throws thedeprecated
error.I suggest that a check be put in to ensure that
ICL_LANGUAGE_CODE
is not only defined but is also notnull
(or just not empty) to prevent this error. As far as I can see you don’t want it executing the block ifICL_LANGUAGE_CODE
is empty anyway:if ( defined( 'ICL_LANGUAGE_CODE' ) && !empty(ICL_LANGUAGE_CODE) && false !== strpos( $title, ICL_LANGUAGE_CODE ) ) {
- The topic ‘Deprecated code’ is closed to new replies.