mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user