Changeset 34533
- Timestamp:
- 09/25/2015 04:40:30 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-functions.php
r34524 r34533 1378 1378 * 1379 1379 * @since 2.0.0 1380 * @since 4.4.0 Introduced `$comment_meta` argument. 1380 1381 * 1381 1382 * @global wpdb $wpdb WordPress database abstraction object. … … 1402 1403 * Default empty. 1403 1404 * @type string $comment_type Comment type. Default empty. 1405 * @type array $comment_meta Optional. Array of key/value pairs to be stored in commentmeta for the 1406 * new comment. 1404 1407 * @type int $user_id ID of the user who submitted the comment. Default 0. 1405 1408 * } … … 1439 1442 } 1440 1443 $comment = get_comment( $id ); 1444 1445 // If metadata is provided, store it. 1446 if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) { 1447 foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) { 1448 add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true ); 1449 } 1450 } 1441 1451 1442 1452 /** -
trunk/tests/phpunit/tests/comment.php
r34250 r34533 274 274 $this->assertFalse( $sent ); 275 275 } 276 277 /** 278 * @ticket 12431 279 */ 280 public function test_wp_new_comment_with_meta() { 281 $c = $this->factory->comment->create( array( 282 'comment_approved' => '1', 283 'comment_meta' => array( 284 'food' => 'taco', 285 'sauce' => 'fire' 286 ) 287 ) ); 288 289 $this->assertEquals( 'fire', get_comment_meta( $c, 'sauce', true ) ); 290 } 276 291 }
Note: See TracChangeset
for help on using the changeset viewer.