PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev4
Elementor Website Builder – more than just a page builder v3.26.0-dev4
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 +60 -50 4.1.43.26.0-dev4 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 -
3 2 namespace Elementor;
4 3
4 +use Elementor\Container\Container;
5 +use ElementorDeps\DI\Container as DIContainer;
5 6 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 7 use Elementor\Core\Wp_Api;
7 8 use Elementor\Core\Admin\Admin;
8 9 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
@@ -23,10 +24,10 @@
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 27 use Elementor\Data\V2\Manager as Data_Manager_V2;
27 -use Elementor\Core\Files\Uploads_Manager;
28 -use WP_REST_Request;
28 +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
29 +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager;
29 30
30 31 if ( ! defined( 'ABSPATH' ) ) {
31 32 exit;
32 33 }
@@ -39,17 +40,10 @@
39 40 *
40 41 * @since 1.0.0
41 42 */
42 43 class Plugin {
43 -
44 44 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 45
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - '_elementor_global_class_data',
50 - ];
51 -
52 46 /**
53 47 * Instance.
54 48 *
55 49 * Holds the plugin instance.
@@ -100,8 +94,21 @@
100 94 */
101 95 public $documents;
102 96
103 97 /**
98 + * Schemes manager.
99 + *
100 + * Holds the plugin schemes manager.
101 + *
102 + * @since 1.0.0
103 + * @access public
104 + * @deprecated 3.0.0
105 + *
106 + * @var Schemes_Manager
107 + */
108 + public $schemes_manager;
109 +
110 + /**
104 111 * Elements manager.
105 112 *
106 113 * Holds the plugin elements manager.
107 114 *
@@ -431,8 +438,19 @@
431 438 */
432 439 public $logger;
433 440
434 441 /**
442 + * Dev tools.
443 + *
444 + * Holds the plugin dev tools.
445 + *
446 + * @access private
447 + *
448 + * @var Dev_Tools
449 + */
450 + private $dev_tools;
451 +
452 + /**
435 453 * Upgrade manager.
436 454 *
437 455 * Holds the plugin upgrade manager.
438 456 *
@@ -552,8 +570,16 @@
552 570 */
553 571 public $assets_loader;
554 572
555 573 /**
574 + * Container instance for managing dependencies.
575 + *
576 + * @since 3.24.0
577 + * @var DIContainer
578 + */
579 + private $container;
580 +
581 + /**
556 582 * Clone.
557 583 *
558 584 * Disable class cloning and throw an error on object clone.
559 585 *
@@ -614,9 +640,26 @@
614 640
615 641 return self::$instance;
616 642 }
617 643
644 + public function initialize_container() {
645 + Container::initialize_instance();
646 +
647 + $this->container = Container::get_instance();
648 + }
649 +
618 650 /**
651 + * Get the Elementor container or resolve a dependency.
652 + */
653 + public function elementor_container( $abstract = null ) {
654 + if ( is_null( $abstract ) ) {
655 + return $this->container;
656 + }
657 +
658 + return $this->container->make( $abstract );
659 + }
660 +
661 + /**
619 662 * Init.
620 663 *
621 664 * Initialize Elementor Plugin. Register Elementor support for all the
622 665 * supported post types and initialize Elementor components.
@@ -722,9 +765,8 @@
722 765 $this->admin_menu_manager = new Admin_Menu_Manager();
723 766 $this->admin_menu_manager->register_actions();
724 767
725 768 User::init();
726 - User_Data::init();
727 769 Api::init();
728 770 Tracker::init();
729 771
730 772 $this->upgrade = new Core\Upgrade\Manager();
@@ -785,16 +827,16 @@
785 827 Autoloader::run();
786 828 }
787 829
788 830 /**
789 - * Magic getter for accessing certain properties.
831 + * Plugin Magic Getter
790 832 *
791 833 * @since 3.1.0
792 834 * @access public
793 835 *
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.
836 + * @param $property
837 + * @return mixed
838 + * @throws \Exception
797 839 */
798 840 public function __get( $property ) {
799 841 if ( 'posts_css_manager' === $property ) {
800 842 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -831,49 +873,17 @@
831 873 Compatibility::register_actions();
832 874
833 875 add_action( 'init', [ $this, 'init' ], 0 );
834 876 add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
835 - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 );
836 877 }
837 878
838 879 final public static function get_title() {
839 880 return esc_html__( 'Elementor', 'elementor' );
840 881 }
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 - }
874 882 }
875 883
876 884 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
877 885 // In tests we run the instance manually.
878 - Plugin::instance();
886 + $plugin_instance = Plugin::instance();
887 +
888 + $plugin_instance->initialize_container();
879 889 }