| @@ -16,11 +16,9 @@ | ||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | class Module extends Module_Base { |
| 19 | 19 | const PAGES_PANEL_EXPERIMENT_NAME = 'pages_panel'; |
| 20 | - const PACKAGES = [ | |
| 21 | - 'editor-site-navigation', | |
| 22 | - ]; | |
| 20 | + | |
| 23 | 21 | /** |
| 24 | 22 | * Initialize the Site navigation module. |
| 25 | 23 | * |
| 26 | 24 | * @return void |
| @@ -28,23 +26,24 @@ | ||
| 28 | 26 | */ |
| 29 | 27 | public function __construct() { |
| 30 | 28 | Plugin::$instance->data_manager_v2->register_controller( new Controller() ); |
| 31 | 29 | |
| 30 | + $is_tests = Utils::is_elementor_tests(); | |
| 31 | + $is_v2_experiment_on = Plugin::$instance->experiments->is_feature_active( 'editor_v2' ); | |
| 32 | + if ( ! $is_v2_experiment_on && ! $is_tests ) { | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + | |
| 32 | 36 | $this->register_pages_panel_experiment(); |
| 33 | 37 | |
| 34 | - add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) ); | |
| 38 | + if ( Plugin::$instance->experiments->is_feature_active( self::PAGES_PANEL_EXPERIMENT_NAME ) ) { | |
| 39 | + add_filter( 'elementor/editor/v2/scripts/env', function( $env ) { | |
| 40 | + $env['@elementor/editor-site-navigation'] = [ | |
| 41 | + 'is_pages_panel_active' => true, | |
| 42 | + ]; | |
| 35 | 43 | |
| 36 | - add_filter( 'elementor/editor/v2/scripts/env', function( $env ) { | |
| 37 | - $env['@elementor/editor-site-navigation'] = [ | |
| 38 | - 'is_pages_panel_active' => Plugin::$instance->experiments->is_feature_active( | |
| 39 | - self::PAGES_PANEL_EXPERIMENT_NAME | |
| 40 | - ), | |
| 41 | - ]; | |
| 42 | - | |
| 43 | - return $env; | |
| 44 | - } ); | |
| 45 | - | |
| 46 | - if ( Plugin::$instance->experiments->is_feature_active( self::PAGES_PANEL_EXPERIMENT_NAME ) ) { | |
| 44 | + return $env; | |
| 45 | + } ); | |
| 47 | 46 | $this->register_rest_fields(); |
| 48 | 47 | } |
| 49 | 48 | } |
| 50 | 49 | |
| @@ -70,8 +69,11 @@ | ||
| 70 | 69 | 'title' => esc_html__( 'Pages Panel', 'elementor' ), |
| 71 | 70 | 'release_status' => Experiments_Manager::RELEASE_STATUS_ALPHA, |
| 72 | 71 | 'default' => Experiments_Manager::STATE_INACTIVE, |
| 73 | 72 | 'hidden' => true, |
| 73 | + 'dependencies' => [ | |
| 74 | + 'editor_v2', | |
| 75 | + ], | |
| 74 | 76 | ] ); |
| 75 | 77 | } |
| 76 | 78 | |
| 77 | 79 | private function register_rest_fields() { |
| @@ -77,10 +79,6 @@ | ||
| 77 | 79 | private function register_rest_fields() { |
| 78 | 80 | add_action( 'rest_api_init', function() { |
| 79 | 81 | ( new Page_User_Can() )->register_rest_field(); |
| 80 | 82 | } ); |
| 81 | - } | |
| 82 | - | |
| 83 | - private function add_packages( $packages ) { | |
| 84 | - return array_merge( $packages, self::PACKAGES ); | |
| 85 | 83 | } |
| 86 | 84 | } |