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

756 lines 14.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\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
25 if ( ! defined( 'ABSPATH' ) ) {
26 exit;
27 }
28
29 /**
30 * Elementor plugin.
31 *
32 * The main plugin handler class is responsible for initializing Elementor. The
33 * class registers and all the components required to run the plugin.
34 *
35 * @since 1.0.0
36 */
37 class Plugin {
38
39 /**
40 * Instance.
41 *
42 * Holds the plugin instance.
43 *
44 * @since 1.0.0
45 * @access public
46 * @static
47 *
48 * @var Plugin
49 */
50 public static $instance = null;
51
52 /**
53 * Database.
54 *
55 * Holds the plugin database.
56 *
57 * @since 1.0.0
58 * @access public
59 *
60 * @var DB
61 */
62 public $db;
63
64 /**
65 * Ajax Manager.
66 *
67 * Holds the plugin ajax manager.
68 *
69 * @since 1.9.0
70 * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
71 * @access public
72 *
73 * @var Ajax
74 */
75 public $ajax;
76
77 /**
78 * Controls manager.
79 *
80 * Holds the plugin controls manager.
81 *
82 * @since 1.0.0
83 * @access public
84 *
85 * @var Controls_Manager
86 */
87 public $controls_manager;
88
89 /**
90 * Documents manager.
91 *
92 * Holds the documents manager.
93 *
94 * @since 2.0.0
95 * @access public
96 *
97 * @var Documents_Manager
98 */
99 public $documents;
100
101 /**
102 * Schemes manager.
103 *
104 * Holds the plugin schemes manager.
105 *
106 * @since 1.0.0
107 * @access public
108 *
109 * @var Schemes_Manager
110 */
111 public $schemes_manager;
112
113 /**
114 * Elements manager.
115 *
116 * Holds the plugin elements manager.
117 *
118 * @since 1.0.0
119 * @access public
120 *
121 * @var Elements_Manager
122 */
123 public $elements_manager;
124
125 /**
126 * Widgets manager.
127 *
128 * Holds the plugin widgets manager.
129 *
130 * @since 1.0.0
131 * @access public
132 *
133 * @var Widgets_Manager
134 */
135 public $widgets_manager;
136
137 /**
138 * Revisions manager.
139 *
140 * Holds the plugin revisions manager.
141 *
142 * @since 1.0.0
143 * @access public
144 *
145 * @var Revisions_Manager
146 */
147 public $revisions_manager;
148
149 /**
150 * Images manager.
151 *
152 * Holds the plugin images manager.
153 *
154 * @since 2.9.0
155 * @access public
156 *
157 * @var Images_Manager
158 */
159 public $images_manager;
160
161 /**
162 * Maintenance mode.
163 *
164 * Holds the plugin maintenance mode.
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 \Elementor\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\Main
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 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 Assets manager.
345 *
346 * @since 2.6.0
347 * @access public
348 *
349 * @var Assets_Manager
350 */
351 public $assets_manager;
352
353 /**
354 * Files Manager.
355 *
356 * Holds the files manager.
357 *
358 * @since 1.0.0
359 * @access public
360 * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
361 *
362 * @var Files_Manager
363 */
364 private $posts_css_manager;
365
366 /**
367 * WordPress widgets manager.
368 *
369 * Holds the WordPress widgets manager.
370 *
371 * @since 1.0.0
372 * @access public
373 *
374 * @var WordPress_Widgets_Manager
375 */
376 public $wordpress_widgets_manager;
377
378 /**
379 * Modules manager.
380 *
381 * Holds the modules manager.
382 *
383 * @since 1.0.0
384 * @access public
385 *
386 * @var Modules_Manager
387 */
388 public $modules_manager;
389
390 /**
391 * Beta testers.
392 *
393 * Holds the plugin beta testers.
394 *
395 * @since 1.0.0
396 * @access public
397 *
398 * @var Beta_Testers
399 */
400 public $beta_testers;
401
402 /**
403 * @var Inspector
404 * @deprecated 2.1.2 Use $inspector.
405 */
406 public $debugger;
407
408 /**
409 * @var Inspector
410 */
411 public $inspector;
412
413 /**
414 * @var CommonApp
415 */
416 public $common;
417
418 /**
419 * @var Log_Manager
420 */
421 public $logger;
422
423 /**
424 * @var Core\Upgrade\Manager
425 */
426 public $upgrade;
427
428 /**
429 * @var Core\Kits\Manager
430 */
431 public $kits_manager;
432
433 /**
434 * @var \Core\Data\Manager
435 */
436 public $data_manager;
437
438 public $legacy_mode;
439
440 /**
441 * @var Core\App\App
442 */
443 public $app;
444
445 /**
446 * @var Experiments_Manager
447 */
448 public $experiments;
449
450 /**
451 * Clone.
452 *
453 * Disable class cloning and throw an error on object clone.
454 *
455 * The whole idea of the singleton design pattern is that there is a single
456 * object. Therefore, we don't want the object to be cloned.
457 *
458 * @access public
459 * @since 1.0.0
460 */
461 public function __clone() {
462 // Cloning instances of the class is forbidden.
463 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
464 }
465
466 /**
467 * Wakeup.
468 *
469 * Disable unserializing of the class.
470 *
471 * @access public
472 * @since 1.0.0
473 */
474 public function __wakeup() {
475 // Unserializing instances of the class is forbidden.
476 _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
477 }
478
479 /**
480 * Instance.
481 *
482 * Ensures only one instance of the plugin class is loaded or can be loaded.
483 *
484 * @since 1.0.0
485 * @access public
486 * @static
487 *
488 * @return Plugin An instance of the class.
489 */
490 public static function instance() {
491 if ( is_null( self::$instance ) ) {
492 self::$instance = new self();
493
494 /**
495 * Elementor loaded.
496 *
497 * Fires when Elementor was fully loaded and instantiated.
498 *
499 * @since 1.0.0
500 */
501 do_action( 'elementor/loaded' );
502 }
503
504 return self::$instance;
505 }
506
507 /**
508 * Init.
509 *
510 * Initialize Elementor Plugin. Register Elementor support for all the
511 * supported post types and initialize Elementor components.
512 *
513 * @since 1.0.0
514 * @access public
515 */
516 public function init() {
517 $this->add_cpt_support();
518
519 $this->init_components();
520
521 /**
522 * Elementor init.
523 *
524 * Fires on Elementor init, after Elementor has finished loading but
525 * before any headers are sent.
526 *
527 * @since 1.0.0
528 */
529 do_action( 'elementor/init' );
530 }
531
532 /**
533 * Get install time.
534 *
535 * Retrieve the time when Elementor was installed.
536 *
537 * @since 2.6.0
538 * @access public
539 * @static
540 *
541 * @return int Unix timestamp when Elementor was installed.
542 */
543 public function get_install_time() {
544 $installed_time = get_option( '_elementor_installed_time' );
545
546 if ( ! $installed_time ) {
547 $installed_time = time();
548
549 update_option( '_elementor_installed_time', $installed_time );
550 }
551
552 return $installed_time;
553 }
554
555 /**
556 * @since 2.3.0
557 * @access public
558 */
559 public function on_rest_api_init() {
560 // On admin/frontend sometimes the rest API is initialized after the common is initialized.
561 if ( ! $this->common ) {
562 $this->init_common();
563 }
564 }
565
566 /**
567 * Init components.
568 *
569 * Initialize Elementor components. Register actions, run setting manager,
570 * initialize all the components that run elementor, and if in admin page
571 * initialize admin components.
572 *
573 * @since 1.0.0
574 * @access private
575 */
576 private function init_components() {
577 $this->experiments = new Experiments_Manager();
578 $this->inspector = new Inspector();
579 $this->debugger = $this->inspector;
580
581 Settings_Manager::run();
582
583 $this->db = new DB();
584 $this->controls_manager = new Controls_Manager();
585 $this->documents = new Documents_Manager();
586 $this->kits_manager = new Kits_Manager();
587 $this->schemes_manager = new Schemes_Manager();
588 $this->elements_manager = new Elements_Manager();
589 $this->widgets_manager = new Widgets_Manager();
590 $this->skins_manager = new Skins_Manager();
591 $this->files_manager = new Files_Manager();
592 $this->assets_manager = new Assets_Manager();
593 $this->icons_manager = new Icons_Manager();
594 $this->settings = new Settings();
595 $this->tools = new Tools();
596 $this->editor = new Editor();
597 $this->preview = new Preview();
598 $this->frontend = new Frontend();
599 $this->templates_manager = new TemplateLibrary\Manager();
600 $this->maintenance_mode = new Maintenance_Mode();
601 $this->dynamic_tags = new Dynamic_Tags_Manager();
602 $this->modules_manager = new Modules_Manager();
603 $this->role_manager = new Core\RoleManager\Role_Manager();
604 $this->system_info = new System_Info_Module();
605 $this->revisions_manager = new Revisions_Manager();
606 $this->images_manager = new Images_Manager();
607
608 User::init();
609 Api::init();
610 Tracker::init();
611
612 $this->upgrade = new Core\Upgrade\Manager();
613
614 $this->app = new Core\App\App();
615
616 if ( is_admin() ) {
617 $this->heartbeat = new Heartbeat();
618 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
619 $this->admin = new Admin();
620 $this->beta_testers = new Beta_Testers();
621 new Elementor_3_Re_Migrate_Globals();
622 }
623 }
624
625 /**
626 * @since 2.3.0
627 * @access public
628 */
629 public function init_common() {
630 $this->common = new CommonApp();
631
632 $this->common->init_components();
633
634 $this->ajax = $this->common->get_component( 'ajax' );
635 }
636
637 /**
638 * Get Legacy Mode
639 *
640 * @since 3.0.0
641 * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
642 *
643 * @param string $mode_name Optional. Default is null
644 *
645 * @return bool|bool[]
646 */
647 public function get_legacy_mode( $mode_name = null ) {
648 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
649 ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
650
651 $legacy_mode = [
652 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
653 ];
654
655 if ( ! $mode_name ) {
656 return $legacy_mode;
657 }
658
659 if ( isset( $legacy_mode[ $mode_name ] ) ) {
660 return $legacy_mode[ $mode_name ];
661 }
662
663 // If there is no legacy mode with the given mode name;
664 return false;
665 }
666
667 /**
668 * Add custom post type support.
669 *
670 * Register Elementor support for all the supported post types defined by
671 * the user in the admin screen and saved as `elementor_cpt_support` option
672 * in WordPress `$wpdb->options` table.
673 *
674 * If no custom post type selected, usually in new installs, this method
675 * will return the two default post types: `page` and `post`.
676 *
677 * @since 1.0.0
678 * @access private
679 */
680 private function add_cpt_support() {
681 $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
682
683 foreach ( $cpt_support as $cpt_slug ) {
684 add_post_type_support( $cpt_slug, 'elementor' );
685 }
686 }
687
688 /**
689 * Register autoloader.
690 *
691 * Elementor autoloader loads all the classes needed to run the plugin.
692 *
693 * @since 1.6.0
694 * @access private
695 */
696 private function register_autoloader() {
697 require_once ELEMENTOR_PATH . '/includes/autoloader.php';
698
699 Autoloader::run();
700 }
701
702 /**
703 * Plugin Magic Getter
704 *
705 * @since 3.1.0
706 * @access public
707 *
708 * @param $property
709 * @return mixed
710 * @throws \Exception
711 */
712 public function __get( $property ) {
713 if ( 'posts_css_manager' === $property ) {
714 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
715
716 return $this->files_manager;
717 }
718
719 if ( property_exists( $this, $property ) ) {
720 throw new \Exception( 'Cannot access private property' );
721 }
722
723 return null;
724 }
725
726 /**
727 * Plugin constructor.
728 *
729 * Initializing Elementor plugin.
730 *
731 * @since 1.0.0
732 * @access private
733 */
734 private function __construct() {
735 $this->register_autoloader();
736
737 $this->logger = Log_Manager::instance();
738 $this->data_manager = Data_Manager::instance();
739
740 Maintenance::init();
741 Compatibility::register_actions();
742
743 add_action( 'init', [ $this, 'init' ], 0 );
744 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
745 }
746
747 final public static function get_title() {
748 return __( 'Elementor', 'elementor' );
749 }
750 }
751
752 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
753 // In tests we run the instance manually.
754 Plugin::instance();
755 }
756