PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.2
Elementor Website Builder – more than just a page builder v3.6.2
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 +70 -70 4.0.73.6.2 View file →
@@ -1,9 +1,7 @@
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;
9 7 use Elementor\Core\Common\App as CommonApp;
@@ -14,10 +12,12 @@
14 12 use Elementor\Core\Editor\Editor;
15 13 use Elementor\Core\Files\Manager as Files_Manager;
16 14 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 15 use Elementor\Core\Modules_Manager;
16 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 17 use Elementor\Core\Settings\Manager as Settings_Manager;
19 18 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
19 +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
20 20 use Elementor\Modules\History\Revisions_Manager;
21 21 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 22 use Elementor\Core\Logger\Manager as Log_Manager;
23 23 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
@@ -23,10 +23,10 @@
23 23 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 24 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 25 use Elementor\Data\Manager as Data_Manager;
26 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.
@@ -99,8 +93,20 @@
99 93 */
100 94 public $documents;
101 95
102 96 /**
97 + * Schemes manager.
98 + *
99 + * Holds the plugin schemes manager.
100 + *
101 + * @since 1.0.0
102 + * @access public
103 + *
104 + * @var Schemes_Manager
105 + */
106 + public $schemes_manager;
107 +
108 + /**
103 109 * Elements manager.
104 110 *
105 111 * Holds the plugin elements manager.
106 112 *
@@ -402,13 +408,8 @@
402 408 */
403 409 public $inspector;
404 410
405 411 /**
406 - * @var Admin_Menu_Manager
407 - */
408 - public $admin_menu_manager;
409 -
410 - /**
411 412 * Common functionality.
412 413 *
413 414 * Holds the plugin common functionality.
414 415 *
@@ -430,8 +431,19 @@
430 431 */
431 432 public $logger;
432 433
433 434 /**
435 + * Dev tools.
436 + *
437 + * Holds the plugin dev tools.
438 + *
439 + * @access private
440 + *
441 + * @var Dev_Tools
442 + */
443 + private $dev_tools;
444 +
445 + /**
434 446 * Upgrade manager.
435 447 *
436 448 * Holds the plugin upgrade manager.
437 449 *
@@ -484,9 +496,9 @@
484 496 *
485 497 * @since 3.0.0
486 498 * @access public
487 499 *
488 - * @var App\App
500 + * @var Core\App\App
489 501 */
490 502 public $app;
491 503
492 504 /**
@@ -562,13 +574,10 @@
562 574 * @access public
563 575 * @since 1.0.0
564 576 */
565 577 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 - );
578 + // Cloning instances of the class is forbidden.
579 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
571 580 }
572 581
573 582 /**
574 583 * Wakeup.
@@ -578,13 +587,10 @@
578 587 * @access public
579 588 * @since 1.0.0
580 589 */
581 590 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 - );
591 + // Unserializing instances of the class is forbidden.
592 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
587 593 }
588 594
589 595 /**
590 596 * Instance.
@@ -694,8 +700,9 @@
694 700 $this->db = new DB();
695 701 $this->controls_manager = new Controls_Manager();
696 702 $this->documents = new Documents_Manager();
697 703 $this->kits_manager = new Kits_Manager();
704 + $this->schemes_manager = new Schemes_Manager();
698 705 $this->elements_manager = new Elements_Manager();
699 706 $this->widgets_manager = new Widgets_Manager();
700 707 $this->skins_manager = new Skins_Manager();
701 708 $this->files_manager = new Files_Manager();
@@ -717,13 +724,9 @@
717 724 $this->wp = new Wp_Api();
718 725 $this->assets_loader = new Assets_Loader();
719 726 $this->uploads_manager = new Uploads_Manager();
720 727
721 - $this->admin_menu_manager = new Admin_Menu_Manager();
722 - $this->admin_menu_manager->register_actions();
723 -
724 728 User::init();
725 - User_Data::init();
726 729 Api::init();
727 730 Tracker::init();
728 731
729 732 $this->upgrade = new Core\Upgrade\Manager();
@@ -728,9 +731,9 @@
728 731
729 732 $this->upgrade = new Core\Upgrade\Manager();
730 733 $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
731 734
732 - $this->app = new App\App();
735 + $this->app = new Core\App\App();
733 736
734 737 if ( is_admin() ) {
735 738 $this->heartbeat = new Heartbeat();
736 739 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -735,8 +738,9 @@
735 738 $this->heartbeat = new Heartbeat();
736 739 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
737 740 $this->admin = new Admin();
738 741 $this->beta_testers = new Beta_Testers();
742 + new Elementor_3_Re_Migrate_Globals();
739 743 }
740 744 }
741 745
742 746 /**
@@ -749,8 +753,38 @@
749 753 $this->common->init_components();
750 754 }
751 755
752 756 /**
757 + * Get Legacy Mode
758 + *
759 + * @since 3.0.0
760 + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
761 + *
762 + * @param string $mode_name Optional. Default is null
763 + *
764 + * @return bool|bool[]
765 + */
766 + public function get_legacy_mode( $mode_name = null ) {
767 + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
768 + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
769 +
770 + $legacy_mode = [
771 + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
772 + ];
773 +
774 + if ( ! $mode_name ) {
775 + return $legacy_mode;
776 + }
777 +
778 + if ( isset( $legacy_mode[ $mode_name ] ) ) {
779 + return $legacy_mode[ $mode_name ];
780 + }
781 +
782 + // If there is no legacy mode with the given mode name;
783 + return false;
784 + }
785 +
786 + /**
753 787 * Add custom post type support.
754 788 *
755 789 * Register Elementor support for all the supported post types defined by
756 790 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -784,16 +818,16 @@
784 818 Autoloader::run();
785 819 }
786 820
787 821 /**
788 - * Magic getter for accessing certain properties.
822 + * Plugin Magic Getter
789 823 *
790 824 * @since 3.1.0
791 825 * @access public
792 826 *
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.
827 + * @param $property
828 + * @return mixed
829 + * @throws \Exception
796 830 */
797 831 public function __get( $property ) {
798 832 if ( 'posts_css_manager' === $property ) {
799 833 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -805,9 +839,9 @@
805 839 return Data_Manager::instance();
806 840 }
807 841
808 842 if ( property_exists( $this, $property ) ) {
809 - throw new \Exception( 'Cannot access private property.' );
843 + throw new \Exception( 'Cannot access private property' );
810 844 }
811 845
812 846 return null;
813 847 }
@@ -830,46 +864,12 @@
830 864 Compatibility::register_actions();
831 865
832 866 add_action( 'init', [ $this, 'init' ], 0 );
833 867 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
834 - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 );
835 868 }
836 869
837 870 final public static function get_title() {
838 871 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 872 }
873 873 }
874 874
875 875 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {