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

762 lines 14.1 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\Admin;
5 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 use Elementor\Core\Common\App as CommonApp;
7 use Elementor\Core\Debug\Inspector;
8 use Elementor\Core\Documents_Manager;
9 use Elementor\Core\Experiments\Manager as Experiments_Manager;
10 use Elementor\Core\Kits\Manager as Kits_Manager;
11 use Elementor\Core\Editor\Editor;
12 use Elementor\Core\Files\Manager as Files_Manager;
13 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
14 use Elementor\Core\Modules_Manager;
15 use Elementor\Core\Schemes\Manager as Schemes_Manager;
16 use Elementor\Core\Settings\Manager as Settings_Manager;
17 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
18 use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
19 use Elementor\Modules\History\Revisions_Manager;
20 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
21 use Elementor\Core\Logger\Manager as Log_Manager;
22 use Elementor\Modules\System_Info\Module as System_Info_Module;
23 use Elementor\Data\Manager as Data_Manager;
24 use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
25
26 if ( ! defined( 'ABSPATH' ) ) {
27 exit;
28 }
29
30 /**
31 * Elementor plugin.
32 *
33 * The main plugin handler class is responsible for initializing Elementor. The
34 * class registers and all the components required to run the plugin.
35 *
36 * @since 1.0.0
37 */
38 class Plugin {
39
40 /**
41 * Instance.
42 *
43 * Holds the plugin instance.
44 *
45 * @since 1.0.0
46 * @access public
47 * @static
48 *
49 * @var Plugin
50 */
51 public static $instance = null;
52
53 /**
54 * Database.
55 *
56 * Holds the plugin database.
57 *
58 * @since 1.0.0
59 * @access public
60 *
61 * @var DB
62 */
63 public $db;
64
65 /**
66 * Ajax Manager.
67 *
68 * Holds the plugin ajax manager.
69 *
70 * @since 1.9.0
71 * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
72 * @access public
73 *
74 * @var Ajax
75 */
76 public $ajax;
77
78 /**
79 * Controls manager.
80 *
81 * Holds the plugin controls manager.
82 *
83 * @since 1.0.0
84 * @access public
85 *
86 * @var Controls_Manager
87 */
88 public $controls_manager;
89
90 /**
91 * Documents manager.
92 *
93 * Holds the documents manager.
94 *
95 * @since 2.0.0
96 * @access public
97 *
98 * @var Documents_Manager
99 */
100 public $documents;
101
102 /**
103 * Schemes manager.
104 *
105 * Holds the plugin schemes manager.
106 *
107 * @since 1.0.0
108 * @access public
109 *
110 * @var Schemes_Manager
111 */
112 public $schemes_manager;
113
114 /**
115 * Elements manager.
116 *
117 * Holds the plugin elements manager.
118 *
119 * @since 1.0.0
120 * @access public
121 *
122 * @var Elements_Manager
123 */
124 public $elements_manager;
125
126 /**
127 * Widgets manager.
128 *
129 * Holds the plugin widgets manager.
130 *
131 * @since 1.0.0
132 * @access public
133 *
134 * @var Widgets_Manager
135 */
136 public $widgets_manager;
137
138 /**
139 * Revisions manager.
140 *
141 * Holds the plugin revisions manager.
142 *
143 * @since 1.0.0
144 * @access public
145 *
146 * @var Revisions_Manager
147 */
148 public $revisions_manager;
149
150 /**
151 * Images manager.
152 *
153 * Holds the plugin images manager.
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 plugin maintenance mode.
166 *
167 * @since 1.0.0
168 * @access public
169 *
170 * @var Maintenance_Mode
171 */
172 public $maintenance_mode;
173
174 /**
175 * Page settings manager.
176 *
177 * Holds the page settings manager.
178 *
179 * @since 1.0.0
180 * @access public
181 *
182 * @var Page_Settings_Manager
183 */
184 public $page_settings_manager;
185
186 /**
187 * Dynamic tags manager.
188 *
189 * Holds the dynamic tags manager.
190 *
191 * @since 1.0.0
192 * @access public
193 *
194 * @var Dynamic_Tags_Manager
195 */
196 public $dynamic_tags;
197
198 /**
199 * Settings.
200 *
201 * Holds the plugin settings.
202 *
203 * @since 1.0.0
204 * @access public
205 *
206 * @var Settings
207 */
208 public $settings;
209
210 /**
211 * Role Manager.
212 *
213 * Holds the plugin Role Manager
214 *
215 * @since 2.0.0
216 * @access public
217 *
218 * @var \Elementor\Core\RoleManager\Role_Manager
219 */
220 public $role_manager;
221
222 /**
223 * Admin.
224 *
225 * Holds the plugin admin.
226 *
227 * @since 1.0.0
228 * @access public
229 *
230 * @var Admin
231 */
232 public $admin;
233
234 /**
235 * Tools.
236 *
237 * Holds the plugin tools.
238 *
239 * @since 1.0.0
240 * @access public
241 *
242 * @var Tools
243 */
244 public $tools;
245
246 /**
247 * Preview.
248 *
249 * Holds the plugin preview.
250 *
251 * @since 1.0.0
252 * @access public
253 *
254 * @var Preview
255 */
256 public $preview;
257
258 /**
259 * Editor.
260 *
261 * Holds the plugin editor.
262 *
263 * @since 1.0.0
264 * @access public
265 *
266 * @var Editor
267 */
268 public $editor;
269
270 /**
271 * Frontend.
272 *
273 * Holds the plugin frontend.
274 *
275 * @since 1.0.0
276 * @access public
277 *
278 * @var Frontend
279 */
280 public $frontend;
281
282 /**
283 * Heartbeat.
284 *
285 * Holds the plugin heartbeat.
286 *
287 * @since 1.0.0
288 * @access public
289 *
290 * @var Heartbeat
291 */
292 public $heartbeat;
293
294 /**
295 * System info.
296 *
297 * Holds the system info data.
298 *
299 * @since 1.0.0
300 * @access public
301 *
302 * @var System_Info\Main
303 */
304 public $system_info;
305
306 /**
307 * Template library manager.
308 *
309 * Holds the template library manager.
310 *
311 * @since 1.0.0
312 * @access public
313 *
314 * @var TemplateLibrary\Manager
315 */
316 public $templates_manager;
317
318 /**
319 * Skins manager.
320 *
321 * Holds the skins manager.
322 *
323 * @since 1.0.0
324 * @access public
325 *
326 * @var Skins_Manager
327 */
328 public $skins_manager;
329
330 /**
331 * Files Manager.
332 *
333 * Holds the files manager.
334 *
335 * @since 2.1.0
336 * @access public
337 *
338 * @var Files_Manager
339 */
340 public $files_manager;
341
342 /**
343 * Assets Manager.
344 *
345 * Holds the Assets manager.
346 *
347 * @since 2.6.0
348 * @access public
349 *
350 * @var Assets_Manager
351 */
352 public $assets_manager;
353
354 /**
355 * Files Manager.
356 *
357 * Holds the files manager.
358 *
359 * @since 1.0.0
360 * @access public
361 * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
362 *
363 * @var Files_Manager
364 */
365 private $posts_css_manager;
366
367 /**
368 * WordPress widgets manager.
369 *
370 * Holds the WordPress widgets manager.
371 *
372 * @since 1.0.0
373 * @access public
374 *
375 * @var WordPress_Widgets_Manager
376 */
377 public $wordpress_widgets_manager;
378
379 /**
380 * Modules manager.
381 *
382 * Holds the modules manager.
383 *
384 * @since 1.0.0
385 * @access public
386 *
387 * @var Modules_Manager
388 */
389 public $modules_manager;
390
391 /**
392 * Beta testers.
393 *
394 * Holds the plugin beta testers.
395 *
396 * @since 1.0.0
397 * @access public
398 *
399 * @var Beta_Testers
400 */
401 public $beta_testers;
402
403 /**
404 * @var Inspector
405 * @deprecated 2.1.2 Use $inspector.
406 */
407 public $debugger;
408
409 /**
410 * @var Inspector
411 */
412 public $inspector;
413
414 /**
415 * @var CommonApp
416 */
417 public $common;
418
419 /**
420 * @var Log_Manager
421 */
422 public $logger;
423
424 /**
425 * @var Dev_Tools
426 */
427 private $dev_tools;
428
429 /**
430 * @var Core\Upgrade\Manager
431 */
432 public $upgrade;
433
434 /**
435 * @var Core\Kits\Manager
436 */
437 public $kits_manager;
438
439 /**
440 * @var \Core\Data\Manager
441 */
442 public $data_manager;
443
444 public $legacy_mode;
445
446 /**
447 * @var Core\App\App
448 */
449 public $app;
450
451 /**
452 * @var Experiments_Manager
453 */
454 public $experiments;
455
456 /**
457 * Clone.
458 *
459 * Disable class cloning and throw an error on object clone.
460 *
461 * The whole idea of the singleton design pattern is that there is a single
462 * object. Therefore, we don't want the object to be cloned.
463 *
464 * @access public
465 * @since 1.0.0
466 */
467 public function __clone() {
468 // Cloning instances of the class is forbidden.
469 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
470 }
471
472 /**
473 * Wakeup.
474 *
475 * Disable unserializing of the class.
476 *
477 * @access public
478 * @since 1.0.0
479 */
480 public function __wakeup() {
481 // Unserializing instances of the class is forbidden.
482 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
483 }
484
485 /**
486 * Instance.
487 *
488 * Ensures only one instance of the plugin class is loaded or can be loaded.
489 *
490 * @since 1.0.0
491 * @access public
492 * @static
493 *
494 * @return Plugin An instance of the class.
495 */
496 public static function instance() {
497 if ( is_null( self::$instance ) ) {
498 self::$instance = new self();
499
500 /**
501 * Elementor loaded.
502 *
503 * Fires when Elementor was fully loaded and instantiated.
504 *
505 * @since 1.0.0
506 */
507 do_action( 'elementor/loaded' );
508 }
509
510 return self::$instance;
511 }
512
513 /**
514 * Init.
515 *
516 * Initialize Elementor Plugin. Register Elementor support for all the
517 * supported post types and initialize Elementor components.
518 *
519 * @since 1.0.0
520 * @access public
521 */
522 public function init() {
523 $this->add_cpt_support();
524
525 $this->init_components();
526
527 /**
528 * Elementor init.
529 *
530 * Fires on Elementor init, after Elementor has finished loading but
531 * before any headers are sent.
532 *
533 * @since 1.0.0
534 */
535 do_action( 'elementor/init' );
536 }
537
538 /**
539 * Get install time.
540 *
541 * Retrieve the time when Elementor was installed.
542 *
543 * @since 2.6.0
544 * @access public
545 * @static
546 *
547 * @return int Unix timestamp when Elementor was installed.
548 */
549 public function get_install_time() {
550 $installed_time = get_option( '_elementor_installed_time' );
551
552 if ( ! $installed_time ) {
553 $installed_time = time();
554
555 update_option( '_elementor_installed_time', $installed_time );
556 }
557
558 return $installed_time;
559 }
560
561 /**
562 * @since 2.3.0
563 * @access public
564 */
565 public function on_rest_api_init() {
566 // On admin/frontend sometimes the rest API is initialized after the common is initialized.
567 if ( ! $this->common ) {
568 $this->init_common();
569 }
570 }
571
572 /**
573 * Init components.
574 *
575 * Initialize Elementor components. Register actions, run setting manager,
576 * initialize all the components that run elementor, and if in admin page
577 * initialize admin components.
578 *
579 * @since 1.0.0
580 * @access private
581 */
582 private function init_components() {
583 $this->experiments = new Experiments_Manager();
584 $this->inspector = new Inspector();
585 $this->debugger = $this->inspector;
586
587 Settings_Manager::run();
588
589 $this->db = new DB();
590 $this->controls_manager = new Controls_Manager();
591 $this->documents = new Documents_Manager();
592 $this->kits_manager = new Kits_Manager();
593 $this->schemes_manager = new Schemes_Manager();
594 $this->elements_manager = new Elements_Manager();
595 $this->widgets_manager = new Widgets_Manager();
596 $this->skins_manager = new Skins_Manager();
597 $this->files_manager = new Files_Manager();
598 $this->assets_manager = new Assets_Manager();
599 $this->icons_manager = new Icons_Manager();
600 $this->settings = new Settings();
601 $this->tools = new Tools();
602 $this->editor = new Editor();
603 $this->preview = new Preview();
604 $this->frontend = new Frontend();
605 $this->templates_manager = new TemplateLibrary\Manager();
606 $this->maintenance_mode = new Maintenance_Mode();
607 $this->dynamic_tags = new Dynamic_Tags_Manager();
608 $this->modules_manager = new Modules_Manager();
609 $this->role_manager = new Core\RoleManager\Role_Manager();
610 $this->system_info = new System_Info_Module();
611 $this->revisions_manager = new Revisions_Manager();
612 $this->images_manager = new Images_Manager();
613
614 User::init();
615 Api::init();
616 Tracker::init();
617
618 $this->upgrade = new Core\Upgrade\Manager();
619
620 $this->app = new Core\App\App();
621
622 if ( is_admin() ) {
623 $this->heartbeat = new Heartbeat();
624 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
625 $this->admin = new Admin();
626 $this->beta_testers = new Beta_Testers();
627 new Elementor_3_Re_Migrate_Globals();
628 }
629 }
630
631 /**
632 * @since 2.3.0
633 * @access public
634 */
635 public function init_common() {
636 $this->common = new CommonApp();
637
638 $this->common->init_components();
639
640 $this->ajax = $this->common->get_component( 'ajax' );
641 }
642
643 /**
644 * Get Legacy Mode
645 *
646 * @since 3.0.0
647 * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
648 *
649 * @param string $mode_name Optional. Default is null
650 *
651 * @return bool|bool[]
652 */
653 public function get_legacy_mode( $mode_name = null ) {
654 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
655 ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
656
657 $legacy_mode = [
658 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
659 ];
660
661 if ( ! $mode_name ) {
662 return $legacy_mode;
663 }
664
665 if ( isset( $legacy_mode[ $mode_name ] ) ) {
666 return $legacy_mode[ $mode_name ];
667 }
668
669 // If there is no legacy mode with the given mode name;
670 return false;
671 }
672
673 /**
674 * Add custom post type support.
675 *
676 * Register Elementor support for all the supported post types defined by
677 * the user in the admin screen and saved as `elementor_cpt_support` option
678 * in WordPress `$wpdb->options` table.
679 *
680 * If no custom post type selected, usually in new installs, this method
681 * will return the two default post types: `page` and `post`.
682 *
683 * @since 1.0.0
684 * @access private
685 */
686 private function add_cpt_support() {
687 $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
688
689 foreach ( $cpt_support as $cpt_slug ) {
690 add_post_type_support( $cpt_slug, 'elementor' );
691 }
692 }
693
694 /**
695 * Register autoloader.
696 *
697 * Elementor autoloader loads all the classes needed to run the plugin.
698 *
699 * @since 1.6.0
700 * @access private
701 */
702 private function register_autoloader() {
703 require_once ELEMENTOR_PATH . '/includes/autoloader.php';
704
705 Autoloader::run();
706 }
707
708 /**
709 * Plugin Magic Getter
710 *
711 * @since 3.1.0
712 * @access public
713 *
714 * @param $property
715 * @return mixed
716 * @throws \Exception
717 */
718 public function __get( $property ) {
719 if ( 'posts_css_manager' === $property ) {
720 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
721
722 return $this->files_manager;
723 }
724
725 if ( property_exists( $this, $property ) ) {
726 throw new \Exception( 'Cannot access private property' );
727 }
728
729 return null;
730 }
731
732 /**
733 * Plugin constructor.
734 *
735 * Initializing Elementor plugin.
736 *
737 * @since 1.0.0
738 * @access private
739 */
740 private function __construct() {
741 $this->register_autoloader();
742
743 $this->logger = Log_Manager::instance();
744 $this->data_manager = Data_Manager::instance();
745
746 Maintenance::init();
747 Compatibility::register_actions();
748
749 add_action( 'init', [ $this, 'init' ], 0 );
750 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
751 }
752
753 final public static function get_title() {
754 return __( 'Elementor', 'elementor' );
755 }
756 }
757
758 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
759 // In tests we run the instance manually.
760 Plugin::instance();
761 }
762