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

888 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\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\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\Data\V2\Manager as Data_Manager_V2;
28 use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
29 use Elementor\Core\Files\Uploads_Manager as Uploads_Manager;
30
31 if ( ! defined( 'ABSPATH' ) ) {
32 exit;
33 }
34
35 /**
36 * Elementor plugin.
37 *
38 * The main plugin handler class is responsible for initializing Elementor. The
39 * class registers and all the components required to run the plugin.
40 *
41 * @since 1.0.0
42 */
43 class Plugin {
44 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45
46 /**
47 * Instance.
48 *
49 * Holds the plugin instance.
50 *
51 * @since 1.0.0
52 * @access public
53 * @static
54 *
55 * @var Plugin
56 */
57 public static $instance = null;
58
59 /**
60 * Database.
61 *
62 * Holds the plugin database handler which is responsible for communicating
63 * with the database.
64 *
65 * @since 1.0.0
66 * @access public
67 *
68 * @var DB
69 */
70 public $db;
71
72 /**
73 * Controls manager.
74 *
75 * Holds the plugin controls manager handler is responsible for registering
76 * and initializing controls.
77 *
78 * @since 1.0.0
79 * @access public
80 *
81 * @var Controls_Manager
82 */
83 public $controls_manager;
84
85 /**
86 * Documents manager.
87 *
88 * Holds the documents manager.
89 *
90 * @since 2.0.0
91 * @access public
92 *
93 * @var Documents_Manager
94 */
95 public $documents;
96
97 /**
98 * Schemes manager.
99 *
100 * Holds the plugin schemes manager.
101 *
102 * @since 1.0.0
103 * @access public
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 Core\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 // Cloning instances of the class is forbidden.
585 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
586 }
587
588 /**
589 * Wakeup.
590 *
591 * Disable unserializing of the class.
592 *
593 * @access public
594 * @since 1.0.0
595 */
596 public function __wakeup() {
597 // Unserializing instances of the class is forbidden.
598 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
599 }
600
601 /**
602 * Instance.
603 *
604 * Ensures only one instance of the plugin class is loaded or can be loaded.
605 *
606 * @since 1.0.0
607 * @access public
608 * @static
609 *
610 * @return Plugin An instance of the class.
611 */
612 public static function instance() {
613 if ( is_null( self::$instance ) ) {
614 self::$instance = new self();
615
616 /**
617 * Elementor loaded.
618 *
619 * Fires when Elementor was fully loaded and instantiated.
620 *
621 * @since 1.0.0
622 */
623 do_action( 'elementor/loaded' );
624 }
625
626 return self::$instance;
627 }
628
629 /**
630 * Init.
631 *
632 * Initialize Elementor Plugin. Register Elementor support for all the
633 * supported post types and initialize Elementor components.
634 *
635 * @since 1.0.0
636 * @access public
637 */
638 public function init() {
639 $this->add_cpt_support();
640
641 $this->init_components();
642
643 /**
644 * Elementor init.
645 *
646 * Fires when Elementor components are initialized.
647 *
648 * After Elementor finished loading but before any headers are sent.
649 *
650 * @since 1.0.0
651 */
652 do_action( 'elementor/init' );
653 }
654
655 /**
656 * Get install time.
657 *
658 * Retrieve the time when Elementor was installed.
659 *
660 * @since 2.6.0
661 * @access public
662 * @static
663 *
664 * @return int Unix timestamp when Elementor was installed.
665 */
666 public function get_install_time() {
667 $installed_time = get_option( '_elementor_installed_time' );
668
669 if ( ! $installed_time ) {
670 $installed_time = time();
671
672 update_option( '_elementor_installed_time', $installed_time );
673 }
674
675 return $installed_time;
676 }
677
678 /**
679 * @since 2.3.0
680 * @access public
681 */
682 public function on_rest_api_init() {
683 // On admin/frontend sometimes the rest API is initialized after the common is initialized.
684 if ( ! $this->common ) {
685 $this->init_common();
686 }
687 }
688
689 /**
690 * Init components.
691 *
692 * Initialize Elementor components. Register actions, run setting manager,
693 * initialize all the components that run elementor, and if in admin page
694 * initialize admin components.
695 *
696 * @since 1.0.0
697 * @access private
698 */
699 private function init_components() {
700 $this->experiments = new Experiments_Manager();
701 $this->breakpoints = new Breakpoints_Manager();
702 $this->inspector = new Inspector();
703
704 Settings_Manager::run();
705
706 $this->db = new DB();
707 $this->controls_manager = new Controls_Manager();
708 $this->documents = new Documents_Manager();
709 $this->kits_manager = new Kits_Manager();
710 $this->schemes_manager = new Schemes_Manager();
711 $this->elements_manager = new Elements_Manager();
712 $this->widgets_manager = new Widgets_Manager();
713 $this->skins_manager = new Skins_Manager();
714 $this->files_manager = new Files_Manager();
715 $this->assets_manager = new Assets_Manager();
716 $this->icons_manager = new Icons_Manager();
717 $this->settings = new Settings();
718 $this->tools = new Tools();
719 $this->editor = new Editor();
720 $this->preview = new Preview();
721 $this->frontend = new Frontend();
722 $this->maintenance_mode = new Maintenance_Mode();
723 $this->dynamic_tags = new Dynamic_Tags_Manager();
724 $this->modules_manager = new Modules_Manager();
725 $this->templates_manager = new TemplateLibrary\Manager();
726 $this->role_manager = new Core\RoleManager\Role_Manager();
727 $this->system_info = new System_Info_Module();
728 $this->revisions_manager = new Revisions_Manager();
729 $this->images_manager = new Images_Manager();
730 $this->wp = new Wp_Api();
731 $this->assets_loader = new Assets_Loader();
732 $this->uploads_manager = new Uploads_Manager();
733
734 $this->admin_menu_manager = new Admin_Menu_Manager();
735 $this->admin_menu_manager->register_actions();
736
737 User::init();
738 Api::init();
739 Tracker::init();
740
741 $this->upgrade = new Core\Upgrade\Manager();
742 $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
743
744 $this->app = new Core\App\App();
745
746 if ( is_admin() ) {
747 $this->heartbeat = new Heartbeat();
748 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
749 $this->admin = new Admin();
750 $this->beta_testers = new Beta_Testers();
751 new Elementor_3_Re_Migrate_Globals();
752 }
753 }
754
755 /**
756 * @since 2.3.0
757 * @access public
758 */
759 public function init_common() {
760 $this->common = new CommonApp();
761
762 $this->common->init_components();
763 }
764
765 /**
766 * Get Legacy Mode
767 *
768 * @since 3.0.0
769 * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
770 *
771 * @param string $mode_name Optional. Default is null
772 *
773 * @return bool|bool[]
774 */
775 public function get_legacy_mode( $mode_name = null ) {
776 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
777 ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
778
779 $legacy_mode = [
780 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
781 ];
782
783 if ( ! $mode_name ) {
784 return $legacy_mode;
785 }
786
787 if ( isset( $legacy_mode[ $mode_name ] ) ) {
788 return $legacy_mode[ $mode_name ];
789 }
790
791 // If there is no legacy mode with the given mode name;
792 return false;
793 }
794
795 /**
796 * Add custom post type support.
797 *
798 * Register Elementor support for all the supported post types defined by
799 * the user in the admin screen and saved as `elementor_cpt_support` option
800 * in WordPress `$wpdb->options` table.
801 *
802 * If no custom post type selected, usually in new installs, this method
803 * will return the two default post types: `page` and `post`.
804 *
805 * @since 1.0.0
806 * @access private
807 */
808 private function add_cpt_support() {
809 $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
810
811 foreach ( $cpt_support as $cpt_slug ) {
812 add_post_type_support( $cpt_slug, 'elementor' );
813 }
814 }
815
816 /**
817 * Register autoloader.
818 *
819 * Elementor autoloader loads all the classes needed to run the plugin.
820 *
821 * @since 1.6.0
822 * @access private
823 */
824 private function register_autoloader() {
825 require_once ELEMENTOR_PATH . '/includes/autoloader.php';
826
827 Autoloader::run();
828 }
829
830 /**
831 * Plugin Magic Getter
832 *
833 * @since 3.1.0
834 * @access public
835 *
836 * @param $property
837 * @return mixed
838 * @throws \Exception
839 */
840 public function __get( $property ) {
841 if ( 'posts_css_manager' === $property ) {
842 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
843
844 return $this->files_manager;
845 }
846
847 if ( 'data_manager' === $property ) {
848 return Data_Manager::instance();
849 }
850
851 if ( property_exists( $this, $property ) ) {
852 throw new \Exception( 'Cannot access private property' );
853 }
854
855 return null;
856 }
857
858 /**
859 * Plugin constructor.
860 *
861 * Initializing Elementor plugin.
862 *
863 * @since 1.0.0
864 * @access private
865 */
866 private function __construct() {
867 $this->register_autoloader();
868
869 $this->logger = Log_Manager::instance();
870 $this->data_manager_v2 = Data_Manager_V2::instance();
871
872 Maintenance::init();
873 Compatibility::register_actions();
874
875 add_action( 'init', [ $this, 'init' ], 0 );
876 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
877 }
878
879 final public static function get_title() {
880 return esc_html__( 'Elementor', 'elementor' );
881 }
882 }
883
884 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
885 // In tests we run the instance manually.
886 Plugin::instance();
887 }
888