PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.8
Elementor Website Builder – more than just a page builder v3.4.8
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 -89 4.0.73.4.8 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,16 +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 - ];
50 -
51 45 /**
52 46 * Instance.
53 47 *
54 48 * Holds the plugin instance.
@@ -74,8 +68,22 @@
74 68 */
75 69 public $db;
76 70
77 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 + /**
78 86 * Controls manager.
79 87 *
80 88 * Holds the plugin controls manager handler is responsible for registering
81 89 * and initializing controls.
@@ -99,8 +107,20 @@
99 107 */
100 108 public $documents;
101 109
102 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 + /**
103 123 * Elements manager.
104 124 *
105 125 * Holds the plugin elements manager.
106 126 *
@@ -354,8 +374,21 @@
354 374 */
355 375 public $icons_manager;
356 376
357 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 + /**
358 391 * WordPress widgets manager.
359 392 *
360 393 * Holds the WordPress widgets manager.
361 394 *
@@ -390,8 +423,20 @@
390 423 */
391 424 public $beta_testers;
392 425
393 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 + /**
394 439 * Inspector.
395 440 *
396 441 * Holds the plugin inspector data.
397 442 *
@@ -402,13 +447,8 @@
402 447 */
403 448 public $inspector;
404 449
405 450 /**
406 - * @var Admin_Menu_Manager
407 - */
408 - public $admin_menu_manager;
409 -
410 - /**
411 451 * Common functionality.
412 452 *
413 453 * Holds the plugin common functionality.
414 454 *
@@ -430,8 +470,19 @@
430 470 */
431 471 public $logger;
432 472
433 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 + /**
434 485 * Upgrade manager.
435 486 *
436 487 * Holds the plugin upgrade manager.
437 488 *
@@ -441,17 +492,8 @@
441 492 */
442 493 public $upgrade;
443 494
444 495 /**
445 - * Tasks manager.
446 - *
447 - * Holds the plugin tasks manager.
448 - *
449 - * @var Core\Upgrade\Custom_Tasks_Manager
450 - */
451 - public $custom_tasks;
452 -
453 - /**
454 496 * Kits manager.
455 497 *
456 498 * Holds the plugin kits manager.
457 499 *
@@ -461,11 +503,17 @@
461 503 */
462 504 public $kits_manager;
463 505
464 506 /**
465 - * @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
466 514 */
467 - public $data_manager_v2;
515 + public $data_manager;
468 516
469 517 /**
470 518 * Legacy mode.
471 519 *
@@ -484,9 +532,9 @@
484 532 *
485 533 * @since 3.0.0
486 534 * @access public
487 535 *
488 - * @var App\App
536 + * @var Core\App\App
489 537 */
490 538 public $app;
491 539
492 540 /**
@@ -562,13 +610,10 @@
562 610 * @access public
563 611 * @since 1.0.0
564 612 */
565 613 public function __clone() {
566 - _doing_it_wrong(
567 - __FUNCTION__,
568 - sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
569 - '1.0.0'
570 - );
614 + // Cloning instances of the class is forbidden.
615 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
571 616 }
572 617
573 618 /**
574 619 * Wakeup.
@@ -578,13 +623,10 @@
578 623 * @access public
579 624 * @since 1.0.0
580 625 */
581 626 public function __wakeup() {
582 - _doing_it_wrong(
583 - __FUNCTION__,
584 - sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
585 - '1.0.0'
586 - );
627 + // Unserializing instances of the class is forbidden.
628 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
587 629 }
588 630
589 631 /**
590 632 * Instance.
@@ -687,8 +729,9 @@
687 729 private function init_components() {
688 730 $this->experiments = new Experiments_Manager();
689 731 $this->breakpoints = new Breakpoints_Manager();
690 732 $this->inspector = new Inspector();
733 + $this->debugger = $this->inspector;
691 734
692 735 Settings_Manager::run();
693 736
694 737 $this->db = new DB();
@@ -694,8 +737,9 @@
694 737 $this->db = new DB();
695 738 $this->controls_manager = new Controls_Manager();
696 739 $this->documents = new Documents_Manager();
697 740 $this->kits_manager = new Kits_Manager();
741 + $this->schemes_manager = new Schemes_Manager();
698 742 $this->elements_manager = new Elements_Manager();
699 743 $this->widgets_manager = new Widgets_Manager();
700 744 $this->skins_manager = new Skins_Manager();
701 745 $this->files_manager = new Files_Manager();
@@ -717,20 +761,15 @@
717 761 $this->wp = new Wp_Api();
718 762 $this->assets_loader = new Assets_Loader();
719 763 $this->uploads_manager = new Uploads_Manager();
720 764
721 - $this->admin_menu_manager = new Admin_Menu_Manager();
722 - $this->admin_menu_manager->register_actions();
723 -
724 765 User::init();
725 - User_Data::init();
726 766 Api::init();
727 767 Tracker::init();
728 768
729 769 $this->upgrade = new Core\Upgrade\Manager();
730 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
731 770
732 - $this->app = new App\App();
771 + $this->app = new Core\App\App();
733 772
734 773 if ( is_admin() ) {
735 774 $this->heartbeat = new Heartbeat();
736 775 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -735,8 +774,9 @@
735 774 $this->heartbeat = new Heartbeat();
736 775 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
737 776 $this->admin = new Admin();
738 777 $this->beta_testers = new Beta_Testers();
778 + new Elementor_3_Re_Migrate_Globals();
739 779 }
740 780 }
741 781
742 782 /**
@@ -746,11 +786,43 @@
746 786 public function init_common() {
747 787 $this->common = new CommonApp();
748 788
749 789 $this->common->init_components();
790 +
791 + $this->ajax = $this->common->get_component( 'ajax' );
750 792 }
751 793
752 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 + /**
753 825 * Add custom post type support.
754 826 *
755 827 * Register Elementor support for all the supported post types defined by
756 828 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -784,16 +856,16 @@
784 856 Autoloader::run();
785 857 }
786 858
787 859 /**
788 - * Magic getter for accessing certain properties.
860 + * Plugin Magic Getter
789 861 *
790 862 * @since 3.1.0
791 863 * @access public
792 864 *
793 - * @param string $property The property name.
794 - * @return mixed The property value or null if not found.
795 - * @throws \Exception If trying to access a private property.
865 + * @param $property
866 + * @return mixed
867 + * @throws \Exception
796 868 */
797 869 public function __get( $property ) {
798 870 if ( 'posts_css_manager' === $property ) {
799 871 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -800,14 +872,10 @@
800 872
801 873 return $this->files_manager;
802 874 }
803 875
804 - if ( 'data_manager' === $property ) {
805 - return Data_Manager::instance();
806 - }
807 -
808 876 if ( property_exists( $this, $property ) ) {
809 - throw new \Exception( 'Cannot access private property.' );
877 + throw new \Exception( 'Cannot access private property' );
810 878 }
811 879
812 880 return null;
813 881 }
@@ -823,53 +891,19 @@
823 891 private function __construct() {
824 892 $this->register_autoloader();
825 893
826 894 $this->logger = Log_Manager::instance();
827 - $this->data_manager_v2 = Data_Manager_V2::instance();
895 + $this->data_manager = Data_Manager::instance();
828 896
829 897 Maintenance::init();
830 898 Compatibility::register_actions();
831 899
832 900 add_action( 'init', [ $this, 'init' ], 0 );
833 - add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
834 - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 );
901 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
835 902 }
836 903
837 904 final public static function get_title() {
838 905 return esc_html__( 'Elementor', 'elementor' );
839 - }
840 -
841 - public function sanitize_post_data( $post, WP_REST_Request $request ) {
842 - if ( current_user_can( 'unfiltered_html' ) ) {
843 - return $post;
844 - }
845 -
846 - $meta = $request->get_param( 'meta' );
847 - if ( empty( $meta ) || ! is_array( $meta ) ) {
848 - return $post;
849 - }
850 -
851 - foreach ( self::SANITIZABLE_META_KEYS as $meta_key ) {
852 - $elementor_data = $meta[ $meta_key ] ?? null;
853 - if ( is_null( $elementor_data ) ) {
854 - continue;
855 - }
856 - if ( is_string( $elementor_data ) ) {
857 - $elementor_data = json_decode( $elementor_data, true );
858 - }
859 - if ( empty( $elementor_data ) ) {
860 - continue;
861 - }
862 -
863 - $elementor_data = map_deep($elementor_data, function ( $value ) {
864 - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value );
865 - });
866 -
867 - $meta[ $meta_key ] = wp_json_encode( $elementor_data );
868 - }
869 -
870 - $request->set_param( 'meta', $meta );
871 - return $post;
872 906 }
873 907 }
874 908
875 909 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {