diff --git a/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php b/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php index 981b9dbd840319..60b45b1a63adef 100644 --- a/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php +++ b/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php @@ -10,6 +10,10 @@ class Gutenberg_REST_Comment_Controller_6_8 extends WP_REST_Comments_Controller { public function create_item_permissions_check( $request ) { + if ( empty( $request['comment_type'] ) || 'comment' === $request['comment_type'] ) { + return parent::create_item_permissions_check( $request ); + } + if ( ! is_user_logged_in() ) { if ( get_option( 'comment_registration' ) ) { return new WP_Error( @@ -90,14 +94,6 @@ public function create_item_permissions_check( $request ) { ); } - if ( 'draft' === $post->post_status && 'comment' === $request['comment_type'] ) { - return new WP_Error( - 'rest_comment_draft_post', - __( 'Sorry, you are not allowed to create a comment on this post.' ), - array( 'status' => 403 ) - ); - } - if ( 'trash' === $post->post_status ) { return new WP_Error( 'rest_comment_trash_post', @@ -114,14 +110,6 @@ public function create_item_permissions_check( $request ) { ); } - if ( ! comments_open( $post->ID ) && 'comment' === $request['comment_type'] ) { - return new WP_Error( - 'rest_comment_closed', - __( 'Sorry, comments are closed for this item.' ), - array( 'status' => 403 ) - ); - } - return true; } }