| @@ -1,112 +1,30 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\EditorOne; |
| 4 | 4 | |
| 5 | -use Elementor\Core\Admin\EditorOneMenu\Elementor_One_Menu_Manager; | |
| 6 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 7 | -use Elementor\Modules\EditorOne\Classes\Editor_One_Pointer; | |
| 8 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 9 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 10 | -use Elementor\Modules\EditorOne\Components\Sidebar_Navigation_Handler; | |
| 11 | -use Elementor\Modules\EditorOne\Components\Top_Bar_Handler; | |
| 6 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 12 | 7 | |
| 13 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 9 | exit; |
| 15 | 10 | } |
| 11 | + | |
| 16 | 12 | class Module extends BaseModule { |
| 17 | 13 | |
| 18 | - const CUSTOM_REACT_APP_PAGES = [ | |
| 19 | - 'elementor-element-manager', | |
| 20 | - ]; | |
| 14 | + const EXPERIMENT_NAME = 'e_editor_one'; | |
| 21 | 15 | |
| 22 | - public function get_name(): string { | |
| 16 | + public function get_name() { | |
| 23 | 17 | return 'editor-one'; |
| 24 | 18 | } |
| 25 | 19 | |
| 26 | - public function __construct() { | |
| 27 | - parent::__construct(); | |
| 28 | - | |
| 29 | - if ( is_admin() ) { | |
| 30 | - $this->add_component( 'editor-one-menu-manager', new Elementor_One_Menu_Manager() ); | |
| 31 | - $this->add_component( 'sidebar-navigation-handler', new Sidebar_Navigation_Handler() ); | |
| 32 | - $this->add_component( 'top-bar-handler', new Top_Bar_Handler() ); | |
| 33 | - $this->add_component( 'editor-one-pointer', new Editor_One_Pointer() ); | |
| 34 | - } | |
| 35 | - | |
| 36 | - add_action( 'current_screen', function () { | |
| 37 | - $menu_data_provider = Menu_Data_Provider::instance(); | |
| 38 | - | |
| 39 | - if ( ! $menu_data_provider->is_editor_one_admin_page() ) { | |
| 40 | - return; | |
| 41 | - } | |
| 42 | - | |
| 43 | - add_action( 'admin_enqueue_scripts', function () { | |
| 44 | - $this->enqueue_styles(); | |
| 45 | - } ); | |
| 46 | - } ); | |
| 47 | - | |
| 48 | - add_filter( 'elementor/admin-top-bar/is-active', function ( $_is_active ) { | |
| 49 | - return false; | |
| 50 | - } ); | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Check if current page has a custom React app that uses @elementor/ui | |
| 55 | - * | |
| 56 | - * @return bool | |
| 57 | - */ | |
| 58 | - private function is_custom_react_app_page() { | |
| 59 | - $current_screen = get_current_screen(); | |
| 60 | - | |
| 61 | - if ( ! $current_screen ) { | |
| 62 | - return false; | |
| 63 | - } | |
| 64 | - | |
| 65 | - foreach ( self::CUSTOM_REACT_APP_PAGES as $page_slug ) { | |
| 66 | - if ( str_contains( $current_screen->id ?? '', $page_slug ) ) { | |
| 67 | - return true; | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - return false; | |
| 72 | - } | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * Enqueue admin styles | |
| 76 | - */ | |
| 77 | - private function enqueue_styles() { | |
| 78 | - | |
| 79 | - wp_enqueue_style( 'elementor-admin' ); | |
| 80 | - | |
| 81 | - wp_enqueue_style( | |
| 82 | - 'elementor-editor-one-common', | |
| 83 | - $this->get_css_assets_url( 'editor-one-common' ), | |
| 84 | - [ 'elementor-admin' ], | |
| 85 | - ELEMENTOR_VERSION | |
| 86 | - ); | |
| 87 | - | |
| 88 | - if ( ! $this->is_custom_react_app_page() ) { | |
| 89 | - wp_enqueue_style( | |
| 90 | - 'elementor-editor-one-elements', | |
| 91 | - $this->get_css_assets_url( 'editor-one-elements' ), | |
| 92 | - [ 'elementor-editor-one-common' ], | |
| 93 | - ELEMENTOR_VERSION | |
| 94 | - ); | |
| 95 | - | |
| 96 | - wp_enqueue_style( | |
| 97 | - 'elementor-editor-one-tables', | |
| 98 | - $this->get_css_assets_url( 'editor-one-tables' ), | |
| 99 | - [ 'elementor-editor-one-common' ], | |
| 100 | - ELEMENTOR_VERSION | |
| 101 | - ); | |
| 102 | - } | |
| 103 | - | |
| 104 | - wp_enqueue_script( | |
| 105 | - 'editor-one-admin', | |
| 106 | - $this->get_js_assets_url( 'editor-one-admin' ), | |
| 107 | - [ 'jquery' ], | |
| 108 | - ELEMENTOR_VERSION, | |
| 109 | - true | |
| 110 | - ); | |
| 20 | + public static function get_experimental_data() { | |
| 21 | + return [ | |
| 22 | + 'name' => static::EXPERIMENT_NAME, | |
| 23 | + 'title' => esc_html__( 'Editor one', 'elementor' ), | |
| 24 | + 'description' => esc_html__( 'General', 'elementor' ), | |
| 25 | + 'hidden' => true, | |
| 26 | + 'default' => Experiments_Manager::STATE_INACTIVE, | |
| 27 | + 'release_status' => Experiments_Manager::RELEASE_STATUS_DEV, | |
| 28 | + ]; | |
| 111 | 29 | } |
| 112 | 30 | } |