Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

leods92 on "[Plugin: Polylang] Enhance feature "When front page is visited, set language according to browser""

$
0
0

@Chouby
I'm not completely sure if this is a new bug but using the lastest stable version of your plugin I have one problem: users are not arriving at the right homepage.
Going through the latest SVN development changes, I noticed you have made some changes related to this but even trying the latest development versions the problem persists.

Just to assure we are on the same page here, I'd like to summarize how this feature should work:
- User accesses homepage without pll cookie (new visitor or visitor who has disabled cookies) -> Polylang gets the preferred language from request HTTP header "Accept-Language", sets the proper cookie, and if the language is different from the homepage's, redirects the user.
- User with pll cookie accesses the homepage -> Polylang gets the preferred language from cookies, and if the language is different from the homepage's, redirects the user.
- User deliberately change the language, by clicking on a link inside the website -> Polylang reassigns the cookie value and DOES NOT redirect the user as he/she really wants to be at a different homepage.

Since the function get_preferred_language() takes care of getting the preferred language from the cookie (if available), the code you've just proposed and the one that's currently being used should not evaluate whether (isset($_COOKIE['wordpress_polylang']) || isset($_COOKIE[PLL_COOKIE]) is true. Doing so, will skip get_preferred_language and if the user tries to access the homepage WITH a cookie different from the homepage language, he/she won't be redirected and the cookie will be reassigned to the homepage's language code.

I'm not sure if I was clear; if I wasn't please let me know so I explain it better.
I've removed the unnecessary evaluation from core.php in my blog and the redirections are now working as expected.

Hope yo hear your insights about this issue.


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>