PluginProbe
Elementor Website Builder – more than just a page builder / 3.27.5
Elementor Website Builder – more than just a page builder v3.27.5
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 / core / common / app.php

app.php in Elementor Website Builder – more than just a page builder 3.27.5, at core/common/app.php

291 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Common;
3
4 use Elementor\Core\Base\App as BaseApp;
5 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 use Elementor\Core\Common\Modules\Finder\Module as Finder;
7 use Elementor\Core\Common\Modules\Connect\Module as Connect;
8 use Elementor\Core\Common\Modules\EventTracker\Module as Event_Tracker;
9 use Elementor\Core\Files\Uploads_Manager;
10 use Elementor\Core\Settings\Manager as SettingsManager;
11 use Elementor\Icons_Manager;
12 use Elementor\Plugin;
13 use Elementor\Utils;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * App
21 *
22 * Elementor's common app that groups shared functionality, components and configuration
23 *
24 * @since 2.3.0
25 */
26 class App extends BaseApp {
27
28 private $templates = [];
29
30 /**
31 * App constructor.
32 *
33 * @since 2.3.0
34 * @access public
35 */
36 public function __construct() {
37 $this->add_default_templates();
38
39 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_scripts' ] );
40 add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] );
41 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
42
43 add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'register_styles' ] );
44 add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] );
45 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 9 );
46
47 add_action( 'elementor/editor/footer', [ $this, 'print_templates' ] );
48 add_action( 'admin_footer', [ $this, 'print_templates' ] );
49 add_action( 'wp_footer', [ $this, 'print_templates' ] );
50 }
51
52 /**
53 * Init components
54 *
55 * Initializing common components.
56 *
57 * @since 2.3.0
58 * @access public
59 */
60 public function init_components() {
61 $this->add_component( 'ajax', new Ajax() );
62
63 if ( current_user_can( 'manage_options' ) ) {
64 if ( ! is_customize_preview() ) {
65 $this->add_component( 'finder', new Finder() );
66 }
67 }
68
69 $this->add_component( 'connect', new Connect() );
70
71 $this->add_component( 'event-tracker', new Event_Tracker() );
72 }
73
74 /**
75 * Get name.
76 *
77 * Retrieve the app name.
78 *
79 * @since 2.3.0
80 * @access public
81 *
82 * @return string Common app name.
83 */
84 public function get_name() {
85 return 'common';
86 }
87
88 /**
89 * Register scripts.
90 *
91 * Register common scripts.
92 *
93 * @since 2.3.0
94 * @access public
95 */
96 public function register_scripts() {
97 wp_register_script(
98 'elementor-common-modules',
99 $this->get_js_assets_url( 'common-modules' ),
100 [],
101 ELEMENTOR_VERSION,
102 true
103 );
104
105 wp_register_script(
106 'backbone-marionette',
107 $this->get_js_assets_url( 'backbone.marionette', 'assets/lib/backbone/' ),
108 [
109 'backbone',
110 ],
111 '2.4.5.e1',
112 true
113 );
114
115 wp_register_script(
116 'backbone-radio',
117 $this->get_js_assets_url( 'backbone.radio', 'assets/lib/backbone/' ),
118 [
119 'backbone',
120 ],
121 '1.0.4',
122 true
123 );
124
125 wp_register_script(
126 'elementor-dialog',
127 $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
128 [
129 'jquery-ui-position',
130 ],
131 '4.9.0',
132 true
133 );
134
135 wp_enqueue_script(
136 'elementor-common',
137 $this->get_js_assets_url( 'common' ),
138 [
139 'jquery',
140 'jquery-ui-draggable',
141 'backbone-marionette',
142 'backbone-radio',
143 'elementor-common-modules',
144 'elementor-web-cli',
145 'elementor-dialog',
146 'wp-api-request',
147 'elementor-dev-tools',
148 ],
149 ELEMENTOR_VERSION,
150 true
151 );
152
153 wp_set_script_translations( 'elementor-common', 'elementor' );
154
155 $this->print_config();
156
157 // Used for external plugins.
158 do_action( 'elementor/common/after_register_scripts', $this );
159 }
160
161 /**
162 * Register styles.
163 *
164 * Register common styles.
165 *
166 * @since 2.3.0
167 * @access public
168 */
169 public function register_styles() {
170 wp_register_style(
171 'elementor-icons',
172 $this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ),
173 [],
174 Icons_Manager::ELEMENTOR_ICONS_VERSION
175 );
176
177 wp_enqueue_style(
178 'elementor-common',
179 $this->get_css_assets_url( 'common', null, 'default', true ),
180 [
181 'elementor-icons',
182 ],
183 ELEMENTOR_VERSION
184 );
185
186 wp_enqueue_style(
187 'e-theme-ui-light',
188 $this->get_css_assets_url( 'theme-light' ),
189 [],
190 ELEMENTOR_VERSION
191 );
192 }
193
194 /**
195 * Add template.
196 *
197 * @since 2.3.0
198 * @access public
199 *
200 * @param string $template Can be either a link to template file or template
201 * HTML content.
202 * @param string $type Optional. Whether to handle the template as path
203 * or text. Default is `path`.
204 */
205 public function add_template( $template, $type = 'path' ) {
206 if ( 'path' === $type ) {
207 ob_start();
208
209 include $template;
210
211 $template = ob_get_clean();
212 }
213
214 $this->templates[] = $template;
215 }
216
217 /**
218 * Print Templates
219 *
220 * Prints all registered templates.
221 *
222 * @since 2.3.0
223 * @access public
224 */
225 public function print_templates() {
226 foreach ( $this->templates as $template ) {
227 echo $template; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
228 }
229 }
230
231 /**
232 * Get init settings.
233 *
234 * Define the default/initial settings of the common app.
235 *
236 * @since 2.3.0
237 * @access protected
238 *
239 * @return array
240 */
241 protected function get_init_settings() {
242 $active_experimental_features = Plugin::$instance->experiments->get_active_features();
243
244 $active_experimental_features = array_fill_keys( array_keys( $active_experimental_features ), true );
245
246 $config = [
247 'version' => ELEMENTOR_VERSION,
248 'isRTL' => is_rtl(),
249 'isDebug' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
250 'isElementorDebug' => ( defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG ),
251 'activeModules' => array_keys( $this->get_components() ),
252 'experimentalFeatures' => $active_experimental_features,
253 'urls' => [
254 'assets' => ELEMENTOR_ASSETS_URL,
255 'rest' => get_rest_url(),
256 ],
257 'filesUpload' => [
258 'unfilteredFiles' => Uploads_Manager::are_unfiltered_uploads_enabled(),
259 ],
260 ];
261
262 /**
263 * Localize common settings.
264 *
265 * Filters the editor localized settings.
266 *
267 * @since 1.0.0
268 *
269 * @param array $config Common configuration.
270 */
271 return apply_filters( 'elementor/common/localize_settings', $config );
272 }
273
274 /**
275 * Add default templates.
276 *
277 * Register common app default templates.
278 * @since 2.3.0
279 * @access private
280 */
281 private function add_default_templates() {
282 $default_templates = [
283 'includes/editor-templates/library-layout.php',
284 ];
285
286 foreach ( $default_templates as $template ) {
287 $this->add_template( ELEMENTOR_PATH . $template );
288 }
289 }
290 }
291