Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4129,7 +4129,10 @@ 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' );
add_action( 'rest_api_init', 'wp_create_initial_comment_meta' );
5 changes: 5 additions & 0 deletions tests/phpunit/tests/rest-api/rest-comments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,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
3 changes: 3 additions & 0 deletions tests/phpunit/tests/rest-api/rest-schema-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function set_up() {
do_action( 'rest_api_init', $wp_rest_server );

add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 );

// `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present:
self::touch( ABSPATH . WPINC . '/js/wp-embed.js' );
}

public function tear_down() {
Expand Down
28 changes: 26 additions & 2 deletions tests/qunit/fixtures/wp-api-generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -11654,7 +11654,18 @@ mockedApiResponse.Schema = {
"meta": {
"description": "Meta fields.",
"type": "object",
"properties": [],
"properties": {
"_wp_note_status": {
"type": "string",
"title": "",
"description": "Note resolution status",
"default": "",
"enum": [
"resolved",
"reopen"
]
}
},
"required": false
}
}
Expand Down Expand Up @@ -11801,7 +11812,18 @@ mockedApiResponse.Schema = {
"meta": {
"description": "Meta fields.",
"type": "object",
"properties": [],
"properties": {
"_wp_note_status": {
"type": "string",
"title": "",
"description": "Note resolution status",
"default": "",
"enum": [
"resolved",
"reopen"
]
}
},
"required": false
}
}
Expand Down Expand Up @@ -15480,6 +15502,7 @@ mockedApiResponse.CommentsCollection = [
"96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g"
},
"meta": {
"_wp_note_status": null,
"meta_key": "meta_value"
},
"_links": {
Expand Down Expand Up @@ -15534,6 +15557,7 @@ mockedApiResponse.CommentModel = {
"96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g"
},
"meta": {
"_wp_note_status": null,
"meta_key": "meta_value"
}
};
Expand Down
3 changes: 3 additions & 0 deletions tests/qunit/wp-includes/js/wp-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@
if ( 'Tags' === modelType ) {
expectedMetas = '{"test_single":"","test_multi":[],"meta_key":"meta_value","test_tag_meta":""}';
}
if ( 'Comments' === modelType ) {
expectedMetas = '{"_wp_note_status":null,"meta_key":"meta_value"}';
}

// Verify the meta object returned correctly from `getMetas()`.
assert.equal( JSON.stringify( endpoint.getMetas() ), expectedMetas, 'Full meta key/values object should be readable.' );
Expand Down
Loading