PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.2
Elementor Website Builder – more than just a page builder v3.25.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 +62 -50 4.2.0-dev23.25.2 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;
@@ -14,8 +15,9 @@
14 15 use Elementor\Core\Editor\Editor;
15 16 use Elementor\Core\Files\Manager as Files_Manager;
16 17 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 18 use Elementor\Core\Modules_Manager;
19 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 20 use Elementor\Core\Settings\Manager as Settings_Manager;
19 21 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
20 22 use Elementor\Modules\History\Revisions_Manager;
21 23 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
@@ -23,10 +25,10 @@
23 25 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 26 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 27 use Elementor\Data\Manager as Data_Manager;
26 28 use Elementor\Data\V2\Manager as Data_Manager_V2;
27 -use Elementor\Core\Files\Uploads_Manager;
28 -use WP_REST_Request;
29 +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
30 +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager;
29 31
30 32 if ( ! defined( 'ABSPATH' ) ) {
31 33 exit;
32 34 }
@@ -39,17 +41,10 @@
39 41 *
40 42 * @since 1.0.0
41 43 */
42 44 class Plugin {
43 -
44 45 const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 46
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - '_elementor_global_class_data',
50 - ];
51 -
52 47 /**
53 48 * Instance.
54 49 *
55 50 * Holds the plugin instance.
@@ -100,8 +95,21 @@
100 95 */
101 96 public $documents;
102 97
103 98 /**
99 + * Schemes manager.
100 + *
101 + * Holds the plugin schemes manager.
102 + *
103 + * @since 1.0.0
104 + * @access public
105 + * @deprecated 3.0.0
106 + *
107 + * @var Schemes_Manager
108 + */
109 + public $schemes_manager;
110 +
111 + /**
104 112 * Elements manager.
105 113 *
106 114 * Holds the plugin elements manager.
107 115 *
@@ -431,8 +439,19 @@
431 439 */
432 440 public $logger;
433 441
434 442 /**
443 + * Dev tools.
444 + *
445 + * Holds the plugin dev tools.
446 + *
447 + * @access private
448 + *
449 + * @var Dev_Tools
450 + */
451 + private $dev_tools;
452 +
453 + /**
435 454 * Upgrade manager.
436 455 *
437 456 * Holds the plugin upgrade manager.
438 457 *
@@ -552,8 +571,16 @@
552 571 */
553 572 public $assets_loader;
554 573
555 574 /**
575 + * Container instance for managing dependencies.
576 + *
577 + * @since 3.24.0
578 + * @var DIContainer
579 + */
580 + private $container;
581 +
582 + /**
556 583 * Clone.
557 584 *
558 585 * Disable class cloning and throw an error on object clone.
559 586 *
@@ -614,9 +641,26 @@
614 641
615 642 return self::$instance;
616 643 }
617 644
645 + public function initialize_container() {
646 + Container::initialize_instance();
647 +
648 + $this->container = Container::get_instance();
649 + }
650 +
618 651 /**
652 + * Get the Elementor container or resolve a dependency.
653 + */
654 + public function elementor_container( $abstract = null ) {
655 + if ( is_null( $abstract ) ) {
656 + return $this->container;
657 + }
658 +
659 + return $this->container->make( $abstract );
660 + }
661 +
662 + /**
619 663 * Init.
620 664 *
621 665 * Initialize Elementor Plugin. Register Elementor support for all the
622 666 * supported post types and initialize Elementor components.
@@ -695,8 +739,9 @@
695 739 $this->db = new DB();
696 740 $this->controls_manager = new Controls_Manager();
697 741 $this->documents = new Documents_Manager();
698 742 $this->kits_manager = new Kits_Manager();
743 + $this->schemes_manager = new Schemes_Manager();
699 744 $this->elements_manager = new Elements_Manager();
700 745 $this->widgets_manager = new Widgets_Manager();
701 746 $this->skins_manager = new Skins_Manager();
702 747 $this->files_manager = new Files_Manager();
@@ -722,9 +767,8 @@
722 767 $this->admin_menu_manager = new Admin_Menu_Manager();
723 768 $this->admin_menu_manager->register_actions();
724 769
725 770 User::init();
726 - User_Data::init();
727 771 Api::init();
728 772 Tracker::init();
729 773
730 774 $this->upgrade = new Core\Upgrade\Manager();
@@ -785,16 +829,16 @@
785 829 Autoloader::run();
786 830 }
787 831
788 832 /**
789 - * Magic getter for accessing certain properties.
833 + * Plugin Magic Getter
790 834 *
791 835 * @since 3.1.0
792 836 * @access public
793 837 *
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.
838 + * @param $property
839 + * @return mixed
840 + * @throws \Exception
797 841 */
798 842 public function __get( $property ) {
799 843 if ( 'posts_css_manager' === $property ) {
800 844 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 +875,17 @@
831 875 Compatibility::register_actions();
832 876
833 877 add_action( 'init', [ $this, 'init' ], 0 );
834 878 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 879 }
837 880
838 881 final public static function get_title() {
839 882 return esc_html__( 'Elementor', 'elementor' );
840 883 }
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 884 }
875 885
876 886 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
877 887 // In tests we run the instance manually.
878 - Plugin::instance();
888 + $plugin_instance = Plugin::instance();
889 +
890 + $plugin_instance->initialize_container();
879 891 }