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

253 lines 5.1 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
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 /**
14 * App
15 *
16 * Elementor's common app that groups shared functionality, components and configuration
17 *
18 * @since 2.3.0
19 */
20 class App extends BaseApp {
21
22 private $templates = [];
23
24 /**
25 * App constructor.
26 *
27 * @since 2.3.0
28 * @access public
29 */
30 public function __construct() {
31 $this->add_default_templates();
32
33 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_scripts' ] );
34 add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] );
35 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
36
37 add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'register_styles' ] );
38 add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] );
39 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 9 );
40
41 add_action( 'elementor/editor/footer', [ $this, 'print_templates' ] );
42 add_action( 'admin_footer', [ $this, 'print_templates' ] );
43 add_action( 'wp_footer', [ $this, 'print_templates' ] );
44 }
45
46 /**
47 * Init components
48 *
49 * Initializing common components.
50 *
51 * @since 2.3.0
52 * @access public
53 */
54 public function init_components() {
55 $this->add_component( 'ajax', new Ajax() );
56
57 if ( current_user_can( 'manage_options' ) ) {
58 if ( ! is_customize_preview() ) {
59 $this->add_component( 'finder', new Finder() );
60 }
61 }
62
63 $this->add_component( 'connect', new Connect() );
64 }
65
66 /**
67 * Get name.
68 *
69 * Retrieve the app name.
70 *
71 * @since 2.3.0
72 * @access public
73 *
74 * @return string Common app name.
75 */
76 public function get_name() {
77 return 'common';
78 }
79
80 /**
81 * Register scripts.
82 *
83 * Register common scripts.
84 *
85 * @since 2.3.0
86 * @access public
87 */
88 public function register_scripts() {
89 wp_register_script(
90 'elementor-common-modules',
91 $this->get_js_assets_url( 'common-modules' ),
92 [],
93 ELEMENTOR_VERSION,
94 true
95 );
96
97 wp_register_script(
98 'backbone-marionette',
99 $this->get_js_assets_url( 'backbone.marionette', 'assets/lib/backbone/' ),
100 [
101 'backbone',
102 ],
103 '2.4.5',
104 true
105 );
106
107 wp_register_script(
108 'backbone-radio',
109 $this->get_js_assets_url( 'backbone.radio', 'assets/lib/backbone/' ),
110 [
111 'backbone',
112 ],
113 '1.0.4',
114 true
115 );
116
117 wp_register_script(
118 'elementor-dialog',
119 $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
120 [
121 'jquery-ui-position',
122 ],
123 '4.8.1',
124 true
125 );
126
127 wp_enqueue_script(
128 'elementor-common',
129 $this->get_js_assets_url( 'common' ),
130 [
131 'jquery',
132 'jquery-ui-draggable',
133 'backbone-marionette',
134 'backbone-radio',
135 'elementor-common-modules',
136 'elementor-dialog',
137 'wp-api-request',
138 ],
139 ELEMENTOR_VERSION,
140 true
141 );
142
143 $this->print_config();
144
145 // Used for external plugins.
146 do_action( 'elementor/common/after_register_scripts', $this );
147 }
148
149 /**
150 * Register styles.
151 *
152 * Register common styles.
153 *
154 * @since 2.3.0
155 * @access public
156 */
157 public function register_styles() {
158 wp_register_style(
159 'elementor-icons',
160 $this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ),
161 [],
162 '5.9.1'
163 );
164
165 wp_enqueue_style(
166 'elementor-common',
167 $this->get_css_assets_url( 'common', null, 'default', true ),
168 [
169 'elementor-icons',
170 ],
171 ELEMENTOR_VERSION
172 );
173 }
174
175 /**
176 * Add template.
177 *
178 * @since 2.3.0
179 * @access public
180 *
181 * @param string $template Can be either a link to template file or template
182 * HTML content.
183 * @param string $type Optional. Whether to handle the template as path
184 * or text. Default is `path`.
185 */
186 public function add_template( $template, $type = 'path' ) {
187 if ( 'path' === $type ) {
188 ob_start();
189
190 include $template;
191
192 $template = ob_get_clean();
193 }
194
195 $this->templates[] = $template;
196 }
197
198 /**
199 * Print Templates
200 *
201 * Prints all registered templates.
202 *
203 * @since 2.3.0
204 * @access public
205 */
206 public function print_templates() {
207 foreach ( $this->templates as $template ) {
208 echo $template;
209 }
210 }
211
212 /**
213 * Get init settings.
214 *
215 * Define the default/initial settings of the common app.
216 *
217 * @since 2.3.0
218 * @access protected
219 *
220 * @return array
221 */
222 protected function get_init_settings() {
223 return [
224 'version' => ELEMENTOR_VERSION,
225 'isRTL' => is_rtl(),
226 'isDebug' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
227 'isElementorDebug' => ( defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG ),
228 'activeModules' => array_keys( $this->get_components() ),
229 'urls' => [
230 'assets' => ELEMENTOR_ASSETS_URL,
231 'rest' => get_rest_url(),
232 ],
233 ];
234 }
235
236 /**
237 * Add default templates.
238 *
239 * Register common app default templates.
240 * @since 2.3.0
241 * @access private
242 */
243 private function add_default_templates() {
244 $default_templates = [
245 'includes/editor-templates/library-layout.php',
246 ];
247
248 foreach ( $default_templates as $template ) {
249 $this->add_template( ELEMENTOR_PATH . $template );
250 }
251 }
252 }
253