Changeset 38864
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r38832 r38864 420 420 } 421 421 422 $prepared_comment['comment_agent'] = ''; 422 if ( ! isset( $prepared_comment['comment_agent'] ) ) { 423 $prepared_comment['comment_agent'] = ''; 424 } 425 423 426 $prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true ); 424 427 … … 889 892 } 890 893 894 if ( isset( $request['author_user_agent'] ) ) { 895 $prepared_comment['comment_agent'] = $request['author_user_agent']; 896 } 897 891 898 if ( isset( $request['type'] ) ) { 892 899 // Comment type "comment" needs to be created as an empty string. … … 976 983 'type' => 'string', 977 984 'context' => array( 'edit' ), 978 'readonly' => true, 985 'arg_options' => array( 986 'sanitize_callback' => 'sanitize_text_field', 987 ), 979 988 ), 980 989 'content' => array( -
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r38832 r38864 1065 1065 } 1066 1066 1067 public function test_create_comment_with_status_ and_IP() {1067 public function test_create_comment_with_status_IP_and_user_agent() { 1068 1068 $post_id = $this->factory->post->create(); 1069 1069 wp_set_current_user( $this->admin_id ); … … 1075 1075 'author_ip' => '139.130.4.5', 1076 1076 'author_url' => 'http://androidsdungeon.com', 1077 'author_user_agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', 1077 1078 'content' => 'Worst Comment Ever!', 1078 1079 'status' => 'approved', … … 1089 1090 $this->assertEquals( 'approved', $data['status'] ); 1090 1091 $this->assertEquals( '139.130.4.5', $data['author_ip'] ); 1092 $this->assertEquals( 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', $data['author_user_agent'] ); 1091 1093 } 1092 1094
Note: See TracChangeset
for help on using the changeset viewer.