Polylang is integrated into EU Cookie Law Compliance with the following code:
if (is_plugin_active('polylang/polylang.php') && function_exists('pll_current_language') && function_exists('pll_the_languages')) {
if (!is_admin()) {
self::$language = pll_current_language('slug');
} else {
global $polylang;
if (!(!$polylang->get_languages_list())) {
$pll_options = get_option('polylang');
self::$language = $pll_options['default_language'];
if (isset($_GET['lang']) && isset($_GET['page']) && $_GET['page'] == 'cookie-compliance-settings') {
self::$language = $_GET['lang'];
}
foreach ($polylang->get_languages_list() as $language) {
$language = get_object_vars($language);
self::$languages[$language['slug']] = $language['name'];
}
self::$languagechoice = true;
}
}
}
I have noticed that pll_current_language('slug') returns null.
What needs to be changed to make this snippet work with Polylang version 1.3.1?