[Plugin: Polylang] Better way to set language from cookie?
-
Hi,
Polylang rules. But on my website, sometimes we include wp-load.php in order to access wordpress functions from outside of viewable pages. For example, checking wp user authentication from an ajax-based database pull.
I have a hacky solution on how to make polylang play nice with including wp-load. But is there a way to do it that doesn’t involve changing polylang code? Here’s what I did:
1. create a new member function for Polylang_Core:
function set_curlang_by_cookie() { $this->curlang = $this->get_preferred_language(); }
2. add 2 lines after my old include statement:
require_once(<path to wp-load.php>); $GLOBALS['polylang']->set_curlang_by_cookie(); $GLOBALS['polylang']->load_textdomains();
Thanks!!!
– Dave
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[Plugin: Polylang] Better way to set language from cookie?’ is closed to new replies.