# quadmenu/trunk/lib/integrations/class-polylang.php

QuadMenu – Mega Menu, version trunk. 66 lines.

- Page: https://pluginprobe.com/plugins/quadmenu/trunk/code/lib/integrations/class-polylang.php
- Raw: https://pluginprobe.com/plugins/quadmenu/trunk/raw/lib/integrations/class-polylang.php
- Modified: 2024-10-03T08:33:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/quadmenu/trunk/code/lib/integrations/class-polylang.php#L10-L20`.

```php
<?php

namespace QuadLayers\QuadMenu\Integrations;

if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

/**
 * Polylang ex QuadMenu_Polylang Class
 */
class Polylang {

	private static $instance;

	public function __construct() {
		if ( ! defined( 'POLYLANG_BASENAME' ) ) {
			return;
		}
		add_action( 'init', array( $this, 'locations' ), -11 );
		add_action( 'init', array( $this, 'active' ), -9 );
	}

	function locations() {

		global $quadmenu, $quadmenu_locations, $quadmenu_active_locations;

		if ( function_exists( 'pll_languages_list' ) ) {
			foreach ( pll_languages_list() as $lang ) {

				foreach ( $quadmenu_locations as $id => $location ) {

					if ( strpos( $id, "___{$lang}" ) !== false ) {
						unset( $quadmenu_locations[ $id ] );
					}
				}
			}
		}
	}

	function active() {

		global $quadmenu, $quadmenu_locations, $quadmenu_active_locations;

		if ( function_exists( 'pll_languages_list' ) ) {

			foreach ( $quadmenu_active_locations as $id => $theme ) {

				foreach ( pll_languages_list() as $lang ) {

					if ( strpos( $id, "___{$lang}" ) === false ) {
						$quadmenu_active_locations[ "{$id}___{$lang}" ] = $quadmenu_active_locations[ $id ];
					}
				}
			}
		}
	}

	public static function instance() {
		if ( ! isset( self::$instance ) ) {
			self::$instance = new self();
		}
		return self::$instance;
	}
}

```
