PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.4
Elementor Website Builder – more than just a page builder v3.4.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
← All changes | includes/plugin.php +123 -90 4.2.03.4.4 View file →
@@ -1,12 +1,11 @@
1 1 <?php
2 -
3 2 namespace Elementor;
4 3
5 -use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 4 use Elementor\Core\Wp_Api;
7 5 use Elementor\Core\Admin\Admin;
8 6 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
7 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
9 8 use Elementor\Core\Common\App as CommonApp;
10 9 use Elementor\Core\Debug\Inspector;
11 10 use Elementor\Core\Documents_Manager;
12 11 use Elementor\Core\Experiments\Manager as Experiments_Manager;
@@ -14,10 +13,12 @@
14 13 use Elementor\Core\Editor\Editor;
15 14 use Elementor\Core\Files\Manager as Files_Manager;
16 15 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 16 use Elementor\Core\Modules_Manager;
17 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 18 use Elementor\Core\Settings\Manager as Settings_Manager;
19 19 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
20 +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
20 21 use Elementor\Modules\History\Revisions_Manager;
21 22 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 23 use Elementor\Core\Logger\Manager as Log_Manager;
23 24 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
@@ -22,11 +23,10 @@
22 23 use Elementor\Core\Logger\Manager as Log_Manager;
23 24 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 25 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 26 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;
27 +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
28 +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager;
29 29
30 30 if ( ! defined( 'ABSPATH' ) ) {
31 31 exit;
32 32 }
@@ -39,17 +39,10 @@
39 39 *
40 40 * @since 1.0.0
41 41 */
42 42 class Plugin {
43 -
44 43 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 44
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - '_elementor_global_class_data',
50 - ];
51 -
52 45 /**
53 46 * Instance.
54 47 *
55 48 * Holds the plugin instance.
@@ -75,8 +68,22 @@
75 68 */
76 69 public $db;
77 70
78 71 /**
72 + * Ajax Manager.
73 + *
74 + * Holds the plugin ajax handlers which are responsible for ajax requests
75 + * and responses.
76 + *
77 + * @since 1.9.0
78 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead.
79 + * @access public
80 + *
81 + * @var Ajax
82 + */
83 + public $ajax;
84 +
85 + /**
79 86 * Controls manager.
80 87 *
81 88 * Holds the plugin controls manager handler is responsible for registering
82 89 * and initializing controls.
@@ -100,8 +107,20 @@
100 107 */
101 108 public $documents;
102 109
103 110 /**
111 + * Schemes manager.
112 + *
113 + * Holds the plugin schemes manager.
114 + *
115 + * @since 1.0.0
116 + * @access public
117 + *
118 + * @var Schemes_Manager
119 + */
120 + public $schemes_manager;
121 +
122 + /**
104 123 * Elements manager.
105 124 *
106 125 * Holds the plugin elements manager.
107 126 *
@@ -355,8 +374,21 @@
355 374 */
356 375 public $icons_manager;
357 376
358 377 /**
378 + * Files Manager.
379 + *
380 + * Holds the plugin files manager.
381 + *
382 + * @since 1.0.0
383 + * @deprecated 2.1.0 Use `Plugin::$files_manager` instead.
384 + * @access public
385 + *
386 + * @var Files_Manager
387 + */
388 + private $posts_css_manager;
389 +
390 + /**
359 391 * WordPress widgets manager.
360 392 *
361 393 * Holds the WordPress widgets manager.
362 394 *
@@ -391,8 +423,20 @@
391 423 */
392 424 public $beta_testers;
393 425
394 426 /**
427 + * Debugger.
428 + *
429 + * Holds the plugin debugger data.
430 + *
431 + * @deprecated 2.1.2 Use `Plugin::$inspector` instead.
432 + * @access public
433 + *
434 + * @var Inspector
435 + */
436 + public $debugger;
437 +
438 + /**
395 439 * Inspector.
396 440 *
397 441 * Holds the plugin inspector data.
398 442 *
@@ -403,13 +447,8 @@
403 447 */
404 448 public $inspector;
405 449
406 450 /**
407 - * @var Admin_Menu_Manager
408 - */
409 - public $admin_menu_manager;
410 -
411 - /**
412 451 * Common functionality.
413 452 *
414 453 * Holds the plugin common functionality.
415 454 *
@@ -431,8 +470,19 @@
431 470 */
432 471 public $logger;
433 472
434 473 /**
474 + * Dev tools.
475 + *
476 + * Holds the plugin dev tools.
477 + *
478 + * @access private
479 + *
480 + * @var Dev_Tools
481 + */
482 + private $dev_tools;
483 +
484 + /**
435 485 * Upgrade manager.
436 486 *
437 487 * Holds the plugin upgrade manager.
438 488 *
@@ -442,17 +492,8 @@
442 492 */
443 493 public $upgrade;
444 494
445 495 /**
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 496 * Kits manager.
456 497 *
457 498 * Holds the plugin kits manager.
458 499 *
@@ -462,11 +503,17 @@
462 503 */
463 504 public $kits_manager;
464 505
465 506 /**
466 - * @var \Elementor\Data\V2\Manager
507 + * Data manager.
508 + *
509 + * Holds the plugin data manager.
510 + *
511 + * @access public
512 + *
513 + * @var \Core\Data\Manager
467 514 */
468 - public $data_manager_v2;
515 + public $data_manager;
469 516
470 517 /**
471 518 * Legacy mode.
472 519 *
@@ -485,9 +532,9 @@
485 532 *
486 533 * @since 3.0.0
487 534 * @access public
488 535 *
489 - * @var App\App
536 + * @var Core\App\App
490 537 */
491 538 public $app;
492 539
493 540 /**
@@ -563,13 +610,10 @@
563 610 * @access public
564 611 * @since 1.0.0
565 612 */
566 613 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 - );
614 + // Cloning instances of the class is forbidden.
615 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
572 616 }
573 617
574 618 /**
575 619 * Wakeup.
@@ -579,13 +623,10 @@
579 623 * @access public
580 624 * @since 1.0.0
581 625 */
582 626 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 - );
627 + // Unserializing instances of the class is forbidden.
628 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
588 629 }
589 630
590 631 /**
591 632 * Instance.
@@ -688,8 +729,9 @@
688 729 private function init_components() {
689 730 $this->experiments = new Experiments_Manager();
690 731 $this->breakpoints = new Breakpoints_Manager();
691 732 $this->inspector = new Inspector();
733 + $this->debugger = $this->inspector;
692 734
693 735 Settings_Manager::run();
694 736
695 737 $this->db = new DB();
@@ -695,8 +737,9 @@
695 737 $this->db = new DB();
696 738 $this->controls_manager = new Controls_Manager();
697 739 $this->documents = new Documents_Manager();
698 740 $this->kits_manager = new Kits_Manager();
741 + $this->schemes_manager = new Schemes_Manager();
699 742 $this->elements_manager = new Elements_Manager();
700 743 $this->widgets_manager = new Widgets_Manager();
701 744 $this->skins_manager = new Skins_Manager();
702 745 $this->files_manager = new Files_Manager();
@@ -718,20 +761,15 @@
718 761 $this->wp = new Wp_Api();
719 762 $this->assets_loader = new Assets_Loader();
720 763 $this->uploads_manager = new Uploads_Manager();
721 764
722 - $this->admin_menu_manager = new Admin_Menu_Manager();
723 - $this->admin_menu_manager->register_actions();
724 -
725 765 User::init();
726 - User_Data::init();
727 766 Api::init();
728 767 Tracker::init();
729 768
730 769 $this->upgrade = new Core\Upgrade\Manager();
731 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
732 770
733 - $this->app = new App\App();
771 + $this->app = new Core\App\App();
734 772
735 773 if ( is_admin() ) {
736 774 $this->heartbeat = new Heartbeat();
737 775 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -736,8 +774,9 @@
736 774 $this->heartbeat = new Heartbeat();
737 775 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
738 776 $this->admin = new Admin();
739 777 $this->beta_testers = new Beta_Testers();
778 + new Elementor_3_Re_Migrate_Globals();
740 779 }
741 780 }
742 781
743 782 /**
@@ -747,11 +786,43 @@
747 786 public function init_common() {
748 787 $this->common = new CommonApp();
749 788
750 789 $this->common->init_components();
790 +
791 + $this->ajax = $this->common->get_component( 'ajax' );
751 792 }
752 793
753 794 /**
795 + * Get Legacy Mode
796 + *
797 + * @since 3.0.0
798 + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
799 + *
800 + * @param string $mode_name Optional. Default is null
801 + *
802 + * @return bool|bool[]
803 + */
804 + public function get_legacy_mode( $mode_name = null ) {
805 + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
806 + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
807 +
808 + $legacy_mode = [
809 + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
810 + ];
811 +
812 + if ( ! $mode_name ) {
813 + return $legacy_mode;
814 + }
815 +
816 + if ( isset( $legacy_mode[ $mode_name ] ) ) {
817 + return $legacy_mode[ $mode_name ];
818 + }
819 +
820 + // If there is no legacy mode with the given mode name;
821 + return false;
822 + }
823 +
824 + /**
754 825 * Add custom post type support.
755 826 *
756 827 * Register Elementor support for all the supported post types defined by
757 828 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -785,16 +856,16 @@
785 856 Autoloader::run();
786 857 }
787 858
788 859 /**
789 - * Magic getter for accessing certain properties.
860 + * Plugin Magic Getter
790 861 *
791 862 * @since 3.1.0
792 863 * @access public
793 864 *
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.
865 + * @param $property
866 + * @return mixed
867 + * @throws \Exception
797 868 */
798 869 public function __get( $property ) {
799 870 if ( 'posts_css_manager' === $property ) {
800 871 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -801,14 +872,10 @@
801 872
802 873 return $this->files_manager;
803 874 }
804 875
805 - if ( 'data_manager' === $property ) {
806 - return Data_Manager::instance();
807 - }
808 -
809 876 if ( property_exists( $this, $property ) ) {
810 - throw new \Exception( 'Cannot access private property.' );
877 + throw new \Exception( 'Cannot access private property' );
811 878 }
812 879
813 880 return null;
814 881 }
@@ -824,53 +891,19 @@
824 891 private function __construct() {
825 892 $this->register_autoloader();
826 893
827 894 $this->logger = Log_Manager::instance();
828 - $this->data_manager_v2 = Data_Manager_V2::instance();
895 + $this->data_manager = Data_Manager::instance();
829 896
830 897 Maintenance::init();
831 898 Compatibility::register_actions();
832 899
833 900 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 );
901 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
836 902 }
837 903
838 904 final public static function get_title() {
839 905 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;
873 906 }
874 907 }
875 908
876 909 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {