| @@ -24,9 +24,8 @@ | ||
| 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 | 27 | use Elementor\Core\Files\Uploads_Manager; |
| 28 | -use WP_REST_Request; | |
| 29 | 28 | |
| 30 | 29 | if ( ! defined( 'ABSPATH' ) ) { |
| 31 | 30 | exit; |
| 32 | 31 | } |
| @@ -42,13 +41,8 @@ | ||
| 42 | 41 | class Plugin { |
| 43 | 42 | |
| 44 | 43 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 45 | 44 | |
| 46 | - private const SANITIZABLE_META_KEYS = [ | |
| 47 | - '_elementor_data', | |
| 48 | - '_elementor_page_settings', | |
| 49 | - ]; | |
| 50 | - | |
| 51 | 45 | /** |
| 52 | 46 | * Instance. |
| 53 | 47 | * |
| 54 | 48 | * Holds the plugin instance. |
| @@ -830,46 +824,12 @@ | ||
| 830 | 824 | Compatibility::register_actions(); |
| 831 | 825 | |
| 832 | 826 | add_action( 'init', [ $this, 'init' ], 0 ); |
| 833 | 827 | add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 ); |
| 834 | - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 ); | |
| 835 | 828 | } |
| 836 | 829 | |
| 837 | 830 | final public static function get_title() { |
| 838 | 831 | return esc_html__( 'Elementor', 'elementor' ); |
| 839 | - } | |
| 840 | - | |
| 841 | - public function sanitize_post_data( $post, WP_REST_Request $request ) { | |
| 842 | - if ( current_user_can( 'unfiltered_html' ) ) { | |
| 843 | - return $post; | |
| 844 | - } | |
| 845 | - | |
| 846 | - $meta = $request->get_param( 'meta' ); | |
| 847 | - if ( empty( $meta ) || ! is_array( $meta ) ) { | |
| 848 | - return $post; | |
| 849 | - } | |
| 850 | - | |
| 851 | - foreach ( self::SANITIZABLE_META_KEYS as $meta_key ) { | |
| 852 | - $elementor_data = $meta[ $meta_key ] ?? null; | |
| 853 | - if ( is_null( $elementor_data ) ) { | |
| 854 | - continue; | |
| 855 | - } | |
| 856 | - if ( is_string( $elementor_data ) ) { | |
| 857 | - $elementor_data = json_decode( $elementor_data, true ); | |
| 858 | - } | |
| 859 | - if ( empty( $elementor_data ) ) { | |
| 860 | - continue; | |
| 861 | - } | |
| 862 | - | |
| 863 | - $elementor_data = map_deep($elementor_data, function ( $value ) { | |
| 864 | - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value ); | |
| 865 | - }); | |
| 866 | - | |
| 867 | - $meta[ $meta_key ] = wp_json_encode( $elementor_data ); | |
| 868 | - } | |
| 869 | - | |
| 870 | - $request->set_param( 'meta', $meta ); | |
| 871 | - return $post; | |
| 872 | 832 | } |
| 873 | 833 | } |
| 874 | 834 | |
| 875 | 835 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |