diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 9399889768e57..aa841bfda976f 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4129,7 +4129,9 @@ function wp_create_initial_comment_meta() { 'enum' => array( 'resolved', 'reopen' ), ), ), + 'auth_callback' => function ( $allowed, $meta_key, $object_id ) { + return current_user_can( 'edit_comment', $object_id ); + }, ) ); } -add_action( 'init', 'wp_create_initial_comment_meta' ); diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 5dc54c3686b3a..f59d25b4fd0e3 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -151,6 +151,7 @@ add_action( 'added_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'updated_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'deleted_comment_meta', 'wp_cache_set_comments_last_changed' ); +add_action( 'init', 'wp_create_initial_comment_meta' ); // Places to balance tags on input. foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index e0868bbeca362..7a5109b25d909 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -170,6 +170,8 @@ public static function wpTearDownAfterClass() { public function set_up() { parent::set_up(); $this->endpoint = new WP_REST_Comments_Controller(); + wp_create_initial_comment_meta(); + if ( is_multisite() ) { update_site_option( 'site_admins', array( 'superadmin' ) ); } @@ -3888,6 +3890,11 @@ public function test_create_empty_note_with_resolution_meta( $status ) { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 201, $response->get_status() ); + + $data = $response->get_data(); + $this->assertArrayHasKey( 'meta', $data ); + $this->assertArrayHasKey( '_wp_note_status', $data['meta'] ); + $this->assertSame( $status, $data['meta']['_wp_note_status'] ); } /**