Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is trying to activate the WPML plugin but encounters a fatal error due to an undefined function

str_contains()

. This issue typically occurs when using outdated versions of WordPress and PHP.

Solution:
1. Ensure that both WordPress and PHP are updated to the latest versions. WPML is designed to work with the most recent versions of WordPress and PHP, which can prevent such errors.
2. If you're using WordPress versions older than 5.9 and PHP versions older than 8.0, you might need to manually define the

str_contains()

function to resolve the error.
3. Before making any updates, we recommend performing a full website backup to safeguard your data.
4. If you prefer to use an older version of WPML, you can create a backup, remove the current WPML plugin, and install WPML version 4.6.7 from here.

If this solution doesn't look relevant to your situation, please open a new support ticket in the WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Mihai Apetrei 1 year, 5 months ago.

Assisted by: Mihai Apetrei.

Author Posts
December 19, 2023 at 4:08 am #15088191

muhammad-nanaS

Tell us what you are trying to do? I want to activate sitepress-multilingual-cms

What is the link to your site? hidden link

Fatal error: Uncaught Error: Call to undefined function str_contains() in /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/request-handling/wpml-request.class.php:123 Stack trace: #0 /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/request-handling/class-wpml-language-resolution.php(87): WPML_Request->show_hidden() #1 /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/language/Detection/CookieLanguage.php(43): WPML_Language_Resolution->is_language_active(NULL) #2 /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/request-handling/wpml-request.class.php(95): WPML\Language\Detection\CookieLanguage->get('wp-wpml_current...') #3 /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/language/Detection/Backend.php(45): WPML_Request->get_cookie_lang() #4 /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/vendor/wpml/collect/src/Illuminate/Support/helpers.php(26): W in /var/www/html/blog/wp-content/plugins/sitepress-multilingual-cms-backup/classes/request-handling/wpml-request.class.php on line 123

Notice: is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/blog/wp-includes/functions.php on line 5663

Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/www/html/blog/wp-includes/functions.php on line 5663

December 19, 2023 at 9:00 pm #15096679

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hi there and thank you for reporting this issue.

This issue is already known to our developers and they are currently working on a fix.

Please take a look at the existing tickets where the same error is reported to find out more:
hidden link

This happens when the WordPress and PHP versions are older.

I hope that you will find this information helpful! 🙂

Mihai Apetrei

December 20, 2023 at 12:13 am #15097017

muhammad-nanaS

So, do I have to install the other version? What version you recommended to install? or do I have to ask for refund as it not possible to install right now?

December 20, 2023 at 7:38 pm #15105717

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hi there.

If using WordPress versions older than 5.9 with PHP versions older than 8, you may need to define that function manually to avoid errors.

To get rid of this error, my recommendation would be to run a full website backup first and then make sure that your WordPress and PHP versions are up to date, using the latest version available. After that, WPML should work perfectly fine.

Please let me know how things go.

Mihai

December 21, 2023 at 3:43 am #15106463

muhammad-nanaS

did I couldn't install the older version?

December 21, 2023 at 8:52 pm #15113383

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hi there.

It is usually recommended that you are using the very latest versions of any product (plugin/theme) that you are using on your site.

This is not advice related specifically to WPML but to any plugin or theme that is used on a WordPress site - this will keep the site secure (by not using older versions).

Of course, if that's what you want, you can try to create a full website backup, remove the current WPML plugin, and then download the 4.6.7 version from here (https://wpml.org/download/wpml-multilingual-cms/?section=changelog) and install this one to see if the issue is still there.

Mihai