Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/rest-api/rest-comments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand Down Expand Up @@ -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'] );
}

/**
Expand Down
Loading