| @@ -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; |
| @@ -39,16 +38,10 @@ | ||
| 39 | 38 | * |
| 40 | 39 | * @since 1.0.0 |
| 41 | 40 | */ |
| 42 | 41 | class Plugin { |
| 43 | - | |
| 44 | 42 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 45 | 43 | |
| 46 | - private const SANITIZABLE_META_KEYS = [ | |
| 47 | - '_elementor_data', | |
| 48 | - '_elementor_page_settings', | |
| 49 | - ]; | |
| 50 | - | |
| 51 | 44 | /** |
| 52 | 45 | * Instance. |
| 53 | 46 | * |
| 54 | 47 | * Holds the plugin instance. |
| @@ -841,34 +834,26 @@ | ||
| 841 | 834 | public function sanitize_post_data( $post, WP_REST_Request $request ) { |
| 842 | 835 | if ( current_user_can( 'unfiltered_html' ) ) { |
| 843 | 836 | return $post; |
| 844 | 837 | } |
| 845 | - | |
| 846 | - $meta = $request->get_param( 'meta' ); | |
| 847 | - if ( empty( $meta ) || ! is_array( $meta ) ) { | |
| 838 | + $request_body = json_decode( $request->get_body(), true ); | |
| 839 | + $meta = $request_body['meta']; | |
| 840 | + if ( is_null( $meta ) ) { | |
| 848 | 841 | return $post; |
| 849 | 842 | } |
| 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 ); | |
| 843 | + $elementor_data = $meta['_elementor_data'] ?? []; | |
| 844 | + if ( is_string( $elementor_data ) ) { | |
| 845 | + $elementor_data = json_decode( $elementor_data ); | |
| 868 | 846 | } |
| 847 | + if ( is_null( $elementor_data ) ) { | |
| 848 | + return $post; | |
| 849 | + } | |
| 869 | 850 | |
| 870 | - $request->set_param( 'meta', $meta ); | |
| 851 | + $elementor_data = map_deep( $elementor_data, function ( $value ) { | |
| 852 | + return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value ); | |
| 853 | + } ); | |
| 854 | + $request_body['meta']['_elementor_data'] = json_encode( $elementor_data ); | |
| 855 | + $request->set_body( json_encode( $request_body ) ); | |
| 871 | 856 | return $post; |
| 872 | 857 | } |
| 873 | 858 | } |
| 874 | 859 | |