| @@ -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; |
| @@ -24,9 +23,8 @@ | ||
| 24 | 23 | use Elementor\Modules\System_Info\Module as System_Info_Module; |
| 25 | 24 | use Elementor\Data\Manager as Data_Manager; |
| 26 | 25 | use Elementor\Data\V2\Manager as Data_Manager_V2; |
| 27 | 26 | use Elementor\Core\Files\Uploads_Manager; |
| 28 | -use WP_REST_Request; | |
| 29 | 27 | |
| 30 | 28 | if ( ! defined( 'ABSPATH' ) ) { |
| 31 | 29 | exit; |
| 32 | 30 | } |
| @@ -39,17 +37,10 @@ | ||
| 39 | 37 | * |
| 40 | 38 | * @since 1.0.0 |
| 41 | 39 | */ |
| 42 | 40 | class Plugin { |
| 43 | - | |
| 44 | 41 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 45 | 42 | |
| 46 | - private const SANITIZABLE_META_KEYS = [ | |
| 47 | - '_elementor_data', | |
| 48 | - '_elementor_page_settings', | |
| 49 | - '_elementor_global_class_data', | |
| 50 | - ]; | |
| 51 | - | |
| 52 | 43 | /** |
| 53 | 44 | * Instance. |
| 54 | 45 | * |
| 55 | 46 | * Holds the plugin instance. |
| @@ -831,46 +822,12 @@ | ||
| 831 | 822 | Compatibility::register_actions(); |
| 832 | 823 | |
| 833 | 824 | add_action( 'init', [ $this, 'init' ], 0 ); |
| 834 | 825 | 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 | 826 | } |
| 837 | 827 | |
| 838 | 828 | final public static function get_title() { |
| 839 | 829 | 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 | 830 | } |
| 874 | 831 | } |
| 875 | 832 | |
| 876 | 833 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |