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