Allow wp_insert_post() to accept a meta_input argument. Devs should use register_meta() to ensure that specific values specified by key are sanitized properly.

Adds unit test.

Props CoenJacobs, swissspidy.
Fixes #20451.


git-svn-id: https://develop.svn.wordpress.org/trunk@33910 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-05 19:49:53 +00:00
parent 7b3b1c12d5
commit 26dd8b5b08
2 changed files with 26 additions and 0 deletions
+19
View File
@@ -452,6 +452,25 @@ class Tests_Post extends WP_UnitTestCase {
$this->assertContains( 'wptests_pt=' . $p, $post->guid );
}
/**
* @ticket 20451
*/
public function test_wp_insert_post_with_meta_input() {
$post_id = wp_insert_post( array(
'post_title' => '',
'post_content' => 'test',
'post_status' => 'publish',
'post_type' => 'post',
'meta_input' => array(
'hello' => 'world',
'foo' => 'bar'
)
) );
$this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) );
$this->assertEquals( 'bar', get_post_meta( $post_id, 'foo', true ) );
}
/**
* @ticket 5364
*/