- Timestamp:
- 11/21/2016 10:55:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r39327 r39337 459 459 } 460 460 461 $prepared_comment = $this->prepare_item_for_database( $request );462 463 if ( is_wp_error( $prepared_comment ) ) {464 return $prepared_comment;465 }466 467 461 // Do not allow comments to be created with a non-default type. 468 462 if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) { 469 463 return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) ); 470 464 } 465 466 $prepared_comment = $this->prepare_item_for_database( $request ); 467 if ( is_wp_error( $prepared_comment ) ) { 468 return $prepared_comment; 469 } 470 471 $prepared_comment['comment_type'] = ''; 471 472 472 473 /* … … 1088 1089 } elseif ( $request->get_header( 'user_agent' ) ) { 1089 1090 $prepared_comment['comment_agent'] = $request->get_header( 'user_agent' ); 1090 }1091 1092 if ( isset( $request['type'] ) ) {1093 // Comment type "comment" needs to be created as an empty string.1094 $prepared_comment['comment_type'] = 'comment' === $request['type'] ? '' : $request['type'];1095 1091 } 1096 1092 … … 1245 1241 'type' => 'string', 1246 1242 'context' => array( 'view', 'edit', 'embed' ), 1247 'default' => 'comment', 1248 'arg_options' => array( 1249 'sanitize_callback' => 'sanitize_key', 1250 ), 1243 'readonly' => true, 1251 1244 ), 1252 1245 ),
Note: See TracChangeset
for help on using the changeset viewer.