Ticket #38816: 38816.3.diff
File 38816.3.diff, 1.4 KB (added by , 4 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
385 385 return new WP_Error( 'rest_comment_invalid_status', __( 'Sorry, you are not allowed to set status for comments.' ), array( 'status' => rest_authorization_required_code() ) ); 386 386 } 387 387 388 if ( empty( $request['post'] ) && ! current_user_can( 'moderate_comments' ) ) {388 if ( empty( $request['post'] ) && ! current_user_can( 'moderate_comments' ) ) { 389 389 return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => rest_authorization_required_code() ) ); 390 390 } 391 391 392 if ( ! empty( $request['post'] ) && $post = get_post( (int) $request['post'] ) ) { 392 if ( ! empty( $request['post'] ) ) { 393 $post = get_post( (int) $request['post'] ); 394 395 if ( ! $post ) { 396 return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) ); 397 } 398 393 399 if ( 'draft' === $post->post_status ) { 394 400 return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) ); 395 401 }