| @@ -79,17 +79,9 @@ | ||
| 79 | 79 | foreach ( $post_ids as $post_id ) { |
| 80 | 80 | $post_id = intval( $post_id ); |
| 81 | 81 | $post = get_post( $post_id ); |
| 82 | 82 | $post_meta = get_post_meta( $post_id ); |
| 83 | - | |
| 84 | - // The view counter belongs to this site's traffic, not to the form. These | |
| 85 | - // payloads feed shared starter templates, so shipping it would hand every | |
| 86 | - // importer a stranger's numbers. The import side already refuses the key, | |
| 87 | - // so this is about not exporting it in the first place. | |
| 88 | - if ( is_array( $post_meta ) ) { | |
| 89 | - unset( $post_meta[ \SRFM\Inc\Form_Views::META_KEY ] ); | |
| 90 | - } | |
| 91 | - $posts[] = [ | |
| 83 | + $posts[] = [ | |
| 92 | 84 | 'post' => $post, |
| 93 | 85 | 'post_meta' => $post_meta, |
| 94 | 86 | ]; |
| 95 | 87 | } |
| @@ -303,14 +295,8 @@ | ||
| 303 | 295 | if ( ! in_array( $meta_key, $allowed_keys, true ) ) { |
| 304 | 296 | continue; |
| 305 | 297 | } |
| 306 | 298 | |
| 307 | - // Note: add_post_meta() internally runs wp_unslash() on the value before | |
| 308 | - // invoking the registered sanitize_callback. Imported values are unslashed, | |
| 309 | - // so without re-slashing, backslashes are stripped — corrupting JSON-string | |
| 310 | - // metas (e.g. _srfm_save_resume, _srfm_conditional_confirmation) whose escaped | |
| 311 | - // quotes (\") then fail json_decode() in their sanitizers, wiping the value to | |
| 312 | - // an empty string. wp_slash() pre-escapes so wp_unslash() restores the original. | |
| 313 | 299 | if ( in_array( $meta_key, $unserialized_meta_keys, true ) ) { |
| 314 | 300 | // Complex array metas — sanitize_callback registered via register_post_meta() |
| 315 | 301 | // is automatically invoked by add_post_meta() → update_metadata() pipeline. |
| 316 | 302 | // When Pro is inactive, some keys may lack a registered callback — apply fallback. |
| @@ -316,9 +302,9 @@ | ||
| 316 | 302 | // When Pro is inactive, some keys may lack a registered callback — apply fallback. |
| 317 | 303 | if ( empty( $registered[ $meta_key ]['sanitize_callback'] ) ) { |
| 318 | 304 | $meta_value = Helper::sanitize_by_type( $meta_value ); |
| 319 | 305 | } |
| 320 | - add_post_meta( $post_id, $meta_key, wp_slash( $meta_value ) ); | |
| 306 | + add_post_meta( $post_id, $meta_key, $meta_value ); | |
| 321 | 307 | } else { |
| 322 | 308 | // Scalar metas — unwrap single-element arrays produced by get_post_meta(). |
| 323 | 309 | $raw_value = is_array( $meta_value ) && isset( $meta_value[0] ) ? $meta_value[0] : $meta_value; |
| 324 | 310 | // Fallback sanitization — skip when a registered callback already handles it. |
| @@ -324,9 +310,9 @@ | ||
| 324 | 310 | // Fallback sanitization — skip when a registered callback already handles it. |
| 325 | 311 | if ( is_string( $raw_value ) && empty( $registered[ $meta_key ]['sanitize_callback'] ) ) { |
| 326 | 312 | $raw_value = sanitize_text_field( $raw_value ); |
| 327 | 313 | } |
| 328 | - add_post_meta( $post_id, $meta_key, wp_slash( $raw_value ) ); | |
| 314 | + add_post_meta( $post_id, $meta_key, $raw_value ); | |
| 329 | 315 | } |
| 330 | 316 | } |
| 331 | 317 | } else { |
| 332 | 318 | return new \WP_Error( 'import_forms_invalid_post_type', __( 'Unable to import form.', 'sureforms' ) ); |