| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\Home; |
| 3 | 3 | |
| 4 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 4 | 5 | use Elementor\Core\Base\App as BaseApp; |
| 6 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 5 | 7 | use Elementor\Includes\EditorAssetsAPI; |
| 6 | 8 | use Elementor\Settings; |
| 7 | 9 | use Elementor\Plugin; |
| 8 | 10 | use Elementor\Utils; |
| @@ -21,8 +23,17 @@ | ||
| 21 | 23 | |
| 22 | 24 | public function __construct() { |
| 23 | 25 | parent::__construct(); |
| 24 | 26 | |
| 27 | + if ( ! $this->is_experiment_active() ) { | |
| 28 | + return; | |
| 29 | + } | |
| 30 | + | |
| 31 | + add_action( 'elementor/admin/menu/after_register', function ( Admin_Menu_Manager $admin_menu, array $hooks ) { | |
| 32 | + $hook_suffix = 'toplevel_page_elementor'; | |
| 33 | + add_action( "admin_print_scripts-{$hook_suffix}", [ $this, 'enqueue_home_screen_scripts' ] ); | |
| 34 | + }, 10, 2 ); | |
| 35 | + | |
| 25 | 36 | add_filter( 'elementor/document/urls/edit', [ $this, 'add_active_document_to_edit_link' ] ); |
| 26 | 37 | } |
| 27 | 38 | |
| 28 | 39 | public function enqueue_home_screen_scripts(): void { |
| @@ -51,15 +62,12 @@ | ||
| 51 | 62 | 'e-home-screen', |
| 52 | 63 | 'elementorHomeScreenData', |
| 53 | 64 | $this->get_app_js_config() |
| 54 | 65 | ); |
| 66 | + } | |
| 55 | 67 | |
| 56 | - wp_enqueue_style( | |
| 57 | - 'e-home-screen', | |
| 58 | - $this->get_css_assets_url( 'modules/home/e-home-screen' ), | |
| 59 | - [], | |
| 60 | - ELEMENTOR_VERSION | |
| 61 | - ); | |
| 68 | + public function is_experiment_active(): bool { | |
| 69 | + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID ); | |
| 62 | 70 | } |
| 63 | 71 | |
| 64 | 72 | public function add_active_document_to_edit_link( $edit_link ) { |
| 65 | 73 | $active_document = Utils::get_super_global_value( $_GET, 'active-document' ) ?? null; |
| @@ -75,15 +83,24 @@ | ||
| 75 | 83 | |
| 76 | 84 | return $edit_link; |
| 77 | 85 | } |
| 78 | 86 | |
| 87 | + public static function get_experimental_data(): array { | |
| 88 | + return [ | |
| 89 | + 'name' => static::PAGE_ID, | |
| 90 | + 'title' => esc_html__( 'Elementor Home Screen', 'elementor' ), | |
| 91 | + 'description' => esc_html__( 'Default Elementor menu page.', 'elementor' ), | |
| 92 | + 'hidden' => true, | |
| 93 | + 'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE, | |
| 94 | + 'default' => Experiments_Manager::STATE_ACTIVE, | |
| 95 | + ]; | |
| 96 | + } | |
| 97 | + | |
| 79 | 98 | private function get_app_js_config(): array { |
| 80 | 99 | $editor_assets_api = new EditorAssetsAPI( $this->get_api_config() ); |
| 81 | 100 | $api = new API( $editor_assets_api ); |
| 82 | 101 | |
| 83 | - $config = $api->get_home_screen_items(); | |
| 84 | - | |
| 85 | - return $config; | |
| 102 | + return $api->get_home_screen_items(); | |
| 86 | 103 | } |
| 87 | 104 | |
| 88 | 105 | private function get_api_config(): array { |
| 89 | 106 | return [ |
| @@ -93,7 +110,9 @@ | ||
| 93 | 110 | ]; |
| 94 | 111 | } |
| 95 | 112 | |
| 96 | 113 | public static function get_elementor_settings_page_id(): string { |
| 97 | - return 'elementor-settings'; | |
| 114 | + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID ) | |
| 115 | + ? 'elementor-settings' | |
| 116 | + : Settings::PAGE_ID; | |
| 98 | 117 | } |
| 99 | 118 | } |