| @@ -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,10 +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 WP_REST_Request; | |
| 28 | +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools; | |
| 29 | +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager; | |
| 29 | 30 | |
| 30 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 31 | 32 | exit; |
| 32 | 33 | } |
| @@ -39,17 +40,10 @@ | ||
| 39 | 40 | * |
| 40 | 41 | * @since 1.0.0 |
| 41 | 42 | */ |
| 42 | 43 | class Plugin { |
| 43 | - | |
| 44 | 44 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 45 | 45 | |
| 46 | - private const SANITIZABLE_META_KEYS = [ | |
| 47 | - '_elementor_data', | |
| 48 | - '_elementor_page_settings', | |
| 49 | - '_elementor_global_class_data', | |
| 50 | - ]; | |
| 51 | - | |
| 52 | 46 | /** |
| 53 | 47 | * Instance. |
| 54 | 48 | * |
| 55 | 49 | * Holds the plugin instance. |
| @@ -100,8 +94,20 @@ | ||
| 100 | 94 | */ |
| 101 | 95 | public $documents; |
| 102 | 96 | |
| 103 | 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 | + /** | |
| 104 | 110 | * Elements manager. |
| 105 | 111 | * |
| 106 | 112 | * Holds the plugin elements manager. |
| 107 | 113 | * |
| @@ -431,8 +437,19 @@ | ||
| 431 | 437 | */ |
| 432 | 438 | public $logger; |
| 433 | 439 | |
| 434 | 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 | + /** | |
| 435 | 452 | * Upgrade manager. |
| 436 | 453 | * |
| 437 | 454 | * Holds the plugin upgrade manager. |
| 438 | 455 | * |
| @@ -485,9 +502,9 @@ | ||
| 485 | 502 | * |
| 486 | 503 | * @since 3.0.0 |
| 487 | 504 | * @access public |
| 488 | 505 | * |
| 489 | - * @var App\App | |
| 506 | + * @var Core\App\App | |
| 490 | 507 | */ |
| 491 | 508 | public $app; |
| 492 | 509 | |
| 493 | 510 | /** |
| @@ -563,13 +580,10 @@ | ||
| 563 | 580 | * @access public |
| 564 | 581 | * @since 1.0.0 |
| 565 | 582 | */ |
| 566 | 583 | public function __clone() { |
| 567 | - _doing_it_wrong( | |
| 568 | - __FUNCTION__, | |
| 569 | - sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 570 | - '1.0.0' | |
| 571 | - ); | |
| 584 | + // Cloning instances of the class is forbidden. | |
| 585 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 572 | 586 | } |
| 573 | 587 | |
| 574 | 588 | /** |
| 575 | 589 | * Wakeup. |
| @@ -579,13 +593,10 @@ | ||
| 579 | 593 | * @access public |
| 580 | 594 | * @since 1.0.0 |
| 581 | 595 | */ |
| 582 | 596 | public function __wakeup() { |
| 583 | - _doing_it_wrong( | |
| 584 | - __FUNCTION__, | |
| 585 | - sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 586 | - '1.0.0' | |
| 587 | - ); | |
| 597 | + // Unserializing instances of the class is forbidden. | |
| 598 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 588 | 599 | } |
| 589 | 600 | |
| 590 | 601 | /** |
| 591 | 602 | * Instance. |
| @@ -695,8 +706,9 @@ | ||
| 695 | 706 | $this->db = new DB(); |
| 696 | 707 | $this->controls_manager = new Controls_Manager(); |
| 697 | 708 | $this->documents = new Documents_Manager(); |
| 698 | 709 | $this->kits_manager = new Kits_Manager(); |
| 710 | + $this->schemes_manager = new Schemes_Manager(); | |
| 699 | 711 | $this->elements_manager = new Elements_Manager(); |
| 700 | 712 | $this->widgets_manager = new Widgets_Manager(); |
| 701 | 713 | $this->skins_manager = new Skins_Manager(); |
| 702 | 714 | $this->files_manager = new Files_Manager(); |
| @@ -722,9 +734,8 @@ | ||
| 722 | 734 | $this->admin_menu_manager = new Admin_Menu_Manager(); |
| 723 | 735 | $this->admin_menu_manager->register_actions(); |
| 724 | 736 | |
| 725 | 737 | User::init(); |
| 726 | - User_Data::init(); | |
| 727 | 738 | Api::init(); |
| 728 | 739 | Tracker::init(); |
| 729 | 740 | |
| 730 | 741 | $this->upgrade = new Core\Upgrade\Manager(); |
| @@ -729,9 +740,9 @@ | ||
| 729 | 740 | |
| 730 | 741 | $this->upgrade = new Core\Upgrade\Manager(); |
| 731 | 742 | $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager(); |
| 732 | 743 | |
| 733 | - $this->app = new App\App(); | |
| 744 | + $this->app = new Core\App\App(); | |
| 734 | 745 | |
| 735 | 746 | if ( is_admin() ) { |
| 736 | 747 | $this->heartbeat = new Heartbeat(); |
| 737 | 748 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| @@ -736,8 +747,9 @@ | ||
| 736 | 747 | $this->heartbeat = new Heartbeat(); |
| 737 | 748 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| 738 | 749 | $this->admin = new Admin(); |
| 739 | 750 | $this->beta_testers = new Beta_Testers(); |
| 751 | + new Elementor_3_Re_Migrate_Globals(); | |
| 740 | 752 | } |
| 741 | 753 | } |
| 742 | 754 | |
| 743 | 755 | /** |
| @@ -750,8 +762,38 @@ | ||
| 750 | 762 | $this->common->init_components(); |
| 751 | 763 | } |
| 752 | 764 | |
| 753 | 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 | + /** | |
| 754 | 796 | * Add custom post type support. |
| 755 | 797 | * |
| 756 | 798 | * Register Elementor support for all the supported post types defined by |
| 757 | 799 | * the user in the admin screen and saved as `elementor_cpt_support` option |
| @@ -785,16 +827,16 @@ | ||
| 785 | 827 | Autoloader::run(); |
| 786 | 828 | } |
| 787 | 829 | |
| 788 | 830 | /** |
| 789 | - * Magic getter for accessing certain properties. | |
| 831 | + * Plugin Magic Getter | |
| 790 | 832 | * |
| 791 | 833 | * @since 3.1.0 |
| 792 | 834 | * @access public |
| 793 | 835 | * |
| 794 | - * @param string $property The property name. | |
| 795 | - * @return mixed The property value or null if not found. | |
| 796 | - * @throws \Exception If trying to access a private property. | |
| 836 | + * @param $property | |
| 837 | + * @return mixed | |
| 838 | + * @throws \Exception | |
| 797 | 839 | */ |
| 798 | 840 | public function __get( $property ) { |
| 799 | 841 | if ( 'posts_css_manager' === $property ) { |
| 800 | 842 | self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); |
| @@ -806,9 +848,9 @@ | ||
| 806 | 848 | return Data_Manager::instance(); |
| 807 | 849 | } |
| 808 | 850 | |
| 809 | 851 | if ( property_exists( $this, $property ) ) { |
| 810 | - throw new \Exception( 'Cannot access private property.' ); | |
| 852 | + throw new \Exception( 'Cannot access private property' ); | |
| 811 | 853 | } |
| 812 | 854 | |
| 813 | 855 | return null; |
| 814 | 856 | } |
| @@ -831,46 +873,12 @@ | ||
| 831 | 873 | Compatibility::register_actions(); |
| 832 | 874 | |
| 833 | 875 | add_action( 'init', [ $this, 'init' ], 0 ); |
| 834 | 876 | add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 ); |
| 835 | - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 ); | |
| 836 | 877 | } |
| 837 | 878 | |
| 838 | 879 | final public static function get_title() { |
| 839 | 880 | return esc_html__( 'Elementor', 'elementor' ); |
| 840 | - } | |
| 841 | - | |
| 842 | - public function sanitize_post_data( $post, WP_REST_Request $request ) { | |
| 843 | - if ( current_user_can( 'unfiltered_html' ) ) { | |
| 844 | - return $post; | |
| 845 | - } | |
| 846 | - | |
| 847 | - $meta = $request->get_param( 'meta' ); | |
| 848 | - if ( empty( $meta ) || ! is_array( $meta ) ) { | |
| 849 | - return $post; | |
| 850 | - } | |
| 851 | - | |
| 852 | - foreach ( self::SANITIZABLE_META_KEYS as $meta_key ) { | |
| 853 | - $elementor_data = $meta[ $meta_key ] ?? null; | |
| 854 | - if ( is_null( $elementor_data ) ) { | |
| 855 | - continue; | |
| 856 | - } | |
| 857 | - if ( is_string( $elementor_data ) ) { | |
| 858 | - $elementor_data = json_decode( $elementor_data, true ); | |
| 859 | - } | |
| 860 | - if ( empty( $elementor_data ) ) { | |
| 861 | - continue; | |
| 862 | - } | |
| 863 | - | |
| 864 | - $elementor_data = map_deep($elementor_data, function ( $value ) { | |
| 865 | - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value ); | |
| 866 | - }); | |
| 867 | - | |
| 868 | - $meta[ $meta_key ] = wp_json_encode( $elementor_data ); | |
| 869 | - } | |
| 870 | - | |
| 871 | - $request->set_param( 'meta', $meta ); | |
| 872 | - return $post; | |
| 873 | 881 | } |
| 874 | 882 | } |
| 875 | 883 | |
| 876 | 884 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |