File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -244,13 +244,26 @@ Feature: Do global search/replace
244244 And a create-post-with-json-content.php file:
245245 """
246246 <?php
247- $post_id = wp_insert_post( [
248- 'post_type' => 'post',
249- 'post_status' => 'publish',
250- 'post_title' => 'Font Test',
251- 'post_content' => json_encode( [ 'src' => 'http://example.com/wp-content/uploads/fonts/test.woff2', 'fontWeight' => '400' ] ),
252- ] );
253- echo $post_id;
247+ // Insert directly via $wpdb to preserve backslash-escaped JSON (as WordPress font face data is stored).
248+ global $wpdb;
249+ $wpdb->insert(
250+ $wpdb->posts,
251+ [
252+ 'post_type' => 'post',
253+ 'post_status' => 'publish',
254+ 'post_title' => 'Font Test',
255+ 'post_content' => '{"src":"http:\/\/example.com\/wp-content\/uploads\/fonts\/test.woff2","fontWeight":"400"}',
256+ 'post_author' => 1,
257+ 'post_date' => '2024-01-01 00:00:00',
258+ 'post_date_gmt' => '2024-01-01 00:00:00',
259+ 'post_modified' => '2024-01-01 00:00:00',
260+ 'post_modified_gmt' => '2024-01-01 00:00:00',
261+ 'to_ping' => '',
262+ 'pinged' => '',
263+ 'post_content_filtered' => '',
264+ ]
265+ );
266+ echo $wpdb->insert_id;
254267 """
255268 And I run `wp eval-file create-post-with-json-content.php`
256269 Then save STDOUT as {POST_ID}
You can’t perform that action at this time.
0 commit comments