Skip Navigation

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.

WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 3 replies, has 0 voices.

Last updated by Bruno Kos 1 week ago.

Assisted by: Bruno Kos.

Author Posts
October 25, 2024 at 12:05 pm #16330493

desireeM

Background of the issue:
2 bugs, both have the same cause:

1) use a plugin to modifies wp-admin URL => lang from auth cookie is not used for admin-ajax requests in wp-admin causing any text from admin-ajax requests in admin to be in wrong language

OR

2) Open wp-admin => it will NOT use the language from auth cookie e.g. on "determine_locale" hook
Click any link in wp-admin => suddenly the language from the "auth cookie" is used and it's possibly different from the first request.

This happens because you check the HTTP REFERER to decide on that. See in sitepress->check_if_admin_action_from_referer()

which calls WPML_Locale->locale()
But that same method is used in lots of other places.

The first issue happens bc:
sitepress->check_if_admin_action_from_referer() calls admin_url() internally:

function check_if_admin_action_from_referer() {
$referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';

return strpos( $referer, strtolower( admin_url() ) ) === 0;
}

However this method gets called immediately when WPML is laoded, but also e.g. when any plugin calls __() initially.

The plugin we're using to modify the admin url has not been loaded at that point (since it's slug starts with a letter after "w" and plugins are loaded alphabetically), so this condition is always false bc our admin url is /staff/ and not /wp-admin/ - but at the point at which you are checking it, admin_url() hasn't been filtered yet, so you get /wp-admin/ and the condition is always false.

Symptoms:
The language from the auth cookie is not used for admin-ajax requests in wp-admin, causing text to be in the wrong language. Additionally, when opening wp-admin, it does not use the language from the auth cookie on the 'determine_locale' hook. Clicking any link in wp-admin suddenly uses the language from the auth cookie, which may differ from the first request.

Questions:
Why is the language from the auth cookie not used for admin-ajax requests?
Why does wp-admin not initially use the language from the auth cookie?

October 28, 2024 at 10:14 am #16336962

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

To ensure we pinpoint the exact source of the issue and fully understand what’s happening, would it be possible for you to record a short video demonstrating the bug in action? You can use tools like hidden link or any other screen recording tool you prefer. This would greatly assist our development team in replicating the issue in our sandbox environment and resolving it quickly.

If possible please use audio to explain as well.

We have set up a sandbox environment for you at this URL: hidden link. The debug log is active, and WPS Hide Login is installed, so the login URL can be changed as needed.

November 4, 2024 at 4:05 am #16358700

desireeM

Sorry, but I can't provide support for bugs in your code. Look at the functions in the xdebug screenshots.

Hook on e.g. 'determine_locale' hook and then you'll see you get a different language code depending on whether there is a referrer or not (= whether it's the initial page load vs a navigation)
=> if you can't reproduce/you get the same language code in both cases - why check the referrer at all then if it doesn't lead to different outcome?

November 4, 2024 at 1:48 pm #16361350

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

This has been escalated to our 2nd tier team team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.

November 18, 2024 at 7:02 am #16412973

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

This issue has been escalated to WPML developers.

I will keep this thread updated as soon as I get any new information from them!