Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Get Language of one domain #20

Closed
vptcnt opened this issue Jun 6, 2018 · 1 comment
Closed

Get Language of one domain #20

vptcnt opened this issue Jun 6, 2018 · 1 comment
Assignees
Milestone

Comments

@vptcnt
Copy link

vptcnt commented Jun 6, 2018

Hello,

I am setting a website under wordpress with multiple domain for each language, for example :
https://www.domain.com - English
https://www.domain.fr - French
https://www.domain.dk - Danish

I am think about to use you plugin..
I am wondering how to get the language of the domain used by the final user :

if the user enters via https://www.domain.dk, how can I get the language - Danish in this case - to allow me to set some code for danish..

Thanks for your help

Vincent

@straube straube added this to the 0.8 milestone Jun 6, 2018
@straube straube self-assigned this Jun 6, 2018
@straube
Copy link
Owner

straube commented Jun 6, 2018

Hey! The plugin currently doesn't have a method to give that info out of the box. I'll add it to the next release.

Until then, you can get the current language with just a few lines of code, this way:

$domains = get_option('multiple-domain-domains');
$lang = null;
if (!empty($domains[MULTPLE_DOMAIN_DOMAIN]['lang'])) {
    $lang = $domains[MULTPLE_DOMAIN_DOMAIN]['lang'];
}

If your WP settings are properly configured -- and my snippet works as expected --, you should get the current language code in $lang variable.

Just keep in mind this code will only run after the plugin is loaded. If you're not sure on which action hook you should use, take a look at this: https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request. In case you use those lines in a template file, you probably won't have to worry about hooks and loading order.

Let me know if you have any questions.

@straube straube closed this as completed in a6a0a4a Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants