mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 12:44:31 +00:00
Allow metadata to be attached to comment at time of creation.
The new `$comment_meta` parameter of `wp_insert_comment()` allows an array of key/value pairs to be passed when creating a comment. These pairs are then stored as commentmeta when the comment has been created. Props tellyworth, wonderboymusic. Fixes #12431. git-svn-id: https://develop.svn.wordpress.org/trunk@34533 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -273,4 +273,19 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
$sent = wp_new_comment_notify_postauthor( $c );
|
||||
$this->assertFalse( $sent );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 12431
|
||||
*/
|
||||
public function test_wp_new_comment_with_meta() {
|
||||
$c = $this->factory->comment->create( array(
|
||||
'comment_approved' => '1',
|
||||
'comment_meta' => array(
|
||||
'food' => 'taco',
|
||||
'sauce' => 'fire'
|
||||
)
|
||||
) );
|
||||
|
||||
$this->assertEquals( 'fire', get_comment_meta( $c, 'sauce', true ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user