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

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

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