PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.1
Elementor Website Builder – more than just a page builder v3.0.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
← All changes | includes/plugin.php +102 -257 4.2.0-dev23.0.1 View file →
@@ -1,32 +1,26 @@
1 1 <?php
2 -
3 2 namespace Elementor;
4 3
5 -use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 -use Elementor\Core\Wp_Api;
7 4 use Elementor\Core\Admin\Admin;
8 -use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
9 6 use Elementor\Core\Common\App as CommonApp;
10 7 use Elementor\Core\Debug\Inspector;
11 8 use Elementor\Core\Documents_Manager;
12 -use Elementor\Core\Experiments\Manager as Experiments_Manager;
13 9 use Elementor\Core\Kits\Manager as Kits_Manager;
14 10 use Elementor\Core\Editor\Editor;
15 11 use Elementor\Core\Files\Manager as Files_Manager;
16 12 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 13 use Elementor\Core\Modules_Manager;
14 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 15 use Elementor\Core\Settings\Manager as Settings_Manager;
19 16 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
17 +use Elementor\Core\Upgrade\Manager as Upgrades_Manager;
20 18 use Elementor\Modules\History\Revisions_Manager;
21 19 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 20 use Elementor\Core\Logger\Manager as Log_Manager;
23 -use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 21 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 22 use Elementor\Data\Manager as Data_Manager;
26 -use Elementor\Data\V2\Manager as Data_Manager_V2;
27 -use Elementor\Core\Files\Uploads_Manager;
28 -use WP_REST_Request;
29 23
30 24 if ( ! defined( 'ABSPATH' ) ) {
31 25 exit;
32 26 }
@@ -40,16 +34,8 @@
40 34 * @since 1.0.0
41 35 */
42 36 class Plugin {
43 37
44 - const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 -
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - '_elementor_global_class_data',
50 - ];
51 -
52 38 /**
53 39 * Instance.
54 40 *
55 41 * Holds the plugin instance.
@@ -64,10 +50,9 @@
64 50
65 51 /**
66 52 * Database.
67 53 *
68 - * Holds the plugin database handler which is responsible for communicating
69 - * with the database.
54 + * Holds the plugin database.
70 55 *
71 56 * @since 1.0.0
72 57 * @access public
73 58 *
@@ -75,12 +60,24 @@
75 60 */
76 61 public $db;
77 62
78 63 /**
64 + * Ajax Manager.
65 + *
66 + * Holds the plugin ajax manager.
67 + *
68 + * @since 1.9.0
69 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
70 + * @access public
71 + *
72 + * @var Ajax
73 + */
74 + public $ajax;
75 +
76 + /**
79 77 * Controls manager.
80 78 *
81 - * Holds the plugin controls manager handler is responsible for registering
82 - * and initializing controls.
79 + * Holds the plugin controls manager.
83 80 *
84 81 * @since 1.0.0
85 82 * @access public
86 83 *
@@ -100,8 +97,20 @@
100 97 */
101 98 public $documents;
102 99
103 100 /**
101 + * Schemes manager.
102 + *
103 + * Holds the plugin schemes manager.
104 + *
105 + * @since 1.0.0
106 + * @access public
107 + *
108 + * @var Schemes_Manager
109 + */
110 + public $schemes_manager;
111 +
112 + /**
104 113 * Elements manager.
105 114 *
106 115 * Holds the plugin elements manager.
107 116 *
@@ -114,10 +123,9 @@
114 123
115 124 /**
116 125 * Widgets manager.
117 126 *
118 - * Holds the plugin widgets manager which is responsible for registering and
119 - * initializing widgets.
127 + * Holds the plugin widgets manager.
120 128 *
121 129 * @since 1.0.0
122 130 * @access public
123 131 *
@@ -127,10 +135,9 @@
127 135
128 136 /**
129 137 * Revisions manager.
130 138 *
131 - * Holds the plugin revisions manager which handles history and revisions
132 - * functionality.
139 + * Holds the plugin revisions manager.
133 140 *
134 141 * @since 1.0.0
135 142 * @access public
136 143 *
@@ -140,10 +147,9 @@
140 147
141 148 /**
142 149 * Images manager.
143 150 *
144 - * Holds the plugin images manager which is responsible for retrieving image
145 - * details.
151 + * Holds the plugin images manager.
146 152 *
147 153 * @since 2.9.0
148 154 * @access public
149 155 *
@@ -153,10 +159,9 @@
153 159
154 160 /**
155 161 * Maintenance mode.
156 162 *
157 - * Holds the maintenance mode manager responsible for the "Maintenance Mode"
158 - * and the "Coming Soon" features.
163 + * Holds the plugin maintenance mode.
159 164 *
160 165 * @since 1.0.0
161 166 * @access public
162 167 *
@@ -202,14 +207,14 @@
202 207
203 208 /**
204 209 * Role Manager.
205 210 *
206 - * Holds the plugin role manager.
211 + * Holds the plugin Role Manager
207 212 *
208 213 * @since 2.0.0
209 214 * @access public
210 215 *
211 - * @var Core\RoleManager\Role_Manager
216 + * @var \Elementor\Core\RoleManager\Role_Manager
212 217 */
213 218 public $role_manager;
214 219
215 220 /**
@@ -291,9 +296,9 @@
291 296 *
292 297 * @since 1.0.0
293 298 * @access public
294 299 *
295 - * @var System_Info_Module
300 + * @var System_Info\Main
296 301 */
297 302 public $system_info;
298 303
299 304 /**
@@ -320,11 +325,11 @@
320 325 */
321 326 public $skins_manager;
322 327
323 328 /**
324 - * Files manager.
329 + * Files Manager.
325 330 *
326 - * Holds the plugin files manager.
331 + * Holds the files manager.
327 332 *
328 333 * @since 2.1.0
329 334 * @access public
330 335 *
@@ -332,11 +337,11 @@
332 337 */
333 338 public $files_manager;
334 339
335 340 /**
336 - * Assets manager.
341 + * Assets Manager.
337 342 *
338 - * Holds the plugin assets manager.
343 + * Holds the Assets manager.
339 344 *
340 345 * @since 2.6.0
341 346 * @access public
342 347 *
@@ -344,17 +349,19 @@
344 349 */
345 350 public $assets_manager;
346 351
347 352 /**
348 - * Icons Manager.
353 + * Files Manager.
349 354 *
350 - * Holds the plugin icons manager.
355 + * Holds the files manager.
351 356 *
357 + * @since 1.0.0
352 358 * @access public
359 + * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
353 360 *
354 - * @var Icons_Manager
361 + * @var Files_Manager
355 362 */
356 - public $icons_manager;
363 + public $posts_css_manager;
357 364
358 365 /**
359 366 * WordPress widgets manager.
360 367 *
@@ -369,9 +376,9 @@
369 376
370 377 /**
371 378 * Modules manager.
372 379 *
373 - * Holds the plugin modules manager.
380 + * Holds the modules manager.
374 381 *
375 382 * @since 1.0.0
376 383 * @access public
377 384 *
@@ -391,169 +398,51 @@
391 398 */
392 399 public $beta_testers;
393 400
394 401 /**
395 - * Inspector.
396 - *
397 - * Holds the plugin inspector data.
398 - *
399 - * @since 2.1.2
400 - * @access public
401 - *
402 402 * @var Inspector
403 + * @deprecated 2.1.2 Use $inspector.
403 404 */
404 - public $inspector;
405 + public $debugger;
405 406
406 407 /**
407 - * @var Admin_Menu_Manager
408 + * @var Inspector
408 409 */
409 - public $admin_menu_manager;
410 + public $inspector;
410 411
411 412 /**
412 - * Common functionality.
413 - *
414 - * Holds the plugin common functionality.
415 - *
416 - * @since 2.3.0
417 - * @access public
418 - *
419 413 * @var CommonApp
420 414 */
421 415 public $common;
422 416
423 417 /**
424 - * Log manager.
425 - *
426 - * Holds the plugin log manager.
427 - *
428 - * @access public
429 - *
430 418 * @var Log_Manager
431 419 */
432 420 public $logger;
433 421
434 422 /**
435 - * Upgrade manager.
436 - *
437 - * Holds the plugin upgrade manager.
438 - *
439 - * @access public
440 - *
441 423 * @var Core\Upgrade\Manager
442 424 */
443 425 public $upgrade;
444 426
445 427 /**
446 - * Tasks manager.
447 - *
448 - * Holds the plugin tasks manager.
449 - *
450 - * @var Core\Upgrade\Custom_Tasks_Manager
451 - */
452 - public $custom_tasks;
453 -
454 - /**
455 - * Kits manager.
456 - *
457 - * Holds the plugin kits manager.
458 - *
459 - * @access public
460 - *
461 428 * @var Core\Kits\Manager
462 429 */
463 430 public $kits_manager;
464 431
465 432 /**
466 - * @var \Elementor\Data\V2\Manager
433 + * @var \Core\Data\Manager
467 434 */
468 - public $data_manager_v2;
435 + public $data_manager;
469 436
470 - /**
471 - * Legacy mode.
472 - *
473 - * Holds the plugin legacy mode data.
474 - *
475 - * @access public
476 - *
477 - * @var array
478 - */
479 437 public $legacy_mode;
480 438
481 439 /**
482 - * App.
483 - *
484 - * Holds the plugin app data.
485 - *
486 - * @since 3.0.0
487 - * @access public
488 - *
489 - * @var App\App
440 + * @var Core\App\App
490 441 */
491 442 public $app;
492 443
493 444 /**
494 - * WordPress API.
495 - *
496 - * Holds the methods that interact with WordPress Core API.
497 - *
498 - * @since 3.0.0
499 - * @access public
500 - *
501 - * @var Wp_Api
502 - */
503 - public $wp;
504 -
505 - /**
506 - * Experiments manager.
507 - *
508 - * Holds the plugin experiments manager.
509 - *
510 - * @since 3.1.0
511 - * @access public
512 - *
513 - * @var Experiments_Manager
514 - */
515 - public $experiments;
516 -
517 - /**
518 - * Uploads manager.
519 - *
520 - * Holds the plugin uploads manager responsible for handling file uploads
521 - * that are not done with WordPress Media.
522 - *
523 - * @since 3.3.0
524 - * @access public
525 - *
526 - * @var Uploads_Manager
527 - */
528 - public $uploads_manager;
529 -
530 - /**
531 - * Breakpoints manager.
532 - *
533 - * Holds the plugin breakpoints manager.
534 - *
535 - * @since 3.2.0
536 - * @access public
537 - *
538 - * @var Breakpoints_Manager
539 - */
540 - public $breakpoints;
541 -
542 - /**
543 - * Assets loader.
544 - *
545 - * Holds the plugin assets loader responsible for conditionally enqueuing
546 - * styles and script assets that were pre-enabled.
547 - *
548 - * @since 3.3.0
549 - * @access public
550 - *
551 - * @var Assets_Loader
552 - */
553 - public $assets_loader;
554 -
555 - /**
556 445 * Clone.
557 446 *
558 447 * Disable class cloning and throw an error on object clone.
559 448 *
@@ -563,13 +452,10 @@
563 452 * @access public
564 453 * @since 1.0.0
565 454 */
566 455 public function __clone() {
567 - _doing_it_wrong(
568 - __FUNCTION__,
569 - sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
570 - '1.0.0'
571 - );
456 + // Cloning instances of the class is forbidden.
457 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
572 458 }
573 459
574 460 /**
575 461 * Wakeup.
@@ -579,13 +465,10 @@
579 465 * @access public
580 466 * @since 1.0.0
581 467 */
582 468 public function __wakeup() {
583 - _doing_it_wrong(
584 - __FUNCTION__,
585 - sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
586 - '1.0.0'
587 - );
469 + // Unserializing instances of the class is forbidden.
470 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
588 471 }
589 472
590 473 /**
591 474 * Instance.
@@ -631,12 +514,11 @@
631 514
632 515 /**
633 516 * Elementor init.
634 517 *
635 - * Fires when Elementor components are initialized.
518 + * Fires on Elementor init, after Elementor has finished loading but
519 + * before any headers are sent.
636 520 *
637 - * After Elementor finished loading but before any headers are sent.
638 - *
639 521 * @since 1.0.0
640 522 */
641 523 do_action( 'elementor/init' );
642 524 }
@@ -685,11 +567,10 @@
685 567 * @since 1.0.0
686 568 * @access private
687 569 */
688 570 private function init_components() {
689 - $this->experiments = new Experiments_Manager();
690 - $this->breakpoints = new Breakpoints_Manager();
691 571 $this->inspector = new Inspector();
572 + $this->debugger = $this->inspector;
692 573
693 574 Settings_Manager::run();
694 575
695 576 $this->db = new DB();
@@ -695,8 +576,9 @@
695 576 $this->db = new DB();
696 577 $this->controls_manager = new Controls_Manager();
697 578 $this->documents = new Documents_Manager();
698 579 $this->kits_manager = new Kits_Manager();
580 + $this->schemes_manager = new Schemes_Manager();
699 581 $this->elements_manager = new Elements_Manager();
700 582 $this->widgets_manager = new Widgets_Manager();
701 583 $this->skins_manager = new Skins_Manager();
702 584 $this->files_manager = new Files_Manager();
@@ -701,37 +583,33 @@
701 583 $this->skins_manager = new Skins_Manager();
702 584 $this->files_manager = new Files_Manager();
703 585 $this->assets_manager = new Assets_Manager();
704 586 $this->icons_manager = new Icons_Manager();
587 + /*
588 + * @TODO: Remove deprecated alias
589 + */
590 + $this->posts_css_manager = $this->files_manager;
705 591 $this->settings = new Settings();
706 592 $this->tools = new Tools();
707 593 $this->editor = new Editor();
708 594 $this->preview = new Preview();
709 595 $this->frontend = new Frontend();
596 + $this->templates_manager = new TemplateLibrary\Manager();
710 597 $this->maintenance_mode = new Maintenance_Mode();
711 598 $this->dynamic_tags = new Dynamic_Tags_Manager();
712 599 $this->modules_manager = new Modules_Manager();
713 - $this->templates_manager = new TemplateLibrary\Manager();
714 600 $this->role_manager = new Core\RoleManager\Role_Manager();
715 601 $this->system_info = new System_Info_Module();
716 602 $this->revisions_manager = new Revisions_Manager();
717 603 $this->images_manager = new Images_Manager();
718 - $this->wp = new Wp_Api();
719 - $this->assets_loader = new Assets_Loader();
720 - $this->uploads_manager = new Uploads_Manager();
721 604
722 - $this->admin_menu_manager = new Admin_Menu_Manager();
723 - $this->admin_menu_manager->register_actions();
724 -
725 605 User::init();
726 - User_Data::init();
727 606 Api::init();
728 607 Tracker::init();
729 608
730 609 $this->upgrade = new Core\Upgrade\Manager();
731 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
732 610
733 - $this->app = new App\App();
611 + $this->app = new Core\App\App();
734 612
735 613 if ( is_admin() ) {
736 614 $this->heartbeat = new Heartbeat();
737 615 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -747,10 +625,39 @@
747 625 public function init_common() {
748 626 $this->common = new CommonApp();
749 627
750 628 $this->common->init_components();
629 +
630 + $this->ajax = $this->common->get_component( 'ajax' );
751 631 }
752 632
633 + public function get_legacy_mode( $mode_name = null ) {
634 + if ( ! $this->legacy_mode ) {
635 + $optimized_dom_output = get_option( 'elementor_optimized_dom_output' );
636 +
637 + if ( $optimized_dom_output ) {
638 + $element_wrappers_legacy_mode = 'disabled' === $optimized_dom_output;
639 + } else {
640 + $element_wrappers_legacy_mode = Upgrades_Manager::install_compare( '3.0.0', '<' );
641 + }
642 +
643 + $this->legacy_mode = [
644 + 'elementWrappers' => $element_wrappers_legacy_mode,
645 + ];
646 + }
647 +
648 + if ( ! $mode_name ) {
649 + return $this->legacy_mode;
650 + }
651 +
652 + if ( isset( $this->legacy_mode[ $mode_name ] ) ) {
653 + return $this->legacy_mode[ $mode_name ];
654 + }
655 +
656 + // If there is no legacy mode with the given mode name;
657 + return false;
658 + }
659 +
753 660 /**
754 661 * Add custom post type support.
755 662 *
756 663 * Register Elementor support for all the supported post types defined by
@@ -763,9 +670,9 @@
763 670 * @since 1.0.0
764 671 * @access private
765 672 */
766 673 private function add_cpt_support() {
767 - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
674 + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
768 675
769 676 foreach ( $cpt_support as $cpt_slug ) {
770 677 add_post_type_support( $cpt_slug, 'elementor' );
771 678 }
@@ -785,36 +692,8 @@
785 692 Autoloader::run();
786 693 }
787 694
788 695 /**
789 - * Magic getter for accessing certain properties.
790 - *
791 - * @since 3.1.0
792 - * @access public
793 - *
794 - * @param string $property The property name.
795 - * @return mixed The property value or null if not found.
796 - * @throws \Exception If trying to access a private property.
797 - */
798 - public function __get( $property ) {
799 - if ( 'posts_css_manager' === $property ) {
800 - self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
801 -
802 - return $this->files_manager;
803 - }
804 -
805 - if ( 'data_manager' === $property ) {
806 - return Data_Manager::instance();
807 - }
808 -
809 - if ( property_exists( $this, $property ) ) {
810 - throw new \Exception( 'Cannot access private property.' );
811 - }
812 -
813 - return null;
814 - }
815 -
816 - /**
817 696 * Plugin constructor.
818 697 *
819 698 * Initializing Elementor plugin.
820 699 *
@@ -824,53 +703,19 @@
824 703 private function __construct() {
825 704 $this->register_autoloader();
826 705
827 706 $this->logger = Log_Manager::instance();
828 - $this->data_manager_v2 = Data_Manager_V2::instance();
707 + $this->data_manager = Data_Manager::instance();
829 708
830 709 Maintenance::init();
831 710 Compatibility::register_actions();
832 711
833 712 add_action( 'init', [ $this, 'init' ], 0 );
834 - add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
835 - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 );
713 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
836 714 }
837 715
838 716 final public static function get_title() {
839 - return esc_html__( 'Elementor', 'elementor' );
840 - }
841 -
842 - public function sanitize_post_data( $post, WP_REST_Request $request ) {
843 - if ( current_user_can( 'unfiltered_html' ) ) {
844 - return $post;
845 - }
846 -
847 - $meta = $request->get_param( 'meta' );
848 - if ( empty( $meta ) || ! is_array( $meta ) ) {
849 - return $post;
850 - }
851 -
852 - foreach ( self::SANITIZABLE_META_KEYS as $meta_key ) {
853 - $elementor_data = $meta[ $meta_key ] ?? null;
854 - if ( is_null( $elementor_data ) ) {
855 - continue;
856 - }
857 - if ( is_string( $elementor_data ) ) {
858 - $elementor_data = json_decode( $elementor_data, true );
859 - }
860 - if ( empty( $elementor_data ) ) {
861 - continue;
862 - }
863 -
864 - $elementor_data = map_deep($elementor_data, function ( $value ) {
865 - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value );
866 - });
867 -
868 - $meta[ $meta_key ] = wp_json_encode( $elementor_data );
869 - }
870 -
871 - $request->set_param( 'meta', $meta );
872 - return $post;
717 + return __( 'Elementor', 'elementor' );
873 718 }
874 719 }
875 720
876 721 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {