PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.3
Elementor Website Builder – more than just a page builder v3.22.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/home/module.php +31 -34 4.2.13.22.3 View file →
@@ -1,9 +1,12 @@
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;
5 -use Elementor\Includes\EditorAssetsAPI;
6 +use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 +use Elementor\Settings;
8 +use Elementor\Plugin;
6 9 use Elementor\Utils;
7 10
8 11 if ( ! defined( 'ABSPATH' ) ) {
9 12 exit; // Exit if accessed directly.
@@ -19,27 +22,27 @@
19 22
20 23 public function __construct() {
21 24 parent::__construct();
22 25
26 + $this->register_layout_experiment();
27 +
28 + if ( ! $this->is_experiment_active() ) {
29 + return;
30 + }
31 +
32 + add_action( 'elementor/admin/menu/after_register', function ( Admin_Menu_Manager $admin_menu, array $hooks ) {
33 + $hook_suffix = 'toplevel_page_elementor';
34 + add_action( "admin_print_scripts-{$hook_suffix}", [ $this, 'enqueue_home_screen_scripts' ] );
35 + }, 10, 2 );
36 +
23 37 add_filter( 'elementor/document/urls/edit', [ $this, 'add_active_document_to_edit_link' ] );
24 38 }
25 39
26 - public function enqueue_fonts(): void {
27 - wp_enqueue_style(
28 - 'elementor-home-screen-fonts',
29 - 'https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap',
30 - [],
31 - ELEMENTOR_VERSION
32 - );
33 - }
34 -
35 40 public function enqueue_home_screen_scripts(): void {
36 41 if ( ! current_user_can( 'manage_options' ) ) {
37 42 return;
38 43 }
39 44
40 - $this->enqueue_fonts();
41 -
42 45 $min_suffix = Utils::is_script_debug() ? '' : '.min';
43 46
44 47 wp_enqueue_script(
45 48 'e-home-screen',
@@ -60,15 +63,12 @@
60 63 'e-home-screen',
61 64 'elementorHomeScreenData',
62 65 $this->get_app_js_config()
63 66 );
67 + }
64 68
65 - wp_enqueue_style(
66 - 'e-home-screen',
67 - $this->get_css_assets_url( 'modules/home/e-home-screen' ),
68 - [],
69 - ELEMENTOR_VERSION
70 - );
69 + public function is_experiment_active(): bool {
70 + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID );
71 71 }
72 72
73 73 public function add_active_document_to_edit_link( $edit_link ) {
74 74 $active_document = Utils::get_super_global_value( $_GET, 'active-document' ) ?? null;
@@ -84,27 +84,24 @@
84 84
85 85 return $edit_link;
86 86 }
87 87
88 - private function get_app_js_config(): array {
89 - $editor_assets_api = new EditorAssetsAPI( $this->get_api_config() );
90 - $api = new API( $editor_assets_api );
91 -
92 - $config = $api->get_home_screen_items();
93 -
94 - $config['wpRestNonce'] = wp_create_nonce( 'wp_rest' );
95 -
96 - return $config;
88 + private function register_layout_experiment(): void {
89 + Plugin::$instance->experiments->add_feature( [
90 + 'name' => static::PAGE_ID,
91 + 'title' => esc_html__( 'Elementor Home Screen', 'elementor' ),
92 + 'description' => esc_html__( 'Default Elementor menu page.', 'elementor' ),
93 + 'hidden' => true,
94 + 'default' => Experiments_Manager::STATE_ACTIVE,
95 + ] );
97 96 }
98 97
99 - private function get_api_config(): array {
100 - return [
101 - EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/home-screen/v1/home-screen.json',
102 - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_home_screen_data',
103 - EditorAssetsAPI::ASSETS_DATA_KEY => 'home-screen',
104 - ];
98 + private function get_app_js_config(): array {
99 + return API::get_home_screen_items();
105 100 }
106 101
107 102 public static function get_elementor_settings_page_id(): string {
108 - return 'elementor-settings';
103 + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID )
104 + ? 'elementor-settings'
105 + : Settings::PAGE_ID;
109 106 }
110 107 }