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

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