| @@ -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,9 +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 Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools; | |
| 29 | +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager; | |
| 28 | 30 | |
| 29 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 30 | 32 | exit; |
| 31 | 33 | } |
| @@ -38,9 +40,8 @@ | ||
| 38 | 40 | * |
| 39 | 41 | * @since 1.0.0 |
| 40 | 42 | */ |
| 41 | 43 | class Plugin { |
| 42 | - | |
| 43 | 44 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 44 | 45 | |
| 45 | 46 | /** |
| 46 | 47 | * Instance. |
| @@ -93,8 +94,21 @@ | ||
| 93 | 94 | */ |
| 94 | 95 | public $documents; |
| 95 | 96 | |
| 96 | 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 | + /** | |
| 97 | 111 | * Elements manager. |
| 98 | 112 | * |
| 99 | 113 | * Holds the plugin elements manager. |
| 100 | 114 | * |
| @@ -424,8 +438,19 @@ | ||
| 424 | 438 | */ |
| 425 | 439 | public $logger; |
| 426 | 440 | |
| 427 | 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 | + /** | |
| 428 | 453 | * Upgrade manager. |
| 429 | 454 | * |
| 430 | 455 | * Holds the plugin upgrade manager. |
| 431 | 456 | * |
| @@ -545,8 +570,16 @@ | ||
| 545 | 570 | */ |
| 546 | 571 | public $assets_loader; |
| 547 | 572 | |
| 548 | 573 | /** |
| 574 | + * Container instance for managing dependencies. | |
| 575 | + * | |
| 576 | + * @since 3.24.0 | |
| 577 | + * @var DIContainer | |
| 578 | + */ | |
| 579 | + private $container; | |
| 580 | + | |
| 581 | + /** | |
| 549 | 582 | * Clone. |
| 550 | 583 | * |
| 551 | 584 | * Disable class cloning and throw an error on object clone. |
| 552 | 585 | * |
| @@ -607,9 +640,26 @@ | ||
| 607 | 640 | |
| 608 | 641 | return self::$instance; |
| 609 | 642 | } |
| 610 | 643 | |
| 644 | + public function initialize_container() { | |
| 645 | + Container::initialize_instance(); | |
| 646 | + | |
| 647 | + $this->container = Container::get_instance(); | |
| 648 | + } | |
| 649 | + | |
| 611 | 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 | + /** | |
| 612 | 662 | * Init. |
| 613 | 663 | * |
| 614 | 664 | * Initialize Elementor Plugin. Register Elementor support for all the |
| 615 | 665 | * supported post types and initialize Elementor components. |
| @@ -715,9 +765,8 @@ | ||
| 715 | 765 | $this->admin_menu_manager = new Admin_Menu_Manager(); |
| 716 | 766 | $this->admin_menu_manager->register_actions(); |
| 717 | 767 | |
| 718 | 768 | User::init(); |
| 719 | - User_Data::init(); | |
| 720 | 769 | Api::init(); |
| 721 | 770 | Tracker::init(); |
| 722 | 771 | |
| 723 | 772 | $this->upgrade = new Core\Upgrade\Manager(); |
| @@ -778,16 +827,16 @@ | ||
| 778 | 827 | Autoloader::run(); |
| 779 | 828 | } |
| 780 | 829 | |
| 781 | 830 | /** |
| 782 | - * Magic getter for accessing certain properties. | |
| 831 | + * Plugin Magic Getter | |
| 783 | 832 | * |
| 784 | 833 | * @since 3.1.0 |
| 785 | 834 | * @access public |
| 786 | 835 | * |
| 787 | - * @param string $property The property name. | |
| 788 | - * @return mixed The property value or null if not found. | |
| 789 | - * @throws \Exception If trying to access a private property. | |
| 836 | + * @param $property | |
| 837 | + * @return mixed | |
| 838 | + * @throws \Exception | |
| 790 | 839 | */ |
| 791 | 840 | public function __get( $property ) { |
| 792 | 841 | if ( 'posts_css_manager' === $property ) { |
| 793 | 842 | self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); |
| @@ -833,6 +882,8 @@ | ||
| 833 | 882 | } |
| 834 | 883 | |
| 835 | 884 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |
| 836 | 885 | // In tests we run the instance manually. |
| 837 | - Plugin::instance(); | |
| 886 | + $plugin_instance = Plugin::instance(); | |
| 887 | + | |
| 888 | + $plugin_instance->initialize_container(); | |
| 838 | 889 | } |