diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index f4f6bdd1f1a54..7c53efebf66a9 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -1254,6 +1254,8 @@ protected function prepare_links( $comment ) { array( 'count' => true, 'orderby' => 'none', + 'type' => $comment->comment_type, + 'status' => 'all', ) ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index e0868bbeca362..61fb2b3f2c0b9 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -4069,4 +4069,38 @@ public function data_note_status_provider() { 'reopen' => array( 'reopen' ), ); } + + /** + * Test children link for note comment type. + * + * @ticket 64145 + */ + public function test_get_note_with_children_link() { + $comment_id_1 = self::factory()->comment->create( + array( + 'comment_approved' => 0, + 'comment_post_ID' => self::$post_id, + 'user_id' => self::$subscriber_id, + 'comment_type' => 'note', + ) + ); + + self::factory()->comment->create( + array( + 'comment_approved' => 0, + 'comment_parent' => $comment_id_1, + 'comment_post_ID' => self::$post_id, + 'user_id' => self::$subscriber_id, + 'comment_type' => 'note', + ) + ); + wp_set_current_user( self::$admin_id ); + $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); + $request->set_param( 'type', 'note' ); + $request->set_param( 'context', 'edit' ); + $response = rest_get_server()->dispatch( $request ); + $this->assertSame( 200, $response->get_status() ); + + $this->assertArrayHasKey( 'children', $response->get_links() ); + } }