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

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