- Timestamp:
- 11/18/2016 06:52:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r39290 r39292 122 122 123 123 if ( ! current_user_can( 'edit_posts' ) ) { 124 $protected_params = array( 'author', 'author_exclude', ' karma', 'author_email', 'type', 'status' );124 $protected_params = array( 'author', 'author_exclude', 'author_email', 'type', 'status' ); 125 125 $forbidden_params = array(); 126 126 … … 173 173 'exclude' => 'comment__not_in', 174 174 'include' => 'comment__in', 175 'karma' => 'karma',176 175 'offset' => 'offset', 177 176 'order' => 'order', … … 198 197 199 198 // Ensure certain parameter values default to empty strings. 200 foreach ( array( 'author_email', ' karma', 'search' ) as $param ) {199 foreach ( array( 'author_email', 'search' ) as $param ) { 201 200 if ( ! isset( $prepared_args[ $param ] ) ) { 202 201 $prepared_args[ $param ] = ''; … … 373 372 } 374 373 375 // Limit who can set comment `author` , `karma`or `status` to anything other than the default.374 // Limit who can set comment `author` or `status` to anything other than the default. 376 375 if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) { 377 376 return new WP_Error( 'rest_comment_invalid_author', __( 'Comment author invalid.' ), array( 'status' => rest_authorization_required_code() ) ); 378 }379 380 if ( isset( $request['karma'] ) && $request['karma'] > 0 && ! current_user_can( 'moderate_comments' ) ) {381 return new WP_Error( 'rest_comment_invalid_karma', __( 'Sorry, you are not allowed to set karma for comments.' ), array( 'status' => rest_authorization_required_code() ) );382 377 } 383 378 … … 818 813 'raw' => $comment->comment_content, 819 814 ), 820 'karma' => (int) $comment->comment_karma,821 815 'link' => get_comment_link( $comment ), 822 816 'status' => $this->prepare_status_response( $comment->comment_approved ), … … 1059 1053 // Comment type "comment" needs to be created as an empty string. 1060 1054 $prepared_comment['comment_type'] = 'comment' === $request['type'] ? '' : $request['type']; 1061 }1062 1063 if ( isset( $request['karma'] ) ) {1064 $prepared_comment['comment_karma'] = $request['karma'] ;1065 1055 } 1066 1056 … … 1185 1175 'context' => array( 'view', 'edit' ), 1186 1176 ), 1187 'karma' => array(1188 'description' => __( 'Karma for the object.' ),1189 'type' => 'integer',1190 'context' => array( 'edit' ),1191 ),1192 1177 'link' => array( 1193 1178 'description' => __( 'URL to the object.' ), … … 1321 1306 ), 1322 1307 'default' => array(), 1323 );1324 1325 $query_params['karma'] = array(1326 'default' => null,1327 'description' => __( 'Limit result set to that of a particular comment karma. Requires authorization.' ),1328 'type' => 'integer',1329 1308 ); 1330 1309
Note: See TracChangeset
for help on using the changeset viewer.