| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
die('-1'); |
| 5 |
} |
| 6 |
|
| 7 |
if (defined('POLYLANG_BASENAME')) { |
| 8 |
|
| 9 |
class QuadMenu_Polylang { |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
add_action('init', array($this, 'locations'), -11); |
| 13 |
add_action('init', array($this, 'active'), -9); |
| 14 |
} |
| 15 |
|
| 16 |
function locations() { |
| 17 |
|
| 18 |
global $quadmenu, $quadmenu_locations, $quadmenu_active_locations; |
| 19 |
|
| 20 |
if (function_exists('pll_languages_list')) { |
| 21 |
foreach (pll_languages_list() as $lang) { |
| 22 |
|
| 23 |
foreach ($quadmenu_locations as $id => $location) { |
| 24 |
|
| 25 |
if (strpos($id, "___{$lang}") !== false) { |
| 26 |
unset($quadmenu_locations[$id]); |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
function active() { |
| 34 |
|
| 35 |
global $quadmenu, $quadmenu_locations, $quadmenu_active_locations; |
| 36 |
|
| 37 |
if (function_exists('pll_languages_list')) { |
| 38 |
|
| 39 |
foreach ($quadmenu_active_locations as $id => $theme) { |
| 40 |
|
| 41 |
foreach (pll_languages_list() as $lang) { |
| 42 |
|
| 43 |
if (strpos($id, "___{$lang}") === false) { |
| 44 |
$quadmenu_active_locations["{$id}___{$lang}"] = $quadmenu_active_locations[$id]; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
new QuadMenu_Polylang(); |
| 54 |
} |