| @@ -274,9 +274,9 @@ | ||
| 274 | 274 | * @param WP_Post $source_post Post object being copied. |
| 275 | 275 | * @param int $target_post_id Target post ID. |
| 276 | 276 | * @return array Modified post data. |
| 277 | 277 | */ |
| 278 | - public function copy_footnotes( $data, $source_post, $target_post_id ) { | |
| 278 | + public function copy_footnotes( $data, $source_post, $target_post_id ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Kept for backward compatibility. | |
| 279 | 279 | $footnotes_json = get_post_meta( $source_post->ID, 'footnotes', true ); |
| 280 | 280 | |
| 281 | 281 | if ( '' === $footnotes_json ) { |
| 282 | 282 | return $data; |
| @@ -310,10 +310,10 @@ | ||
| 310 | 310 | $data['post_content'] = str_replace( 'id="' . $old_id . '-link"', 'id="' . $new_id . '-link"', $data['post_content'] ); |
| 311 | 311 | $data['post_content'] = str_replace( 'id="' . $old_id . '"', 'id="' . $new_id . '"', $data['post_content'] ); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - // Save the footnotes meta with new IDs. | |
| 315 | - update_post_meta( $target_post_id, 'footnotes', wp_json_encode( $footnotes, JSON_UNESCAPED_SLASHES ) ); | |
| 314 | + // Saved by wp_update_post() in update_content(), which slashes $data to match update_post_meta()'s unslashing. | |
| 315 | + $data['meta_input']['footnotes'] = wp_json_encode( $footnotes, JSON_UNESCAPED_SLASHES ); | |
| 316 | 316 | |
| 317 | 317 | return $data; |
| 318 | 318 | } |
| 319 | 319 | |