| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | namespace Elementor; |
| 4 | 3 | |
| 5 | 4 | use Elementor\Core\Admin\Menu\Admin_Menu_Manager; |
| 6 | 5 | use Elementor\Core\Wp_Api; |
| @@ -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 | * |
| @@ -424,8 +437,19 @@ | ||
| 424 | 437 | */ |
| 425 | 438 | public $logger; |
| 426 | 439 | |
| 427 | 440 | /** |
| 441 | + * Dev tools. | |
| 442 | + * | |
| 443 | + * Holds the plugin dev tools. | |
| 444 | + * | |
| 445 | + * @access private | |
| 446 | + * | |
| 447 | + * @var Dev_Tools | |
| 448 | + */ | |
| 449 | + private $dev_tools; | |
| 450 | + | |
| 451 | + /** | |
| 428 | 452 | * Upgrade manager. |
| 429 | 453 | * |
| 430 | 454 | * Holds the plugin upgrade manager. |
| 431 | 455 | * |
| @@ -556,13 +580,10 @@ | ||
| 556 | 580 | * @access public |
| 557 | 581 | * @since 1.0.0 |
| 558 | 582 | */ |
| 559 | 583 | 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 | - ); | |
| 584 | + // Cloning instances of the class is forbidden. | |
| 585 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 565 | 586 | } |
| 566 | 587 | |
| 567 | 588 | /** |
| 568 | 589 | * Wakeup. |
| @@ -572,13 +593,10 @@ | ||
| 572 | 593 | * @access public |
| 573 | 594 | * @since 1.0.0 |
| 574 | 595 | */ |
| 575 | 596 | 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 | - ); | |
| 597 | + // Unserializing instances of the class is forbidden. | |
| 598 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 581 | 599 | } |
| 582 | 600 | |
| 583 | 601 | /** |
| 584 | 602 | * Instance. |
| @@ -688,8 +706,9 @@ | ||
| 688 | 706 | $this->db = new DB(); |
| 689 | 707 | $this->controls_manager = new Controls_Manager(); |
| 690 | 708 | $this->documents = new Documents_Manager(); |
| 691 | 709 | $this->kits_manager = new Kits_Manager(); |
| 710 | + $this->schemes_manager = new Schemes_Manager(); | |
| 692 | 711 | $this->elements_manager = new Elements_Manager(); |
| 693 | 712 | $this->widgets_manager = new Widgets_Manager(); |
| 694 | 713 | $this->skins_manager = new Skins_Manager(); |
| 695 | 714 | $this->files_manager = new Files_Manager(); |
| @@ -715,9 +734,8 @@ | ||
| 715 | 734 | $this->admin_menu_manager = new Admin_Menu_Manager(); |
| 716 | 735 | $this->admin_menu_manager->register_actions(); |
| 717 | 736 | |
| 718 | 737 | User::init(); |
| 719 | - User_Data::init(); | |
| 720 | 738 | Api::init(); |
| 721 | 739 | Tracker::init(); |
| 722 | 740 | |
| 723 | 741 | $this->upgrade = new Core\Upgrade\Manager(); |
| @@ -729,8 +747,9 @@ | ||
| 729 | 747 | $this->heartbeat = new Heartbeat(); |
| 730 | 748 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| 731 | 749 | $this->admin = new Admin(); |
| 732 | 750 | $this->beta_testers = new Beta_Testers(); |
| 751 | + new Elementor_3_Re_Migrate_Globals(); | |
| 733 | 752 | } |
| 734 | 753 | } |
| 735 | 754 | |
| 736 | 755 | /** |
| @@ -743,8 +762,38 @@ | ||
| 743 | 762 | $this->common->init_components(); |
| 744 | 763 | } |
| 745 | 764 | |
| 746 | 765 | /** |
| 766 | + * Get Legacy Mode | |
| 767 | + * | |
| 768 | + * @since 3.0.0 | |
| 769 | + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead | |
| 770 | + * | |
| 771 | + * @param string $mode_name Optional. Default is null | |
| 772 | + * | |
| 773 | + * @return bool|bool[] | |
| 774 | + */ | |
| 775 | + public function get_legacy_mode( $mode_name = null ) { | |
| 776 | + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation | |
| 777 | + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' ); | |
| 778 | + | |
| 779 | + $legacy_mode = [ | |
| 780 | + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ), | |
| 781 | + ]; | |
| 782 | + | |
| 783 | + if ( ! $mode_name ) { | |
| 784 | + return $legacy_mode; | |
| 785 | + } | |
| 786 | + | |
| 787 | + if ( isset( $legacy_mode[ $mode_name ] ) ) { | |
| 788 | + return $legacy_mode[ $mode_name ]; | |
| 789 | + } | |
| 790 | + | |
| 791 | + // If there is no legacy mode with the given mode name; | |
| 792 | + return false; | |
| 793 | + } | |
| 794 | + | |
| 795 | + /** | |
| 747 | 796 | * Add custom post type support. |
| 748 | 797 | * |
| 749 | 798 | * Register Elementor support for all the supported post types defined by |
| 750 | 799 | * the user in the admin screen and saved as `elementor_cpt_support` option |
| @@ -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' ); |
| @@ -799,9 +848,9 @@ | ||
| 799 | 848 | return Data_Manager::instance(); |
| 800 | 849 | } |
| 801 | 850 | |
| 802 | 851 | if ( property_exists( $this, $property ) ) { |
| 803 | - throw new \Exception( 'Cannot access private property.' ); | |
| 852 | + throw new \Exception( 'Cannot access private property' ); | |
| 804 | 853 | } |
| 805 | 854 | |
| 806 | 855 | return null; |
| 807 | 856 | } |