| @@ -5,8 +5,9 @@ | ||
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module as Ajax; |
| 6 | 6 | use Elementor\Core\Common\App as CommonApp; |
| 7 | 7 | use Elementor\Core\Debug\Inspector; |
| 8 | 8 | use Elementor\Core\Documents_Manager; |
| 9 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 9 | 10 | use Elementor\Core\Kits\Manager as Kits_Manager; |
| 10 | 11 | use Elementor\Core\Editor\Editor; |
| 11 | 12 | use Elementor\Core\Files\Manager as Files_Manager; |
| 12 | 13 | use Elementor\Core\Files\Assets\Manager as Assets_Manager; |
| @@ -14,9 +15,8 @@ | ||
| 14 | 15 | use Elementor\Core\Schemes\Manager as Schemes_Manager; |
| 15 | 16 | use Elementor\Core\Settings\Manager as Settings_Manager; |
| 16 | 17 | use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager; |
| 17 | 18 | use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals; |
| 18 | -use Elementor\Core\Upgrade\Manager as Upgrades_Manager; | |
| 19 | 19 | use Elementor\Modules\History\Revisions_Manager; |
| 20 | 20 | use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager; |
| 21 | 21 | use Elementor\Core\Logger\Manager as Log_Manager; |
| 22 | 22 | use Elementor\Modules\System_Info\Module as System_Info_Module; |
| @@ -360,9 +360,9 @@ | ||
| 360 | 360 | * @deprecated 2.1.0 Use `Plugin::$files_manager` instead |
| 361 | 361 | * |
| 362 | 362 | * @var Files_Manager |
| 363 | 363 | */ |
| 364 | - public $posts_css_manager; | |
| 364 | + private $posts_css_manager; | |
| 365 | 365 | |
| 366 | 366 | /** |
| 367 | 367 | * WordPress widgets manager. |
| 368 | 368 | * |
| @@ -442,8 +442,13 @@ | ||
| 442 | 442 | */ |
| 443 | 443 | public $app; |
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | + * @var Experiments_Manager | |
| 447 | + */ | |
| 448 | + public $experiments; | |
| 449 | + | |
| 450 | + /** | |
| 446 | 451 | * Clone. |
| 447 | 452 | * |
| 448 | 453 | * Disable class cloning and throw an error on object clone. |
| 449 | 454 | * |
| @@ -568,8 +573,9 @@ | ||
| 568 | 573 | * @since 1.0.0 |
| 569 | 574 | * @access private |
| 570 | 575 | */ |
| 571 | 576 | private function init_components() { |
| 577 | + $this->experiments = new Experiments_Manager(); | |
| 572 | 578 | $this->inspector = new Inspector(); |
| 573 | 579 | $this->debugger = $this->inspector; |
| 574 | 580 | |
| 575 | 581 | Settings_Manager::run(); |
| @@ -584,12 +590,8 @@ | ||
| 584 | 590 | $this->skins_manager = new Skins_Manager(); |
| 585 | 591 | $this->files_manager = new Files_Manager(); |
| 586 | 592 | $this->assets_manager = new Assets_Manager(); |
| 587 | 593 | $this->icons_manager = new Icons_Manager(); |
| 588 | - /* | |
| 589 | - * @TODO: Remove deprecated alias | |
| 590 | - */ | |
| 591 | - $this->posts_css_manager = $this->files_manager; | |
| 592 | 594 | $this->settings = new Settings(); |
| 593 | 595 | $this->tools = new Tools(); |
| 594 | 596 | $this->editor = new Editor(); |
| 595 | 597 | $this->preview = new Preview(); |
| @@ -631,29 +633,32 @@ | ||
| 631 | 633 | |
| 632 | 634 | $this->ajax = $this->common->get_component( 'ajax' ); |
| 633 | 635 | } |
| 634 | 636 | |
| 637 | + /** | |
| 638 | + * Get Legacy Mode | |
| 639 | + * | |
| 640 | + * @since 3.0.0 | |
| 641 | + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead | |
| 642 | + * | |
| 643 | + * @param string $mode_name Optional. Default is null | |
| 644 | + * | |
| 645 | + * @return bool|bool[] | |
| 646 | + */ | |
| 635 | 647 | public function get_legacy_mode( $mode_name = null ) { |
| 636 | - if ( ! $this->legacy_mode ) { | |
| 637 | - $optimized_dom_output = get_option( 'elementor_optimized_dom_output' ); | |
| 648 | + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation | |
| 649 | + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' ); | |
| 638 | 650 | |
| 639 | - if ( $optimized_dom_output ) { | |
| 640 | - $element_wrappers_legacy_mode = 'disabled' === $optimized_dom_output; | |
| 641 | - } else { | |
| 642 | - $element_wrappers_legacy_mode = true; | |
| 643 | - } | |
| 651 | + $legacy_mode = [ | |
| 652 | + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ), | |
| 653 | + ]; | |
| 644 | 654 | |
| 645 | - $this->legacy_mode = [ | |
| 646 | - 'elementWrappers' => $element_wrappers_legacy_mode, | |
| 647 | - ]; | |
| 648 | - } | |
| 649 | - | |
| 650 | 655 | if ( ! $mode_name ) { |
| 651 | - return $this->legacy_mode; | |
| 656 | + return $legacy_mode; | |
| 652 | 657 | } |
| 653 | 658 | |
| 654 | - if ( isset( $this->legacy_mode[ $mode_name ] ) ) { | |
| 655 | - return $this->legacy_mode[ $mode_name ]; | |
| 659 | + if ( isset( $legacy_mode[ $mode_name ] ) ) { | |
| 660 | + return $legacy_mode[ $mode_name ]; | |
| 656 | 661 | } |
| 657 | 662 | |
| 658 | 663 | // If there is no legacy mode with the given mode name; |
| 659 | 664 | return false; |
| @@ -691,8 +696,32 @@ | ||
| 691 | 696 | private function register_autoloader() { |
| 692 | 697 | require_once ELEMENTOR_PATH . '/includes/autoloader.php'; |
| 693 | 698 | |
| 694 | 699 | Autoloader::run(); |
| 700 | + } | |
| 701 | + | |
| 702 | + /** | |
| 703 | + * Plugin Magic Getter | |
| 704 | + * | |
| 705 | + * @since 3.1.0 | |
| 706 | + * @access public | |
| 707 | + * | |
| 708 | + * @param $property | |
| 709 | + * @return mixed | |
| 710 | + * @throws \Exception | |
| 711 | + */ | |
| 712 | + public function __get( $property ) { | |
| 713 | + if ( 'posts_css_manager' === $property ) { | |
| 714 | + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); | |
| 715 | + | |
| 716 | + return $this->files_manager; | |
| 717 | + } | |
| 718 | + | |
| 719 | + if ( property_exists( $this, $property ) ) { | |
| 720 | + throw new \Exception( 'Cannot access private property' ); | |
| 721 | + } | |
| 722 | + | |
| 723 | + return null; | |
| 695 | 724 | } |
| 696 | 725 | |
| 697 | 726 | /** |
| 698 | 727 | * Plugin constructor. |