PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 +42 -44 4.0.93.28.0-dev2 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;
@@ -24,9 +25,12 @@
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 28 use Elementor\Core\Files\Uploads_Manager;
28 -use WP_REST_Request;
29 +use ElementorDeps\DI\{
30 + DependencyException,
31 + NotFoundException,
32 +};
29 33
30 34 if ( ! defined( 'ABSPATH' ) ) {
31 35 exit;
32 36 }
@@ -39,16 +43,10 @@
39 43 *
40 44 * @since 1.0.0
41 45 */
42 46 class Plugin {
43 -
44 47 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 48
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - ];
50 -
51 49 /**
52 50 * Instance.
53 51 *
54 52 * Holds the plugin instance.
@@ -551,8 +549,16 @@
551 549 */
552 550 public $assets_loader;
553 551
554 552 /**
553 + * Container instance for managing dependencies.
554 + *
555 + * @since 3.24.0
556 + * @var DIContainer
557 + */
558 + private $container;
559 +
560 + /**
555 561 * Clone.
556 562 *
557 563 * Disable class cloning and throw an error on object clone.
558 564 *
@@ -613,9 +619,34 @@
613 619
614 620 return self::$instance;
615 621 }
616 622
623 + public function initialize_container() {
624 + Container::initialize_instance();
625 +
626 + $this->container = Container::get_instance();
627 + }
628 +
617 629 /**
630 + * Get the Elementor container or resolve a dependency.
631 + *
632 + * @param string|null $dependency The dependency to resolve. If null, returns the container instance.
633 + *
634 + * @return mixed The container instance or the resolved dependency.
635 + *
636 + * @throws \InvalidArgumentException The name parameter must be of type string.
637 + * @throws DependencyException Error while resolving the entry.
638 + * @throws NotFoundException No entry found for the given name.
639 + */
640 + public function elementor_container( $dependency = null ) {
641 + if ( is_null( $dependency ) ) {
642 + return $this->container;
643 + }
644 +
645 + return $this->container->make( $dependency );
646 + }
647 +
648 + /**
618 649 * Init.
619 650 *
620 651 * Initialize Elementor Plugin. Register Elementor support for all the
621 652 * supported post types and initialize Elementor components.
@@ -721,9 +752,8 @@
721 752 $this->admin_menu_manager = new Admin_Menu_Manager();
722 753 $this->admin_menu_manager->register_actions();
723 754
724 755 User::init();
725 - User_Data::init();
726 756 Api::init();
727 757 Tracker::init();
728 758
729 759 $this->upgrade = new Core\Upgrade\Manager();
@@ -830,49 +860,17 @@
830 860 Compatibility::register_actions();
831 861
832 862 add_action( 'init', [ $this, 'init' ], 0 );
833 863 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 864 }
836 865
837 866 final public static function get_title() {
838 867 return esc_html__( 'Elementor', 'elementor' );
839 868 }
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 - }
873 869 }
874 870
875 871 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
876 872 // In tests we run the instance manually.
877 - Plugin::instance();
873 + $plugin_instance = Plugin::instance();
874 +
875 + $plugin_instance->initialize_container();
878 876 }