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

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