| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\SiteNavigation; |
| 4 |
|
| 5 |
use Elementor\Core\Base\Module as Module_Base; |
| 6 |
use Elementor\Core\Experiments\Manager as Experiments_Manager; |
| 7 |
use Elementor\Modules\SiteNavigation\Data\Controller; |
| 8 |
use Elementor\Plugin; |
| 9 |
use Elementor\Utils; |
| 10 |
|
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; // Exit if accessed directly |
| 14 |
} |
| 15 |
|
| 16 |
class Module extends Module_Base { |
| 17 |
const PAGES_PANEL_EXPERIMENT_NAME = 'pages_panel'; |
| 18 |
|
| 19 |
/** |
| 20 |
* Initialize the Site navigation module. |
| 21 |
* @return void |
| 22 |
* @throws \Exception |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
Plugin::$instance->data_manager_v2->register_controller( new Controller() ); |
| 26 |
|
| 27 |
$is_tests = Utils::is_elementor_tests(); |
| 28 |
$is_v2_experiment_on = Plugin::$instance->experiments->is_feature_active( 'editor_v2' ); |
| 29 |
if ( ! $is_v2_experiment_on && ! $is_tests ) { |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
$this->register_pages_panel_experiment(); |
| 34 |
|
| 35 |
if ( Plugin::$instance->experiments->is_feature_active( self::PAGES_PANEL_EXPERIMENT_NAME ) ) { |
| 36 |
add_filter( 'elementor/editor/v2/scripts/env', function ( $env ) { |
| 37 |
$env['@elementor/editor-site-navigation'] = [ |
| 38 |
'is_pages_panel_active' => true, |
| 39 |
]; |
| 40 |
|
| 41 |
return $env; |
| 42 |
} ); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Retrieve the module name. |
| 48 |
* |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
public function get_name() { |
| 52 |
return 'site-navigation'; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Register Experiment |
| 57 |
* |
| 58 |
* @since 3.16.0 |
| 59 |
* |
| 60 |
* @return void |
| 61 |
* @throws \Exception |
| 62 |
*/ |
| 63 |
private function register_pages_panel_experiment() { |
| 64 |
Plugin::$instance->experiments->add_feature( [ |
| 65 |
'name' => self::PAGES_PANEL_EXPERIMENT_NAME, |
| 66 |
'title' => esc_html__( 'Pages Panel', 'elementor' ), |
| 67 |
'release_status' => Experiments_Manager::RELEASE_STATUS_ALPHA, |
| 68 |
'default' => Experiments_Manager::STATE_INACTIVE, |
| 69 |
'hidden' => true, |
| 70 |
'dependencies' => [ |
| 71 |
'editor_v2', |
| 72 |
], |
| 73 |
] ); |
| 74 |
} |
| 75 |
} |
| 76 |
|