PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.8
Elementor Website Builder – more than just a page builder v3.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 / includes / plugin.php

plugin.php in Elementor Website Builder – more than just a page builder 3.0.8, at includes/plugin.php

727 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 use Elementor\Core\Admin\Admin;
5 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 use Elementor\Core\Common\App as CommonApp;
7 use Elementor\Core\Debug\Inspector;
8 use Elementor\Core\Documents_Manager;
9 use Elementor\Core\Kits\Manager as Kits_Manager;
10 use Elementor\Core\Editor\Editor;
11 use Elementor\Core\Files\Manager as Files_Manager;
12 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
13 use Elementor\Core\Modules_Manager;
14 use Elementor\Core\Schemes\Manager as Schemes_Manager;
15 use Elementor\Core\Settings\Manager as Settings_Manager;
16 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
17 use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
18 use Elementor\Core\Upgrade\Manager as Upgrades_Manager;
19 use Elementor\Modules\History\Revisions_Manager;
20 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
21 use Elementor\Core\Logger\Manager as Log_Manager;
22 use Elementor\Modules\System_Info\Module as System_Info_Module;
23 use Elementor\Data\Manager as Data_Manager;
24
25 if ( ! defined( 'ABSPATH' ) ) {
26 exit;
27 }
28
29 /**
30 * Elementor plugin.
31 *
32 * The main plugin handler class is responsible for initializing Elementor. The
33 * class registers and all the components required to run the plugin.
34 *
35 * @since 1.0.0
36 */
37 class Plugin {
38
39 /**
40 * Instance.
41 *
42 * Holds the plugin instance.
43 *
44 * @since 1.0.0
45 * @access public
46 * @static
47 *
48 * @var Plugin
49 */
50 public static $instance = null;
51
52 /**
53 * Database.
54 *
55 * Holds the plugin database.
56 *
57 * @since 1.0.0
58 * @access public
59 *
60 * @var DB
61 */
62 public $db;
63
64 /**
65 * Ajax Manager.
66 *
67 * Holds the plugin ajax manager.
68 *
69 * @since 1.9.0
70 * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
71 * @access public
72 *
73 * @var Ajax
74 */
75 public $ajax;
76
77 /**
78 * Controls manager.
79 *
80 * Holds the plugin controls manager.
81 *
82 * @since 1.0.0
83 * @access public
84 *
85 * @var Controls_Manager
86 */
87 public $controls_manager;
88
89 /**
90 * Documents manager.
91 *
92 * Holds the documents manager.
93 *
94 * @since 2.0.0
95 * @access public
96 *
97 * @var Documents_Manager
98 */
99 public $documents;
100
101 /**
102 * Schemes manager.
103 *
104 * Holds the plugin schemes manager.
105 *
106 * @since 1.0.0
107 * @access public
108 *
109 * @var Schemes_Manager
110 */
111 public $schemes_manager;
112
113 /**
114 * Elements manager.
115 *
116 * Holds the plugin elements manager.
117 *
118 * @since 1.0.0
119 * @access public
120 *
121 * @var Elements_Manager
122 */
123 public $elements_manager;
124
125 /**
126 * Widgets manager.
127 *
128 * Holds the plugin widgets manager.
129 *
130 * @since 1.0.0
131 * @access public
132 *
133 * @var Widgets_Manager
134 */
135 public $widgets_manager;
136
137 /**
138 * Revisions manager.
139 *
140 * Holds the plugin revisions manager.
141 *
142 * @since 1.0.0
143 * @access public
144 *
145 * @var Revisions_Manager
146 */
147 public $revisions_manager;
148
149 /**
150 * Images manager.
151 *
152 * Holds the plugin images manager.
153 *
154 * @since 2.9.0
155 * @access public
156 *
157 * @var Images_Manager
158 */
159 public $images_manager;
160
161 /**
162 * Maintenance mode.
163 *
164 * Holds the plugin maintenance mode.
165 *
166 * @since 1.0.0
167 * @access public
168 *
169 * @var Maintenance_Mode
170 */
171 public $maintenance_mode;
172
173 /**
174 * Page settings manager.
175 *
176 * Holds the page settings manager.
177 *
178 * @since 1.0.0
179 * @access public
180 *
181 * @var Page_Settings_Manager
182 */
183 public $page_settings_manager;
184
185 /**
186 * Dynamic tags manager.
187 *
188 * Holds the dynamic tags manager.
189 *
190 * @since 1.0.0
191 * @access public
192 *
193 * @var Dynamic_Tags_Manager
194 */
195 public $dynamic_tags;
196
197 /**
198 * Settings.
199 *
200 * Holds the plugin settings.
201 *
202 * @since 1.0.0
203 * @access public
204 *
205 * @var Settings
206 */
207 public $settings;
208
209 /**
210 * Role Manager.
211 *
212 * Holds the plugin Role Manager
213 *
214 * @since 2.0.0
215 * @access public
216 *
217 * @var \Elementor\Core\RoleManager\Role_Manager
218 */
219 public $role_manager;
220
221 /**
222 * Admin.
223 *
224 * Holds the plugin admin.
225 *
226 * @since 1.0.0
227 * @access public
228 *
229 * @var Admin
230 */
231 public $admin;
232
233 /**
234 * Tools.
235 *
236 * Holds the plugin tools.
237 *
238 * @since 1.0.0
239 * @access public
240 *
241 * @var Tools
242 */
243 public $tools;
244
245 /**
246 * Preview.
247 *
248 * Holds the plugin preview.
249 *
250 * @since 1.0.0
251 * @access public
252 *
253 * @var Preview
254 */
255 public $preview;
256
257 /**
258 * Editor.
259 *
260 * Holds the plugin editor.
261 *
262 * @since 1.0.0
263 * @access public
264 *
265 * @var Editor
266 */
267 public $editor;
268
269 /**
270 * Frontend.
271 *
272 * Holds the plugin frontend.
273 *
274 * @since 1.0.0
275 * @access public
276 *
277 * @var Frontend
278 */
279 public $frontend;
280
281 /**
282 * Heartbeat.
283 *
284 * Holds the plugin heartbeat.
285 *
286 * @since 1.0.0
287 * @access public
288 *
289 * @var Heartbeat
290 */
291 public $heartbeat;
292
293 /**
294 * System info.
295 *
296 * Holds the system info data.
297 *
298 * @since 1.0.0
299 * @access public
300 *
301 * @var System_Info\Main
302 */
303 public $system_info;
304
305 /**
306 * Template library manager.
307 *
308 * Holds the template library manager.
309 *
310 * @since 1.0.0
311 * @access public
312 *
313 * @var TemplateLibrary\Manager
314 */
315 public $templates_manager;
316
317 /**
318 * Skins manager.
319 *
320 * Holds the skins manager.
321 *
322 * @since 1.0.0
323 * @access public
324 *
325 * @var Skins_Manager
326 */
327 public $skins_manager;
328
329 /**
330 * Files Manager.
331 *
332 * Holds the files manager.
333 *
334 * @since 2.1.0
335 * @access public
336 *
337 * @var Files_Manager
338 */
339 public $files_manager;
340
341 /**
342 * Assets Manager.
343 *
344 * Holds the Assets manager.
345 *
346 * @since 2.6.0
347 * @access public
348 *
349 * @var Assets_Manager
350 */
351 public $assets_manager;
352
353 /**
354 * Files Manager.
355 *
356 * Holds the files manager.
357 *
358 * @since 1.0.0
359 * @access public
360 * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
361 *
362 * @var Files_Manager
363 */
364 public $posts_css_manager;
365
366 /**
367 * WordPress widgets manager.
368 *
369 * Holds the WordPress widgets manager.
370 *
371 * @since 1.0.0
372 * @access public
373 *
374 * @var WordPress_Widgets_Manager
375 */
376 public $wordpress_widgets_manager;
377
378 /**
379 * Modules manager.
380 *
381 * Holds the modules manager.
382 *
383 * @since 1.0.0
384 * @access public
385 *
386 * @var Modules_Manager
387 */
388 public $modules_manager;
389
390 /**
391 * Beta testers.
392 *
393 * Holds the plugin beta testers.
394 *
395 * @since 1.0.0
396 * @access public
397 *
398 * @var Beta_Testers
399 */
400 public $beta_testers;
401
402 /**
403 * @var Inspector
404 * @deprecated 2.1.2 Use $inspector.
405 */
406 public $debugger;
407
408 /**
409 * @var Inspector
410 */
411 public $inspector;
412
413 /**
414 * @var CommonApp
415 */
416 public $common;
417
418 /**
419 * @var Log_Manager
420 */
421 public $logger;
422
423 /**
424 * @var Core\Upgrade\Manager
425 */
426 public $upgrade;
427
428 /**
429 * @var Core\Kits\Manager
430 */
431 public $kits_manager;
432
433 /**
434 * @var \Core\Data\Manager
435 */
436 public $data_manager;
437
438 public $legacy_mode;
439
440 /**
441 * @var Core\App\App
442 */
443 public $app;
444
445 /**
446 * Clone.
447 *
448 * Disable class cloning and throw an error on object clone.
449 *
450 * The whole idea of the singleton design pattern is that there is a single
451 * object. Therefore, we don't want the object to be cloned.
452 *
453 * @access public
454 * @since 1.0.0
455 */
456 public function __clone() {
457 // Cloning instances of the class is forbidden.
458 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
459 }
460
461 /**
462 * Wakeup.
463 *
464 * Disable unserializing of the class.
465 *
466 * @access public
467 * @since 1.0.0
468 */
469 public function __wakeup() {
470 // Unserializing instances of the class is forbidden.
471 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
472 }
473
474 /**
475 * Instance.
476 *
477 * Ensures only one instance of the plugin class is loaded or can be loaded.
478 *
479 * @since 1.0.0
480 * @access public
481 * @static
482 *
483 * @return Plugin An instance of the class.
484 */
485 public static function instance() {
486 if ( is_null( self::$instance ) ) {
487 self::$instance = new self();
488
489 /**
490 * Elementor loaded.
491 *
492 * Fires when Elementor was fully loaded and instantiated.
493 *
494 * @since 1.0.0
495 */
496 do_action( 'elementor/loaded' );
497 }
498
499 return self::$instance;
500 }
501
502 /**
503 * Init.
504 *
505 * Initialize Elementor Plugin. Register Elementor support for all the
506 * supported post types and initialize Elementor components.
507 *
508 * @since 1.0.0
509 * @access public
510 */
511 public function init() {
512 $this->add_cpt_support();
513
514 $this->init_components();
515
516 /**
517 * Elementor init.
518 *
519 * Fires on Elementor init, after Elementor has finished loading but
520 * before any headers are sent.
521 *
522 * @since 1.0.0
523 */
524 do_action( 'elementor/init' );
525 }
526
527 /**
528 * Get install time.
529 *
530 * Retrieve the time when Elementor was installed.
531 *
532 * @since 2.6.0
533 * @access public
534 * @static
535 *
536 * @return int Unix timestamp when Elementor was installed.
537 */
538 public function get_install_time() {
539 $installed_time = get_option( '_elementor_installed_time' );
540
541 if ( ! $installed_time ) {
542 $installed_time = time();
543
544 update_option( '_elementor_installed_time', $installed_time );
545 }
546
547 return $installed_time;
548 }
549
550 /**
551 * @since 2.3.0
552 * @access public
553 */
554 public function on_rest_api_init() {
555 // On admin/frontend sometimes the rest API is initialized after the common is initialized.
556 if ( ! $this->common ) {
557 $this->init_common();
558 }
559 }
560
561 /**
562 * Init components.
563 *
564 * Initialize Elementor components. Register actions, run setting manager,
565 * initialize all the components that run elementor, and if in admin page
566 * initialize admin components.
567 *
568 * @since 1.0.0
569 * @access private
570 */
571 private function init_components() {
572 $this->inspector = new Inspector();
573 $this->debugger = $this->inspector;
574
575 Settings_Manager::run();
576
577 $this->db = new DB();
578 $this->controls_manager = new Controls_Manager();
579 $this->documents = new Documents_Manager();
580 $this->kits_manager = new Kits_Manager();
581 $this->schemes_manager = new Schemes_Manager();
582 $this->elements_manager = new Elements_Manager();
583 $this->widgets_manager = new Widgets_Manager();
584 $this->skins_manager = new Skins_Manager();
585 $this->files_manager = new Files_Manager();
586 $this->assets_manager = new Assets_Manager();
587 $this->icons_manager = new Icons_Manager();
588 /*
589 * @TODO: Remove deprecated alias
590 */
591 $this->posts_css_manager = $this->files_manager;
592 $this->settings = new Settings();
593 $this->tools = new Tools();
594 $this->editor = new Editor();
595 $this->preview = new Preview();
596 $this->frontend = new Frontend();
597 $this->templates_manager = new TemplateLibrary\Manager();
598 $this->maintenance_mode = new Maintenance_Mode();
599 $this->dynamic_tags = new Dynamic_Tags_Manager();
600 $this->modules_manager = new Modules_Manager();
601 $this->role_manager = new Core\RoleManager\Role_Manager();
602 $this->system_info = new System_Info_Module();
603 $this->revisions_manager = new Revisions_Manager();
604 $this->images_manager = new Images_Manager();
605
606 User::init();
607 Api::init();
608 Tracker::init();
609
610 $this->upgrade = new Core\Upgrade\Manager();
611
612 $this->app = new Core\App\App();
613
614 if ( is_admin() ) {
615 $this->heartbeat = new Heartbeat();
616 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
617 $this->admin = new Admin();
618 $this->beta_testers = new Beta_Testers();
619 new Elementor_3_Re_Migrate_Globals();
620 }
621 }
622
623 /**
624 * @since 2.3.0
625 * @access public
626 */
627 public function init_common() {
628 $this->common = new CommonApp();
629
630 $this->common->init_components();
631
632 $this->ajax = $this->common->get_component( 'ajax' );
633 }
634
635 public function get_legacy_mode( $mode_name = null ) {
636 if ( ! $this->legacy_mode ) {
637 $optimized_dom_output = get_option( 'elementor_optimized_dom_output' );
638
639 if ( $optimized_dom_output ) {
640 $element_wrappers_legacy_mode = 'disabled' === $optimized_dom_output;
641 } else {
642 $element_wrappers_legacy_mode = true;
643 }
644
645 $this->legacy_mode = [
646 'elementWrappers' => $element_wrappers_legacy_mode,
647 ];
648 }
649
650 if ( ! $mode_name ) {
651 return $this->legacy_mode;
652 }
653
654 if ( isset( $this->legacy_mode[ $mode_name ] ) ) {
655 return $this->legacy_mode[ $mode_name ];
656 }
657
658 // If there is no legacy mode with the given mode name;
659 return false;
660 }
661
662 /**
663 * Add custom post type support.
664 *
665 * Register Elementor support for all the supported post types defined by
666 * the user in the admin screen and saved as `elementor_cpt_support` option
667 * in WordPress `$wpdb->options` table.
668 *
669 * If no custom post type selected, usually in new installs, this method
670 * will return the two default post types: `page` and `post`.
671 *
672 * @since 1.0.0
673 * @access private
674 */
675 private function add_cpt_support() {
676 $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
677
678 foreach ( $cpt_support as $cpt_slug ) {
679 add_post_type_support( $cpt_slug, 'elementor' );
680 }
681 }
682
683 /**
684 * Register autoloader.
685 *
686 * Elementor autoloader loads all the classes needed to run the plugin.
687 *
688 * @since 1.6.0
689 * @access private
690 */
691 private function register_autoloader() {
692 require_once ELEMENTOR_PATH . '/includes/autoloader.php';
693
694 Autoloader::run();
695 }
696
697 /**
698 * Plugin constructor.
699 *
700 * Initializing Elementor plugin.
701 *
702 * @since 1.0.0
703 * @access private
704 */
705 private function __construct() {
706 $this->register_autoloader();
707
708 $this->logger = Log_Manager::instance();
709 $this->data_manager = Data_Manager::instance();
710
711 Maintenance::init();
712 Compatibility::register_actions();
713
714 add_action( 'init', [ $this, 'init' ], 0 );
715 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
716 }
717
718 final public static function get_title() {
719 return __( 'Elementor', 'elementor' );
720 }
721 }
722
723 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
724 // In tests we run the instance manually.
725 Plugin::instance();
726 }
727