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.

This topic contains 3 replies, has 2 voices.

Last updated by Sumit 1 year, 7 months ago.

Assigned support staff: Sumit.

Author Posts
November 30, 2018 at 5:45 pm #2957088

Martino

Hi,
I just upgraded to 4.1.1 and I'm getting two errors.

First, upon upgrading it throws me an error about a code I'm using in functions.php to have a conditional statement to do something only on a specific language


if (ICL_LANGUAGE_CODE == "en") {
 //do something
};

Then I saw for just a moment another error about a duplicate entry on a table about a language, but upon refreshing I can't find it anymore, so I assume it's no big deal.

Is there a better way to do a conditional statement in functions.php?

December 3, 2018 at 2:19 pm #2962675

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for contacting support forum.

Could you please let me know what is the error message regarding ICL_LANGUAGE_CODE? (a screenshot would be better)
Because I just tested with the same example as you mentioned and I can not see any error.

Thanks

December 3, 2018 at 2:36 pm #2962739

Martino

Hi,
I'm not able to replicate the error.
If you think this has been just a hiccup and the code is compliant I'm more than happy about it.
I'll monitor things on my end, I'm just wondering if that code is the right way to proceed on a functions.php file.

Thanks again,
m.

December 4, 2018 at 5:49 am #2965039

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

The code is good and still working. It is possible that upgrade wasn't completed and something requested the page. Most of the time during the upgrade process website in maintenance mode but it is possible sometimes it is not.

Still, I will suggest you please check if constant is really defined before using it. If you deactivate WPML (temporary) then this code will throw a warning. So please use in this way

if (defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE == "en") {
 //do something
};

Thanks