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

863 lines 16.0 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\Menu\Admin_Menu_Manager;
5 use Elementor\Core\Wp_Api;
6 use Elementor\Core\Admin\Admin;
7 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
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\Modules\History\Revisions_Manager;
21 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 use Elementor\Core\Logger\Manager as Log_Manager;
23 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 use Elementor\Data\Manager as Data_Manager;
26 use Elementor\Data\V2\Manager as Data_Manager_V2;
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 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
44
45 /**
46 * Instance.
47 *
48 * Holds the plugin instance.
49 *
50 * @since 1.0.0
51 * @access public
52 * @static
53 *
54 * @var Plugin
55 */
56 public static $instance = null;
57
58 /**
59 * Database.
60 *
61 * Holds the plugin database handler which is responsible for communicating
62 * with the database.
63 *
64 * @since 1.0.0
65 * @access public
66 *
67 * @var DB
68 */
69 public $db;
70
71 /**
72 * Controls manager.
73 *
74 * Holds the plugin controls manager handler is responsible for registering
75 * and initializing controls.
76 *
77 * @since 1.0.0
78 * @access public
79 *
80 * @var Controls_Manager
81 */
82 public $controls_manager;
83
84 /**
85 * Documents manager.
86 *
87 * Holds the documents manager.
88 *
89 * @since 2.0.0
90 * @access public
91 *
92 * @var Documents_Manager
93 */
94 public $documents;
95
96 /**
97 * Schemes manager.
98 *
99 * Holds the plugin schemes manager.
100 *
101 * @since 1.0.0
102 * @access public
103 * @deprecated 3.0.0
104 *
105 * @var Schemes_Manager
106 */
107 public $schemes_manager;
108
109 /**
110 * Elements manager.
111 *
112 * Holds the plugin elements manager.
113 *
114 * @since 1.0.0
115 * @access public
116 *
117 * @var Elements_Manager
118 */
119 public $elements_manager;
120
121 /**
122 * Widgets manager.
123 *
124 * Holds the plugin widgets manager which is responsible for registering and
125 * initializing widgets.
126 *
127 * @since 1.0.0
128 * @access public
129 *
130 * @var Widgets_Manager
131 */
132 public $widgets_manager;
133
134 /**
135 * Revisions manager.
136 *
137 * Holds the plugin revisions manager which handles history and revisions
138 * functionality.
139 *
140 * @since 1.0.0
141 * @access public
142 *
143 * @var Revisions_Manager
144 */
145 public $revisions_manager;
146
147 /**
148 * Images manager.
149 *
150 * Holds the plugin images manager which is responsible for retrieving image
151 * details.
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 maintenance mode manager responsible for the "Maintenance Mode"
164 * and the "Coming Soon" features.
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 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_Module
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 plugin 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 plugin assets manager.
345 *
346 * @since 2.6.0
347 * @access public
348 *
349 * @var Assets_Manager
350 */
351 public $assets_manager;
352
353 /**
354 * Icons Manager.
355 *
356 * Holds the plugin icons manager.
357 *
358 * @access public
359 *
360 * @var Icons_Manager
361 */
362 public $icons_manager;
363
364 /**
365 * WordPress widgets manager.
366 *
367 * Holds the WordPress widgets manager.
368 *
369 * @since 1.0.0
370 * @access public
371 *
372 * @var WordPress_Widgets_Manager
373 */
374 public $wordpress_widgets_manager;
375
376 /**
377 * Modules manager.
378 *
379 * Holds the plugin modules manager.
380 *
381 * @since 1.0.0
382 * @access public
383 *
384 * @var Modules_Manager
385 */
386 public $modules_manager;
387
388 /**
389 * Beta testers.
390 *
391 * Holds the plugin beta testers.
392 *
393 * @since 1.0.0
394 * @access public
395 *
396 * @var Beta_Testers
397 */
398 public $beta_testers;
399
400 /**
401 * Inspector.
402 *
403 * Holds the plugin inspector data.
404 *
405 * @since 2.1.2
406 * @access public
407 *
408 * @var Inspector
409 */
410 public $inspector;
411
412 /**
413 * @var Admin_Menu_Manager
414 */
415 public $admin_menu_manager;
416
417 /**
418 * Common functionality.
419 *
420 * Holds the plugin common functionality.
421 *
422 * @since 2.3.0
423 * @access public
424 *
425 * @var CommonApp
426 */
427 public $common;
428
429 /**
430 * Log manager.
431 *
432 * Holds the plugin log manager.
433 *
434 * @access public
435 *
436 * @var Log_Manager
437 */
438 public $logger;
439
440 /**
441 * Dev tools.
442 *
443 * Holds the plugin dev tools.
444 *
445 * @access private
446 *
447 * @var Dev_Tools
448 */
449 private $dev_tools;
450
451 /**
452 * Upgrade manager.
453 *
454 * Holds the plugin upgrade manager.
455 *
456 * @access public
457 *
458 * @var Core\Upgrade\Manager
459 */
460 public $upgrade;
461
462 /**
463 * Tasks manager.
464 *
465 * Holds the plugin tasks manager.
466 *
467 * @var Core\Upgrade\Custom_Tasks_Manager
468 */
469 public $custom_tasks;
470
471 /**
472 * Kits manager.
473 *
474 * Holds the plugin kits manager.
475 *
476 * @access public
477 *
478 * @var Core\Kits\Manager
479 */
480 public $kits_manager;
481
482 /**
483 * @var \Elementor\Data\V2\Manager
484 */
485 public $data_manager_v2;
486
487 /**
488 * Legacy mode.
489 *
490 * Holds the plugin legacy mode data.
491 *
492 * @access public
493 *
494 * @var array
495 */
496 public $legacy_mode;
497
498 /**
499 * App.
500 *
501 * Holds the plugin app data.
502 *
503 * @since 3.0.0
504 * @access public
505 *
506 * @var App\App
507 */
508 public $app;
509
510 /**
511 * WordPress API.
512 *
513 * Holds the methods that interact with WordPress Core API.
514 *
515 * @since 3.0.0
516 * @access public
517 *
518 * @var Wp_Api
519 */
520 public $wp;
521
522 /**
523 * Experiments manager.
524 *
525 * Holds the plugin experiments manager.
526 *
527 * @since 3.1.0
528 * @access public
529 *
530 * @var Experiments_Manager
531 */
532 public $experiments;
533
534 /**
535 * Uploads manager.
536 *
537 * Holds the plugin uploads manager responsible for handling file uploads
538 * that are not done with WordPress Media.
539 *
540 * @since 3.3.0
541 * @access public
542 *
543 * @var Uploads_Manager
544 */
545 public $uploads_manager;
546
547 /**
548 * Breakpoints manager.
549 *
550 * Holds the plugin breakpoints manager.
551 *
552 * @since 3.2.0
553 * @access public
554 *
555 * @var Breakpoints_Manager
556 */
557 public $breakpoints;
558
559 /**
560 * Assets loader.
561 *
562 * Holds the plugin assets loader responsible for conditionally enqueuing
563 * styles and script assets that were pre-enabled.
564 *
565 * @since 3.3.0
566 * @access public
567 *
568 * @var Assets_Loader
569 */
570 public $assets_loader;
571
572 /**
573 * Clone.
574 *
575 * Disable class cloning and throw an error on object clone.
576 *
577 * The whole idea of the singleton design pattern is that there is a single
578 * object. Therefore, we don't want the object to be cloned.
579 *
580 * @access public
581 * @since 1.0.0
582 */
583 public function __clone() {
584 _doing_it_wrong(
585 __FUNCTION__,
586 sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
587 '1.0.0'
588 );
589 }
590
591 /**
592 * Wakeup.
593 *
594 * Disable unserializing of the class.
595 *
596 * @access public
597 * @since 1.0.0
598 */
599 public function __wakeup() {
600 _doing_it_wrong(
601 __FUNCTION__,
602 sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
603 '1.0.0'
604 );
605 }
606
607 /**
608 * Instance.
609 *
610 * Ensures only one instance of the plugin class is loaded or can be loaded.
611 *
612 * @since 1.0.0
613 * @access public
614 * @static
615 *
616 * @return Plugin An instance of the class.
617 */
618 public static function instance() {
619 if ( is_null( self::$instance ) ) {
620 self::$instance = new self();
621
622 /**
623 * Elementor loaded.
624 *
625 * Fires when Elementor was fully loaded and instantiated.
626 *
627 * @since 1.0.0
628 */
629 do_action( 'elementor/loaded' );
630 }
631
632 return self::$instance;
633 }
634
635 /**
636 * Init.
637 *
638 * Initialize Elementor Plugin. Register Elementor support for all the
639 * supported post types and initialize Elementor components.
640 *
641 * @since 1.0.0
642 * @access public
643 */
644 public function init() {
645 $this->add_cpt_support();
646
647 $this->init_components();
648
649 /**
650 * Elementor init.
651 *
652 * Fires when Elementor components are initialized.
653 *
654 * After Elementor finished loading but before any headers are sent.
655 *
656 * @since 1.0.0
657 */
658 do_action( 'elementor/init' );
659 }
660
661 /**
662 * Get install time.
663 *
664 * Retrieve the time when Elementor was installed.
665 *
666 * @since 2.6.0
667 * @access public
668 * @static
669 *
670 * @return int Unix timestamp when Elementor was installed.
671 */
672 public function get_install_time() {
673 $installed_time = get_option( '_elementor_installed_time' );
674
675 if ( ! $installed_time ) {
676 $installed_time = time();
677
678 update_option( '_elementor_installed_time', $installed_time );
679 }
680
681 return $installed_time;
682 }
683
684 /**
685 * @since 2.3.0
686 * @access public
687 */
688 public function on_rest_api_init() {
689 // On admin/frontend sometimes the rest API is initialized after the common is initialized.
690 if ( ! $this->common ) {
691 $this->init_common();
692 }
693 }
694
695 /**
696 * Init components.
697 *
698 * Initialize Elementor components. Register actions, run setting manager,
699 * initialize all the components that run elementor, and if in admin page
700 * initialize admin components.
701 *
702 * @since 1.0.0
703 * @access private
704 */
705 private function init_components() {
706 $this->experiments = new Experiments_Manager();
707 $this->breakpoints = new Breakpoints_Manager();
708 $this->inspector = new Inspector();
709
710 Settings_Manager::run();
711
712 $this->db = new DB();
713 $this->controls_manager = new Controls_Manager();
714 $this->documents = new Documents_Manager();
715 $this->kits_manager = new Kits_Manager();
716 $this->schemes_manager = new Schemes_Manager();
717 $this->elements_manager = new Elements_Manager();
718 $this->widgets_manager = new Widgets_Manager();
719 $this->skins_manager = new Skins_Manager();
720 $this->files_manager = new Files_Manager();
721 $this->assets_manager = new Assets_Manager();
722 $this->icons_manager = new Icons_Manager();
723 $this->settings = new Settings();
724 $this->tools = new Tools();
725 $this->editor = new Editor();
726 $this->preview = new Preview();
727 $this->frontend = new Frontend();
728 $this->maintenance_mode = new Maintenance_Mode();
729 $this->dynamic_tags = new Dynamic_Tags_Manager();
730 $this->modules_manager = new Modules_Manager();
731 $this->templates_manager = new TemplateLibrary\Manager();
732 $this->role_manager = new Core\RoleManager\Role_Manager();
733 $this->system_info = new System_Info_Module();
734 $this->revisions_manager = new Revisions_Manager();
735 $this->images_manager = new Images_Manager();
736 $this->wp = new Wp_Api();
737 $this->assets_loader = new Assets_Loader();
738 $this->uploads_manager = new Uploads_Manager();
739
740 $this->admin_menu_manager = new Admin_Menu_Manager();
741 $this->admin_menu_manager->register_actions();
742
743 User::init();
744 Api::init();
745 Tracker::init();
746
747 $this->upgrade = new Core\Upgrade\Manager();
748 $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
749
750 $this->app = new App\App();
751
752 if ( is_admin() ) {
753 $this->heartbeat = new Heartbeat();
754 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
755 $this->admin = new Admin();
756 $this->beta_testers = new Beta_Testers();
757 }
758 }
759
760 /**
761 * @since 2.3.0
762 * @access public
763 */
764 public function init_common() {
765 $this->common = new CommonApp();
766
767 $this->common->init_components();
768 }
769
770 /**
771 * Add custom post type support.
772 *
773 * Register Elementor support for all the supported post types defined by
774 * the user in the admin screen and saved as `elementor_cpt_support` option
775 * in WordPress `$wpdb->options` table.
776 *
777 * If no custom post type selected, usually in new installs, this method
778 * will return the two default post types: `page` and `post`.
779 *
780 * @since 1.0.0
781 * @access private
782 */
783 private function add_cpt_support() {
784 $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
785
786 foreach ( $cpt_support as $cpt_slug ) {
787 add_post_type_support( $cpt_slug, 'elementor' );
788 }
789 }
790
791 /**
792 * Register autoloader.
793 *
794 * Elementor autoloader loads all the classes needed to run the plugin.
795 *
796 * @since 1.6.0
797 * @access private
798 */
799 private function register_autoloader() {
800 require_once ELEMENTOR_PATH . '/includes/autoloader.php';
801
802 Autoloader::run();
803 }
804
805 /**
806 * Plugin Magic Getter
807 *
808 * @since 3.1.0
809 * @access public
810 *
811 * @param $property
812 * @return mixed
813 * @throws \Exception
814 */
815 public function __get( $property ) {
816 if ( 'posts_css_manager' === $property ) {
817 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
818
819 return $this->files_manager;
820 }
821
822 if ( 'data_manager' === $property ) {
823 return Data_Manager::instance();
824 }
825
826 if ( property_exists( $this, $property ) ) {
827 throw new \Exception( 'Cannot access private property.' );
828 }
829
830 return null;
831 }
832
833 /**
834 * Plugin constructor.
835 *
836 * Initializing Elementor plugin.
837 *
838 * @since 1.0.0
839 * @access private
840 */
841 private function __construct() {
842 $this->register_autoloader();
843
844 $this->logger = Log_Manager::instance();
845 $this->data_manager_v2 = Data_Manager_V2::instance();
846
847 Maintenance::init();
848 Compatibility::register_actions();
849
850 add_action( 'init', [ $this, 'init' ], 0 );
851 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
852 }
853
854 final public static function get_title() {
855 return esc_html__( 'Elementor', 'elementor' );
856 }
857 }
858
859 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
860 // In tests we run the instance manually.
861 Plugin::instance();
862 }
863