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
30 changes: 29 additions & 1 deletion src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4506,9 +4506,10 @@ function _wp_check_for_scheduled_update_comment_type() {
}

/**
* Register initial note status meta.
* Register initial note meta.
*
* @since 6.9.0
* @since 7.2.0 Registers the `_wp_note_anchor` meta.
*/
function wp_create_initial_comment_meta() {
register_meta(
Expand All @@ -4529,6 +4530,33 @@ function wp_create_initial_comment_meta() {
},
)
);

/*
* Notes anchor to a block through the block's own `metadata.noteId`
* attribute, which only works where there is persisted block content to
* write to. Surfaces without it - the Style Book, whose examples are
* generated fresh on every render - record what the note is about here
* instead, as an opaque identifier the surface defines and resolves.
*/
register_meta(
'comment',
'_wp_note_anchor',
array(
'type' => 'string',
'description' => __( 'What the note is anchored to, for notes not anchored to a block.' ),
'single' => true,
'sanitize_callback' => 'sanitize_text_field',
'show_in_rest' => array(
'schema' => array(
'type' => 'string',
'maxLength' => 100,
),
),
'auth_callback' => function ( $allowed, $meta_key, $object_id ) {
return current_user_can( 'edit_comment', $object_id );
},
)
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ function create_initial_post_types() {
'map_meta_cap' => true,
'supports' => array(
'title',
'editor',
'editor' => array( 'notes' => true ),
'revisions',
),
)
Expand Down
Loading
Loading