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

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