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

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