PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.8
Elementor Website Builder – more than just a page builder v4.0.8
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 4.0.8, at modules/home/module.php

100 lines 2.3 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\Base\App as BaseApp;
5 use Elementor\Includes\EditorAssetsAPI;
6 use Elementor\Settings;
7 use Elementor\Plugin;
8 use Elementor\Utils;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13
14 class Module extends BaseApp {
15
16 const PAGE_ID = 'home_screen';
17
18 public function get_name(): string {
19 return 'home';
20 }
21
22 public function __construct() {
23 parent::__construct();
24
25 add_filter( 'elementor/document/urls/edit', [ $this, 'add_active_document_to_edit_link' ] );
26 }
27
28 public function enqueue_home_screen_scripts(): void {
29 if ( ! current_user_can( 'manage_options' ) ) {
30 return;
31 }
32
33 $min_suffix = Utils::is_script_debug() ? '' : '.min';
34
35 wp_enqueue_script(
36 'e-home-screen',
37 ELEMENTOR_ASSETS_URL . 'js/e-home-screen' . $min_suffix . '.js',
38 [
39 'react',
40 'react-dom',
41 'elementor-common',
42 'elementor-v2-ui',
43 ],
44 ELEMENTOR_VERSION,
45 true
46 );
47
48 wp_set_script_translations( 'e-home-screen', 'elementor' );
49
50 wp_localize_script(
51 'e-home-screen',
52 'elementorHomeScreenData',
53 $this->get_app_js_config()
54 );
55
56 wp_enqueue_style(
57 'e-home-screen',
58 $this->get_css_assets_url( 'modules/home/e-home-screen' ),
59 [],
60 ELEMENTOR_VERSION
61 );
62 }
63
64 public function add_active_document_to_edit_link( $edit_link ) {
65 $active_document = Utils::get_super_global_value( $_GET, 'active-document' ) ?? null;
66 $active_tab = Utils::get_super_global_value( $_GET, 'active-tab' ) ?? null;
67
68 if ( $active_document ) {
69 $edit_link = add_query_arg( 'active-document', $active_document, $edit_link );
70 }
71
72 if ( $active_tab ) {
73 $edit_link = add_query_arg( 'active-tab', $active_tab, $edit_link );
74 }
75
76 return $edit_link;
77 }
78
79 private function get_app_js_config(): array {
80 $editor_assets_api = new EditorAssetsAPI( $this->get_api_config() );
81 $api = new API( $editor_assets_api );
82
83 $config = $api->get_home_screen_items();
84
85 return $config;
86 }
87
88 private function get_api_config(): array {
89 return [
90 EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/home-screen/v1/home-screen.json',
91 EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_home_screen_data',
92 EditorAssetsAPI::ASSETS_DATA_KEY => 'home-screen',
93 ];
94 }
95
96 public static function get_elementor_settings_page_id(): string {
97 return 'elementor-settings';
98 }
99 }
100