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

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