PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.1
Elementor Website Builder – more than just a page builder v3.30.1
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 -45 4.1.43.30.1 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,17 +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 - '_elementor_global_class_data',
50 - ];
51 -
52 49 /**
53 50 * Instance.
54 51 *
55 52 * Holds the plugin instance.
@@ -552,8 +549,16 @@
552 549 */
553 550 public $assets_loader;
554 551
555 552 /**
553 + * Container instance for managing dependencies.
554 + *
555 + * @since 3.24.0
556 + * @var DIContainer
557 + */
558 + private $container;
559 +
560 + /**
556 561 * Clone.
557 562 *
558 563 * Disable class cloning and throw an error on object clone.
559 564 *
@@ -614,9 +619,34 @@
614 619
615 620 return self::$instance;
616 621 }
617 622
623 + public function initialize_container() {
624 + Container::initialize_instance();
625 +
626 + $this->container = Container::get_instance();
627 + }
628 +
618 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 + /**
619 649 * Init.
620 650 *
621 651 * Initialize Elementor Plugin. Register Elementor support for all the
622 652 * supported post types and initialize Elementor components.
@@ -722,9 +752,8 @@
722 752 $this->admin_menu_manager = new Admin_Menu_Manager();
723 753 $this->admin_menu_manager->register_actions();
724 754
725 755 User::init();
726 - User_Data::init();
727 756 Api::init();
728 757 Tracker::init();
729 758
730 759 $this->upgrade = new Core\Upgrade\Manager();
@@ -831,49 +860,17 @@
831 860 Compatibility::register_actions();
832 861
833 862 add_action( 'init', [ $this, 'init' ], 0 );
834 863 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 864 }
837 865
838 866 final public static function get_title() {
839 867 return esc_html__( 'Elementor', 'elementor' );
840 868 }
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 869 }
875 870
876 871 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
877 872 // In tests we run the instance manually.
878 - Plugin::instance();
873 + $plugin_instance = Plugin::instance();
874 +
875 + $plugin_instance->initialize_container();
879 876 }