PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev4
Elementor Website Builder – more than just a page builder v3.26.0-dev4
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 +32 -23 4.2.33.26.0-dev4 View file →
@@ -1,9 +1,13 @@
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;
8 +use Elementor\Settings;
9 +use Elementor\Plugin;
6 10 use Elementor\Utils;
7 11
8 12 if ( ! defined( 'ABSPATH' ) ) {
9 13 exit; // Exit if accessed directly.
@@ -19,27 +23,27 @@
19 23
20 24 public function __construct() {
21 25 parent::__construct();
22 26
27 + $this->register_layout_experiment();
28 +
29 + if ( ! $this->is_experiment_active() ) {
30 + return;
31 + }
32 +
33 + add_action( 'elementor/admin/menu/after_register', function ( Admin_Menu_Manager $admin_menu, array $hooks ) {
34 + $hook_suffix = 'toplevel_page_elementor';
35 + add_action( "admin_print_scripts-{$hook_suffix}", [ $this, 'enqueue_home_screen_scripts' ] );
36 + }, 10, 2 );
37 +
23 38 add_filter( 'elementor/document/urls/edit', [ $this, 'add_active_document_to_edit_link' ] );
24 39 }
25 40
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 41 public function enqueue_home_screen_scripts(): void {
36 42 if ( ! current_user_can( 'manage_options' ) ) {
37 43 return;
38 44 }
39 45
40 - $this->enqueue_fonts();
41 -
42 46 $min_suffix = Utils::is_script_debug() ? '' : '.min';
43 47
44 48 wp_enqueue_script(
45 49 'e-home-screen',
@@ -60,15 +64,12 @@
60 64 'e-home-screen',
61 65 'elementorHomeScreenData',
62 66 $this->get_app_js_config()
63 67 );
68 + }
64 69
65 - wp_enqueue_style(
66 - 'e-home-screen',
67 - $this->get_css_assets_url( 'modules/home/e-home-screen' ),
68 - [],
69 - ELEMENTOR_VERSION
70 - );
70 + public function is_experiment_active(): bool {
71 + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID );
71 72 }
72 73
73 74 public function add_active_document_to_edit_link( $edit_link ) {
74 75 $active_document = Utils::get_super_global_value( $_GET, 'active-document' ) ?? null;
@@ -84,17 +85,23 @@
84 85
85 86 return $edit_link;
86 87 }
87 88
89 + private function register_layout_experiment(): void {
90 + Plugin::$instance->experiments->add_feature( [
91 + 'name' => static::PAGE_ID,
92 + 'title' => esc_html__( 'Elementor Home Screen', 'elementor' ),
93 + 'description' => esc_html__( 'Default Elementor menu page.', 'elementor' ),
94 + 'hidden' => true,
95 + 'default' => Experiments_Manager::STATE_ACTIVE,
96 + ] );
97 + }
98 +
88 99 private function get_app_js_config(): array {
89 100 $editor_assets_api = new EditorAssetsAPI( $this->get_api_config() );
90 101 $api = new API( $editor_assets_api );
91 102
92 - $config = $api->get_home_screen_items();
93 -
94 - $config['wpRestNonce'] = wp_create_nonce( 'wp_rest' );
95 -
96 - return $config;
103 + return $api->get_home_screen_items();
97 104 }
98 105
99 106 private function get_api_config(): array {
100 107 return [
@@ -104,7 +111,9 @@
104 111 ];
105 112 }
106 113
107 114 public static function get_elementor_settings_page_id(): string {
108 - return 'elementor-settings';
115 + return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID )
116 + ? 'elementor-settings'
117 + : Settings::PAGE_ID;
109 118 }
110 119 }