Can't get current locale (trying to implement Polylang)
-
Hello,
I am trying to modificate plugin to be at least a bit compatible with Polylang plugin.
I am getting a strange behaviour when trying to get current locale when using filters in functions.php, or even if hardcoding it in plugin code. If I come and browse my site, the correct locale is not retrieved. If I change language, when the locale is set. If I change back to initial language, locale is also set well.
Here are my functions:
functions.php: function kcsite_alo_easymail_get_language(){ return pll_current_language('slug'); //doesn't always work //return substr(get_locale(), 0, 2); //doesn't always work //return 'lt'; //works } add_filter ( 'alo_easymail_multilang_get_language', 'kcsite_alo_easymail_get_language' ); function custom_easymail_new_subscriber_is_added($subscriber, $user_id=false){ $lang = pll_current_language('slug'); $lang = (string)$lang; global $wpdb; $wpdb->update($wpdb->prefix.'easymail_subscribers', array('lang' => $lang), array('ID' => $subscriber->ID)); } add_action('alo_easymail_new_subscriber_added', 'custom_easymail_new_subscriber_is_added', 10, 2 );
Am I doing it in the proper way, or did I miss something?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Can't get current locale (trying to implement Polylang)’ is closed to new replies.