PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.4
Elementor Website Builder – more than just a page builder v3.24.4
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
elementor / modules / home / module.php

module.php in Elementor Website Builder – more than just a page builder 3.24.4, at modules/home/module.php

108 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Home;
3
4 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 use Elementor\Core\Base\App as BaseApp;
6 use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 use Elementor\Settings;
8 use Elementor\Plugin;
9 use Elementor\Utils;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Module extends BaseApp {
16
17 const PAGE_ID = 'home_screen';
18
19 public function get_name(): string {
20 return 'home';
21 }
22
23 public function __construct() {
24 parent::__construct();
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
37 add_filter( 'elementor/document/urls/edit', [ $this, 'add_active_document_to_edit_link' ] );
38 }
39
40 public function enqueue_home_screen_scripts(): void {
41 if ( ! current_user_can( 'manage_options' ) ) {
42 return;
43 }
44
45 $min_suffix = Utils::is_script_debug() ? '' : '.min';
46
47 wp_enqueue_script(
48 'e-home-screen',
49 ELEMENTOR_ASSETS_URL . 'js/e-home-screen' . $min_suffix . '.js',
50 [
51 'react',
52 'react-dom',
53 'elementor-common',
54 'elementor-v2-ui',
55 ],
56 ELEMENTOR_VERSION,
57 true
58 );
59
60 wp_set_script_translations( 'e-home-screen', 'elementor' );
61
62 wp_localize_script(
63 'e-home-screen',
64 'elementorHomeScreenData',
65 $this->get_app_js_config()
66 );
67 }
68
69 public function is_experiment_active(): bool {
70 return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID );
71 }
72
73 public function add_active_document_to_edit_link( $edit_link ) {
74 $active_document = Utils::get_super_global_value( $_GET, 'active-document' ) ?? null;
75 $active_tab = Utils::get_super_global_value( $_GET, 'active-tab' ) ?? null;
76
77 if ( $active_document ) {
78 $edit_link = add_query_arg( 'active-document', $active_document, $edit_link );
79 }
80
81 if ( $active_tab ) {
82 $edit_link = add_query_arg( 'active-tab', $active_tab, $edit_link );
83 }
84
85 return $edit_link;
86 }
87
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 ] );
96 }
97
98 private function get_app_js_config(): array {
99 return API::get_home_screen_items();
100 }
101
102 public static function get_elementor_settings_page_id(): string {
103 return Plugin::$instance->experiments->is_feature_active( self::PAGE_ID )
104 ? 'elementor-settings'
105 : Settings::PAGE_ID;
106 }
107 }
108