PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.1
Elementor Website Builder – more than just a page builder v3.34.1
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 / editor-one / module.php

module.php in Elementor Website Builder – more than just a page builder 3.34.1, at modules/editor-one/module.php

126 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\EditorOne;
4
5 use Elementor\Core\Admin\Admin;
6 use Elementor\Core\Base\Module as BaseModule;
7 use Elementor\Core\Experiments\Manager as Experiments_Manager;
8 use Elementor\Modules\EditorOne\Components\Elementor_One_Menu_Manager;
9 use Elementor\Modules\EditorOne\Components\Sidebar_Navigation_Handler;
10 use Elementor\Plugin;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 class Module extends BaseModule {
17
18 const EXPERIMENT_NAME = 'e_editor_one';
19
20 const CUSTOM_REACT_APP_PAGES = [
21 'elementor-element-manager',
22 ];
23
24 public function get_name(): string {
25 return 'editor-one';
26 }
27
28 public static function get_experimental_data(): array {
29 return [
30 'name' => static::EXPERIMENT_NAME,
31 'title' => esc_html__( 'Editor one', 'elementor' ),
32 'description' => esc_html__( 'General', 'elementor' ),
33 'hidden' => true,
34 'default' => Experiments_Manager::STATE_INACTIVE,
35 'release_status' => Experiments_Manager::RELEASE_STATUS_DEV,
36 ];
37 }
38
39 public function __construct() {
40 parent::__construct();
41
42 if ( is_admin() ) {
43 $this->add_component( 'editor-one-menu-manager', new Elementor_One_Menu_Manager() );
44 $this->add_component( 'sidebar-navigation-handler', new Sidebar_Navigation_Handler() );
45 }
46
47 add_action( 'current_screen', function () {
48 if ( ! $this->is_feature_enabled() || ! Admin::is_elementor_admin_page() ) {
49 return;
50 }
51
52 add_action( 'admin_enqueue_scripts', function () {
53 $this->enqueue_styles();
54 } );
55 } );
56 }
57
58 /**
59 * Check if Editor One feature is enabled
60 *
61 * @return bool
62 */
63 private function is_feature_enabled() {
64 return Plugin::$instance->experiments->is_feature_active( static::EXPERIMENT_NAME );
65 }
66
67 /**
68 * Check if current page has a custom React app that uses @elementor/ui
69 *
70 * @return bool
71 */
72 private function is_custom_react_app_page() {
73 $current_screen = get_current_screen();
74
75 if ( ! $current_screen ) {
76 return false;
77 }
78
79 foreach ( self::CUSTOM_REACT_APP_PAGES as $page_slug ) {
80 if ( str_contains( $current_screen->id ?? '', $page_slug ) ) {
81 return true;
82 }
83 }
84
85 return false;
86 }
87
88 /**
89 * Enqueue admin styles
90 */
91 private function enqueue_styles() {
92 wp_enqueue_style( 'elementor-admin' );
93
94 wp_enqueue_style(
95 'elementor-editor-one-common',
96 $this->get_css_assets_url( 'editor-one-common' ),
97 [ 'elementor-admin' ],
98 ELEMENTOR_VERSION
99 );
100
101 if ( ! $this->is_custom_react_app_page() ) {
102 wp_enqueue_style(
103 'elementor-editor-one-elements',
104 $this->get_css_assets_url( 'editor-one-elements' ),
105 [ 'elementor-editor-one-common' ],
106 ELEMENTOR_VERSION
107 );
108
109 wp_enqueue_style(
110 'elementor-editor-one-tables',
111 $this->get_css_assets_url( 'editor-one-tables' ),
112 [ 'elementor-editor-one-common' ],
113 ELEMENTOR_VERSION
114 );
115 }
116
117 wp_enqueue_script(
118 'editor-one-admin',
119 $this->get_js_assets_url( 'editor-one-admin' ),
120 [ 'jquery' ],
121 ELEMENTOR_VERSION,
122 true
123 );
124 }
125 }
126