| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | namespace Elementor; |
| 4 | 3 | |
| 5 | -use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 6 | 4 | use Elementor\Core\Wp_Api; |
| 7 | 5 | use Elementor\Core\Admin\Admin; |
| 8 | 6 | use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; |
| 9 | 7 | use Elementor\Core\Common\App as CommonApp; |
| @@ -14,10 +12,12 @@ | ||
| 14 | 12 | use Elementor\Core\Editor\Editor; |
| 15 | 13 | use Elementor\Core\Files\Manager as Files_Manager; |
| 16 | 14 | use Elementor\Core\Files\Assets\Manager as Assets_Manager; |
| 17 | 15 | use Elementor\Core\Modules_Manager; |
| 16 | +use Elementor\Core\Schemes\Manager as Schemes_Manager; | |
| 18 | 17 | use Elementor\Core\Settings\Manager as Settings_Manager; |
| 19 | 18 | use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager; |
| 19 | +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals; | |
| 20 | 20 | use Elementor\Modules\History\Revisions_Manager; |
| 21 | 21 | use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager; |
| 22 | 22 | use Elementor\Core\Logger\Manager as Log_Manager; |
| 23 | 23 | use Elementor\Core\Page_Assets\Loader as Assets_Loader; |
| @@ -23,9 +23,10 @@ | ||
| 23 | 23 | use Elementor\Core\Page_Assets\Loader as Assets_Loader; |
| 24 | 24 | use Elementor\Modules\System_Info\Module as System_Info_Module; |
| 25 | 25 | use Elementor\Data\Manager as Data_Manager; |
| 26 | 26 | use Elementor\Data\V2\Manager as Data_Manager_V2; |
| 27 | -use Elementor\Core\Files\Uploads_Manager; | |
| 27 | +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools; | |
| 28 | +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager; | |
| 28 | 29 | |
| 29 | 30 | if ( ! defined( 'ABSPATH' ) ) { |
| 30 | 31 | exit; |
| 31 | 32 | } |
| @@ -38,9 +39,8 @@ | ||
| 38 | 39 | * |
| 39 | 40 | * @since 1.0.0 |
| 40 | 41 | */ |
| 41 | 42 | class Plugin { |
| 42 | - | |
| 43 | 43 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Instance. |
| @@ -93,8 +93,20 @@ | ||
| 93 | 93 | */ |
| 94 | 94 | public $documents; |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | + * Schemes manager. | |
| 98 | + * | |
| 99 | + * Holds the plugin schemes manager. | |
| 100 | + * | |
| 101 | + * @since 1.0.0 | |
| 102 | + * @access public | |
| 103 | + * | |
| 104 | + * @var Schemes_Manager | |
| 105 | + */ | |
| 106 | + public $schemes_manager; | |
| 107 | + | |
| 108 | + /** | |
| 97 | 109 | * Elements manager. |
| 98 | 110 | * |
| 99 | 111 | * Holds the plugin elements manager. |
| 100 | 112 | * |
| @@ -396,13 +408,8 @@ | ||
| 396 | 408 | */ |
| 397 | 409 | public $inspector; |
| 398 | 410 | |
| 399 | 411 | /** |
| 400 | - * @var Admin_Menu_Manager | |
| 401 | - */ | |
| 402 | - public $admin_menu_manager; | |
| 403 | - | |
| 404 | - /** | |
| 405 | 412 | * Common functionality. |
| 406 | 413 | * |
| 407 | 414 | * Holds the plugin common functionality. |
| 408 | 415 | * |
| @@ -424,8 +431,19 @@ | ||
| 424 | 431 | */ |
| 425 | 432 | public $logger; |
| 426 | 433 | |
| 427 | 434 | /** |
| 435 | + * Dev tools. | |
| 436 | + * | |
| 437 | + * Holds the plugin dev tools. | |
| 438 | + * | |
| 439 | + * @access private | |
| 440 | + * | |
| 441 | + * @var Dev_Tools | |
| 442 | + */ | |
| 443 | + private $dev_tools; | |
| 444 | + | |
| 445 | + /** | |
| 428 | 446 | * Upgrade manager. |
| 429 | 447 | * |
| 430 | 448 | * Holds the plugin upgrade manager. |
| 431 | 449 | * |
| @@ -478,9 +496,9 @@ | ||
| 478 | 496 | * |
| 479 | 497 | * @since 3.0.0 |
| 480 | 498 | * @access public |
| 481 | 499 | * |
| 482 | - * @var App\App | |
| 500 | + * @var Core\App\App | |
| 483 | 501 | */ |
| 484 | 502 | public $app; |
| 485 | 503 | |
| 486 | 504 | /** |
| @@ -556,13 +574,10 @@ | ||
| 556 | 574 | * @access public |
| 557 | 575 | * @since 1.0.0 |
| 558 | 576 | */ |
| 559 | 577 | public function __clone() { |
| 560 | - _doing_it_wrong( | |
| 561 | - __FUNCTION__, | |
| 562 | - sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 563 | - '1.0.0' | |
| 564 | - ); | |
| 578 | + // Cloning instances of the class is forbidden. | |
| 579 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 565 | 580 | } |
| 566 | 581 | |
| 567 | 582 | /** |
| 568 | 583 | * Wakeup. |
| @@ -572,13 +587,10 @@ | ||
| 572 | 587 | * @access public |
| 573 | 588 | * @since 1.0.0 |
| 574 | 589 | */ |
| 575 | 590 | public function __wakeup() { |
| 576 | - _doing_it_wrong( | |
| 577 | - __FUNCTION__, | |
| 578 | - sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 579 | - '1.0.0' | |
| 580 | - ); | |
| 591 | + // Unserializing instances of the class is forbidden. | |
| 592 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 581 | 593 | } |
| 582 | 594 | |
| 583 | 595 | /** |
| 584 | 596 | * Instance. |
| @@ -688,8 +700,9 @@ | ||
| 688 | 700 | $this->db = new DB(); |
| 689 | 701 | $this->controls_manager = new Controls_Manager(); |
| 690 | 702 | $this->documents = new Documents_Manager(); |
| 691 | 703 | $this->kits_manager = new Kits_Manager(); |
| 704 | + $this->schemes_manager = new Schemes_Manager(); | |
| 692 | 705 | $this->elements_manager = new Elements_Manager(); |
| 693 | 706 | $this->widgets_manager = new Widgets_Manager(); |
| 694 | 707 | $this->skins_manager = new Skins_Manager(); |
| 695 | 708 | $this->files_manager = new Files_Manager(); |
| @@ -711,13 +724,9 @@ | ||
| 711 | 724 | $this->wp = new Wp_Api(); |
| 712 | 725 | $this->assets_loader = new Assets_Loader(); |
| 713 | 726 | $this->uploads_manager = new Uploads_Manager(); |
| 714 | 727 | |
| 715 | - $this->admin_menu_manager = new Admin_Menu_Manager(); | |
| 716 | - $this->admin_menu_manager->register_actions(); | |
| 717 | - | |
| 718 | 728 | User::init(); |
| 719 | - User_Data::init(); | |
| 720 | 729 | Api::init(); |
| 721 | 730 | Tracker::init(); |
| 722 | 731 | |
| 723 | 732 | $this->upgrade = new Core\Upgrade\Manager(); |
| @@ -722,9 +731,9 @@ | ||
| 722 | 731 | |
| 723 | 732 | $this->upgrade = new Core\Upgrade\Manager(); |
| 724 | 733 | $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager(); |
| 725 | 734 | |
| 726 | - $this->app = new App\App(); | |
| 735 | + $this->app = new Core\App\App(); | |
| 727 | 736 | |
| 728 | 737 | if ( is_admin() ) { |
| 729 | 738 | $this->heartbeat = new Heartbeat(); |
| 730 | 739 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| @@ -729,8 +738,9 @@ | ||
| 729 | 738 | $this->heartbeat = new Heartbeat(); |
| 730 | 739 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| 731 | 740 | $this->admin = new Admin(); |
| 732 | 741 | $this->beta_testers = new Beta_Testers(); |
| 742 | + new Elementor_3_Re_Migrate_Globals(); | |
| 733 | 743 | } |
| 734 | 744 | } |
| 735 | 745 | |
| 736 | 746 | /** |
| @@ -743,8 +753,38 @@ | ||
| 743 | 753 | $this->common->init_components(); |
| 744 | 754 | } |
| 745 | 755 | |
| 746 | 756 | /** |
| 757 | + * Get Legacy Mode | |
| 758 | + * | |
| 759 | + * @since 3.0.0 | |
| 760 | + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead | |
| 761 | + * | |
| 762 | + * @param string $mode_name Optional. Default is null | |
| 763 | + * | |
| 764 | + * @return bool|bool[] | |
| 765 | + */ | |
| 766 | + public function get_legacy_mode( $mode_name = null ) { | |
| 767 | + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation | |
| 768 | + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' ); | |
| 769 | + | |
| 770 | + $legacy_mode = [ | |
| 771 | + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ), | |
| 772 | + ]; | |
| 773 | + | |
| 774 | + if ( ! $mode_name ) { | |
| 775 | + return $legacy_mode; | |
| 776 | + } | |
| 777 | + | |
| 778 | + if ( isset( $legacy_mode[ $mode_name ] ) ) { | |
| 779 | + return $legacy_mode[ $mode_name ]; | |
| 780 | + } | |
| 781 | + | |
| 782 | + // If there is no legacy mode with the given mode name; | |
| 783 | + return false; | |
| 784 | + } | |
| 785 | + | |
| 786 | + /** | |
| 747 | 787 | * Add custom post type support. |
| 748 | 788 | * |
| 749 | 789 | * Register Elementor support for all the supported post types defined by |
| 750 | 790 | * the user in the admin screen and saved as `elementor_cpt_support` option |
| @@ -778,16 +818,16 @@ | ||
| 778 | 818 | Autoloader::run(); |
| 779 | 819 | } |
| 780 | 820 | |
| 781 | 821 | /** |
| 782 | - * Magic getter for accessing certain properties. | |
| 822 | + * Plugin Magic Getter | |
| 783 | 823 | * |
| 784 | 824 | * @since 3.1.0 |
| 785 | 825 | * @access public |
| 786 | 826 | * |
| 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. | |
| 827 | + * @param $property | |
| 828 | + * @return mixed | |
| 829 | + * @throws \Exception | |
| 790 | 830 | */ |
| 791 | 831 | public function __get( $property ) { |
| 792 | 832 | if ( 'posts_css_manager' === $property ) { |
| 793 | 833 | self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); |
| @@ -799,9 +839,9 @@ | ||
| 799 | 839 | return Data_Manager::instance(); |
| 800 | 840 | } |
| 801 | 841 | |
| 802 | 842 | if ( property_exists( $this, $property ) ) { |
| 803 | - throw new \Exception( 'Cannot access private property.' ); | |
| 843 | + throw new \Exception( 'Cannot access private property' ); | |
| 804 | 844 | } |
| 805 | 845 | |
| 806 | 846 | return null; |
| 807 | 847 | } |