PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.8
Elementor Website Builder – more than just a page builder v3.25.8
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 -49 4.1.0-dev33.25.8 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,16 +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 - ];
50 -
51 47 /**
52 48 * Instance.
53 49 *
54 50 * Holds the plugin instance.
@@ -99,8 +95,21 @@
99 95 */
100 96 public $documents;
101 97
102 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 + /**
103 112 * Elements manager.
104 113 *
105 114 * Holds the plugin elements manager.
106 115 *
@@ -430,8 +439,19 @@
430 439 */
431 440 public $logger;
432 441
433 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 + /**
434 454 * Upgrade manager.
435 455 *
436 456 * Holds the plugin upgrade manager.
437 457 *
@@ -551,8 +571,16 @@
551 571 */
552 572 public $assets_loader;
553 573
554 574 /**
575 + * Container instance for managing dependencies.
576 + *
577 + * @since 3.24.0
578 + * @var DIContainer
579 + */
580 + private $container;
581 +
582 + /**
555 583 * Clone.
556 584 *
557 585 * Disable class cloning and throw an error on object clone.
558 586 *
@@ -613,9 +641,26 @@
613 641
614 642 return self::$instance;
615 643 }
616 644
645 + public function initialize_container() {
646 + Container::initialize_instance();
647 +
648 + $this->container = Container::get_instance();
649 + }
650 +
617 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 + /**
618 663 * Init.
619 664 *
620 665 * Initialize Elementor Plugin. Register Elementor support for all the
621 666 * supported post types and initialize Elementor components.
@@ -694,8 +739,9 @@
694 739 $this->db = new DB();
695 740 $this->controls_manager = new Controls_Manager();
696 741 $this->documents = new Documents_Manager();
697 742 $this->kits_manager = new Kits_Manager();
743 + $this->schemes_manager = new Schemes_Manager();
698 744 $this->elements_manager = new Elements_Manager();
699 745 $this->widgets_manager = new Widgets_Manager();
700 746 $this->skins_manager = new Skins_Manager();
701 747 $this->files_manager = new Files_Manager();
@@ -721,9 +767,8 @@
721 767 $this->admin_menu_manager = new Admin_Menu_Manager();
722 768 $this->admin_menu_manager->register_actions();
723 769
724 770 User::init();
725 - User_Data::init();
726 771 Api::init();
727 772 Tracker::init();
728 773
729 774 $this->upgrade = new Core\Upgrade\Manager();
@@ -784,16 +829,16 @@
784 829 Autoloader::run();
785 830 }
786 831
787 832 /**
788 - * Magic getter for accessing certain properties.
833 + * Plugin Magic Getter
789 834 *
790 835 * @since 3.1.0
791 836 * @access public
792 837 *
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.
838 + * @param $property
839 + * @return mixed
840 + * @throws \Exception
796 841 */
797 842 public function __get( $property ) {
798 843 if ( 'posts_css_manager' === $property ) {
799 844 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 +875,17 @@
830 875 Compatibility::register_actions();
831 876
832 877 add_action( 'init', [ $this, 'init' ], 0 );
833 878 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 879 }
836 880
837 881 final public static function get_title() {
838 882 return esc_html__( 'Elementor', 'elementor' );
839 883 }
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 884 }
874 885
875 886 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {
876 887 // In tests we run the instance manually.
877 - Plugin::instance();
888 + $plugin_instance = Plugin::instance();
889 +
890 + $plugin_instance->initialize_container();
878 891 }