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

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