diff --git src/wp-includes/post-functions.php src/wp-includes/post-functions.php
index fdd01ee..147c3a4 100644
|
|
|
function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
|
| 2775 | 2775 | * |
| 2776 | 2776 | * @since 1.0.0 |
| 2777 | 2777 | * @since 4.2.0 Support was added for encoding emoji in the post title, content, and excerpt. |
| | 2778 | * @since 4.4.0 A 'meta_input' array can now be passed to $postarr to add post meta data. |
| 2778 | 2779 | * |
| 2779 | 2780 | * @see sanitize_post() |
| 2780 | 2781 | * @global wpdb $wpdb WordPress database abstraction object. |
| … |
… |
function wp_insert_post( $postarr, $wp_error = false ) {
|
| 3172 | 3173 | } |
| 3173 | 3174 | } |
| 3174 | 3175 | |
| | 3176 | if ( ! empty( $postarr['meta_input'] ) ) { |
| | 3177 | foreach ( $postarr['meta_input'] as $field => $value ) { |
| | 3178 | update_post_meta( $post_ID, $field, $value ); |
| | 3179 | } |
| | 3180 | } |
| | 3181 | |
| 3175 | 3182 | $current_guid = get_post_field( 'guid', $post_ID ); |
| 3176 | 3183 | |
| 3177 | 3184 | // Set GUID. |
diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
index d51b546..ac2ca71 100644
|
|
|
class Tests_Post extends WP_UnitTestCase {
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
| | 456 | * @ticket 20451 |
| | 457 | */ |
| | 458 | public function test_wp_insert_post_with_meta_input() { |
| | 459 | $post_id = wp_insert_post( array( |
| | 460 | 'post_title' => '', |
| | 461 | 'post_content' => 'test', |
| | 462 | 'post_status' => 'publish', |
| | 463 | 'post_type' => 'post', |
| | 464 | 'meta_input' => array( |
| | 465 | 'hello' => 'world', |
| | 466 | 'foo' => 'bar' |
| | 467 | ) |
| | 468 | ) ); |
| | 469 | |
| | 470 | $this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) ); |
| | 471 | $this->assertEquals( 'bar', get_post_meta( $post_id, 'foo', true ) ); |
| | 472 | } |
| | 473 | |
| | 474 | /** |
| 456 | 475 | * @ticket 5364 |
| 457 | 476 | */ |
| 458 | 477 | function test_delete_future_post_cron() { |