PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.4
Elementor Website Builder – more than just a page builder v3.26.4
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 -49 4.0.93.26.4 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,16 +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 - ];
50 -
51 46 /**
52 47 * Instance.
53 48 *
54 49 * Holds the plugin instance.
@@ -99,8 +94,21 @@
99 94 */
100 95 public $documents;
101 96
102 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 + /**
103 111 * Elements manager.
104 112 *
105 113 * Holds the plugin elements manager.
106 114 *
@@ -430,8 +438,19 @@
430 438 */
431 439 public $logger;
432 440
433 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 + /**
434 453 * Upgrade manager.
435 454 *
436 455 * Holds the plugin upgrade manager.
437 456 *
@@ -551,8 +570,16 @@
551 570 */
552 571 public $assets_loader;
553 572
554 573 /**
574 + * Container instance for managing dependencies.
575 + *
576 + * @since 3.24.0
577 + * @var DIContainer
578 + */
579 + private $container;
580 +
581 + /**
555 582 * Clone.
556 583 *
557 584 * Disable class cloning and throw an error on object clone.
558 585 *
@@ -613,9 +640,26 @@
613 640
614 641 return self::$instance;
615 642 }
616 643
644 + public function initialize_container() {
645 + Container::initialize_instance();
646 +
647 + $this->container = Container::get_instance();
648 + }
649 +
617 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 + /**
618 662 * Init.
619 663 *
620 664 * Initialize Elementor Plugin. Register Elementor support for all the
621 665 * supported post types and initialize Elementor components.
@@ -721,9 +765,8 @@
721 765 $this->admin_menu_manager = new Admin_Menu_Manager();
722 766 $this->admin_menu_manager->register_actions();
723 767
724 768 User::init();
725 - User_Data::init();
726 769 Api::init();
727 770 Tracker::init();
728 771
729 772 $this->upgrade = new Core\Upgrade\Manager();
@@ -784,16 +827,16 @@
784 827 Autoloader::run();
785 828 }
786 829
787 830 /**
788 - * Magic getter for accessing certain properties.
831 + * Plugin Magic Getter
789 832 *
790 833 * @since 3.1.0
791 834 * @access public
792 835 *
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.
836 + * @param $property
837 + * @return mixed
838 + * @throws \Exception
796 839 */
797 840 public function __get( $property ) {
798 841 if ( 'posts_css_manager' === $property ) {
799 842 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -830,49 +873,17 @@
830 873 Compatibility::register_actions();
831 874
832 875 add_action( 'init', [ $this, 'init' ], 0 );
833 876 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 877 }
836 878
837 879 final public static function get_title() {
838 880 return esc_html__( 'Elementor', 'elementor' );
839 881 }
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 882 }
874 883
875 884 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
876 885 // In tests we run the instance manually.
877 - Plugin::instance();
886 + $plugin_instance = Plugin::instance();
887 +
888 + $plugin_instance->initialize_container();
878 889 }