This topic contains 0 replies, has 2 voices, and was last updated by Anonymous 13 years, 7 months ago.
You must be logged in to reply to this topic.
dev.xiligroup is being renovated › Forums › xili-language plugin › Setting language without $_GET
Tagged: $_get, hook, permalinks
This topic contains 0 replies, has 2 voices, and was last updated by Anonymous 13 years, 7 months ago.
After I wrote this, I tried writing this code in the beginning of your plugin:
if(isset($_GET)){
setcookie(‘lang’, $_GET);
}
elseif(isset($_COOKIE)){
$_GET = $_COOKIE;
}
Now it’s working I think you must definitely use that in next versions if you didn’t.
Your approach can be interesting according circumstances of uses. Do you know that xili-language is hookable, so you can change the behaviour how the language of theme is selected. Take a little time to read the source code and discover the « filter » entries. $_GET is a way to find explicitly the lang from URI but the_curlang
function give you the language just after the famous loop of wp (specially when page or home or frontpage…).
Ahm, it requires a bit time. Instead of reading the source code, I rather writing it from the beginning :p
By the way, I added the code (above) inside set_when_plugin_loaded() function and expanded it:
if(!is_admin()){
$myLangs = $this->xili_settings;
if(isset($_GET))
{
$check = false;
foreach($myLangs as $l){
if($l->slug == $_GET){
setcookie(‘lang’, $_GET);
$check = true;
break;
}
}
if($check == false){
foreach($myLangs as $l){
if($l->name == WPLANG){
$_GET = $l->slug;
setcookie(‘lang’, $l->slug);
break;
}
}
}
}
elseif(isset($_COOKIE)){
$_GET = $_COOKIE;
}}
This checks if the get value of lang is available on language lists or not. If it’s not available, it sets the default language. Hope this helps people sharing my opinion.
Have a good day.
You must be logged in to reply to this topic.
Ce site utilise des cookies afin que nous puissions vous fournir la meilleure expérience utilisateur possible. Les informations sur les cookies sont stockées dans votre navigateur et remplissent des fonctions telles que vous reconnaître lorsque vous revenez sur notre site Web et aider notre équipe à comprendre les sections du site que vous trouvez les plus intéressantes et utiles.
Cette option doit être activée à tout moment afin que nous puissions enregistrer vos préférences pour les réglages de cookie.
Si vous désactivez ce cookie, nous ne pourrons pas enregistrer vos préférences. Cela signifie que chaque fois que vous visitez ce site, vous devrez activer ou désactiver à nouveau les cookies.