| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\EditorAppBar; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 6 | +use Elementor\Plugin; | |
| 5 | 7 | |
| 6 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 9 | exit; // Exit if accessed directly. |
| 8 | 10 | } |
| @@ -7,10 +9,15 @@ | ||
| 7 | 9 | exit; // Exit if accessed directly. |
| 8 | 10 | } |
| 9 | 11 | |
| 10 | 12 | class Module extends BaseModule { |
| 13 | + const EXPERIMENT_NAME = 'editor_v2'; // Kept as `editor_v2` for backward compatibility. | |
| 14 | + | |
| 11 | 15 | const PACKAGES = [ |
| 12 | 16 | 'editor-app-bar', |
| 17 | + 'editor-documents', | |
| 18 | + 'editor-panels', | |
| 19 | + 'editor-site-navigation', | |
| 13 | 20 | ]; |
| 14 | 21 | |
| 15 | 22 | const STYLES = [ |
| 16 | 23 | 'editor-v2-app-bar-overrides', |
| @@ -22,14 +29,30 @@ | ||
| 22 | 29 | |
| 23 | 30 | public function __construct() { |
| 24 | 31 | parent::__construct(); |
| 25 | 32 | |
| 26 | - add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) ); | |
| 27 | - add_filter( 'elementor/editor/v2/styles', fn( $styles ) => $this->add_styles( $styles ) ); | |
| 28 | - add_filter( 'elementor/editor/templates', fn( $templates ) => $this->remove_templates( $templates ) ); | |
| 33 | + if ( Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) { | |
| 34 | + add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) ); | |
| 35 | + add_filter( 'elementor/editor/v2/styles', fn( $styles ) => $this->add_styles( $styles ) ); | |
| 36 | + add_filter( 'elementor/editor/templates', fn( $templates ) => $this->remove_templates( $templates ) ); | |
| 29 | 37 | |
| 30 | - add_action( 'elementor/editor/v2/scripts/enqueue', fn() => $this->dequeue_scripts() ); | |
| 31 | - add_action( 'elementor/editor/v2/styles/enqueue', fn() => $this->dequeue_styles() ); | |
| 38 | + add_action( 'elementor/editor/v2/scripts/enqueue', fn() => $this->dequeue_scripts() ); | |
| 39 | + add_action( 'elementor/editor/v2/styles/enqueue', fn() => $this->dequeue_styles() ); | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + public static function get_experimental_data(): array { | |
| 44 | + return [ | |
| 45 | + 'name' => self::EXPERIMENT_NAME, | |
| 46 | + 'title' => esc_html__( 'Editor Top Bar', 'elementor' ), | |
| 47 | + 'description' => sprintf( | |
| 48 | + '%1$s <a href="https://go.elementor.com/wp-dash-elementor-top-bar/" target="_blank">%2$s</a>', | |
| 49 | + esc_html__( 'Get a sneak peek of the new Editor powered by React. The beautiful design and experimental layout of the Top bar are just some of the exciting tools on their way.', 'elementor' ), | |
| 50 | + esc_html__( 'Learn more', 'elementor' ) | |
| 51 | + ), | |
| 52 | + 'default' => Experiments_Manager::STATE_ACTIVE, | |
| 53 | + 'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE, | |
| 54 | + ]; | |
| 32 | 55 | } |
| 33 | 56 | |
| 34 | 57 | private function add_packages( $packages ) { |
| 35 | 58 | return array_merge( $packages, self::PACKAGES ); |