| 1 |
<?php |
| 2 |
|
| 3 |
namespace QuadLayers\QuadMenu\Integrations; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
die( '-1' ); |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Polylang ex QuadMenu_Polylang Class |
| 11 |
*/ |
| 12 |
class Polylang { |
| 13 |
|
| 14 |
private static $instance; |
| 15 |
|
| 16 |
public function __construct() { |
| 17 |
if ( ! defined( 'POLYLANG_BASENAME' ) ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
add_action( 'init', array( $this, 'locations' ), -11 ); |
| 21 |
add_action( 'init', array( $this, 'active' ), -9 ); |
| 22 |
} |
| 23 |
|
| 24 |
function locations() { |
| 25 |
|
| 26 |
global $quadmenu, $quadmenu_locations, $quadmenu_active_locations; |
| 27 |
|
| 28 |
if ( function_exists( 'pll_languages_list' ) ) { |
| 29 |
foreach ( pll_languages_list() as $lang ) { |
| 30 |
|
| 31 |
foreach ( $quadmenu_locations as $id => $location ) { |
| 32 |
|
| 33 |
if ( strpos( $id, "___{$lang}" ) !== false ) { |
| 34 |
unset( $quadmenu_locations[ $id ] ); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
function active() { |
| 42 |
|
| 43 |
global $quadmenu, $quadmenu_locations, $quadmenu_active_locations; |
| 44 |
|
| 45 |
if ( function_exists( 'pll_languages_list' ) ) { |
| 46 |
|
| 47 |
foreach ( $quadmenu_active_locations as $id => $theme ) { |
| 48 |
|
| 49 |
foreach ( pll_languages_list() as $lang ) { |
| 50 |
|
| 51 |
if ( strpos( $id, "___{$lang}" ) === false ) { |
| 52 |
$quadmenu_active_locations[ "{$id}___{$lang}" ] = $quadmenu_active_locations[ $id ]; |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
public static function instance() { |
| 60 |
if ( ! isset( self::$instance ) ) { |
| 61 |
self::$instance = new self(); |
| 62 |
} |
| 63 |
return self::$instance; |
| 64 |
} |
| 65 |
} |
| 66 |
|