Editor: Notes should not appear in the context of comments.

Prevent notes from inadvertently showing up in the context of comments - including on the Dashboard recent comments widget and the “Mine” count on the Comments page. Notes are stored as a custom ‘note’ comment type and this change ensures the note type is only returned when explicitly requested, or when ‘all’ types are requested.

The query for note children is modified to return all child notes. This fixes an issue where children were no longer being returned for the ‘note’ type.

Also fixes https://github.com/WordPress/gutenberg/issues/72548.


Props adamsilverstein, timothyblynjacobs, shailu25, peterwilsoncc, westonruter, mamaduka, kadamwhite.
Fixes #64145.
Fixes #64152.


Built from https://develop.svn.wordpress.org/trunk@61105


git-svn-id: http://core.svn.wordpress.org/trunk@60441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein
2025-10-31 18:57:30 +00:00
parent 180d098dfa
commit 59991fff9b
6 changed files with 29 additions and 3 deletions

View File

@@ -151,7 +151,6 @@ class WP_Comments_List_Table extends WP_List_Table {
'order' => $order,
'post_type' => $post_type,
'update_comment_post_cache' => true,
'type__not_in' => array( 'note' ),
);
/**

View File

@@ -138,6 +138,7 @@ function get_comment_to_edit( $id ) {
* Gets the number of pending comments on a post or posts.
*
* @since 2.3.0
* @since 6.9.0 Exclude the 'note' comment type from the count.
*
* @global wpdb $wpdb WordPress database abstraction object.
*

View File

@@ -536,6 +536,7 @@ class WP_Comment_Query {
* Used internally to get a list of comment IDs matching the query vars.
*
* @since 4.4.0
* @since 6.9.0 Excludes the 'note' comment type, unless 'all' or the 'note' types are requested.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
@@ -770,6 +771,15 @@ class WP_Comment_Query {
'NOT IN' => (array) $this->query_vars['type__not_in'],
);
// Exclude the 'note' comment type, unless 'all' types or the 'note' type explicitly are requested.
if (
! in_array( 'all', $raw_types['IN'], true ) &&
! in_array( 'note', $raw_types['IN'], true ) &&
! in_array( 'note', $raw_types['NOT IN'], true )
) {
$raw_types['NOT IN'][] = 'note';
}
$comment_types = array();
foreach ( $raw_types as $operator => $_raw_types ) {
$_raw_types = array_unique( $_raw_types );

View File

@@ -417,7 +417,6 @@ function get_comment_count( $post_id = 0 ) {
'count' => true,
'update_comment_meta_cache' => false,
'orderby' => 'none',
'type__not_in' => array( 'note' ),
);
if ( $post_id > 0 ) {
$args['post_id'] = $post_id;

View File

@@ -1254,6 +1254,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
array(
'count' => true,
'orderby' => 'none',
'type' => 'all',
)
);
@@ -1270,6 +1271,22 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
);
}
// Embedding children for notes requires `type` and `status` inheritance.
if ( isset( $links['children'] ) && 'note' === $comment->comment_type ) {
$args = array(
'parent' => $comment->comment_ID,
'type' => $comment->comment_type,
'status' => 'all',
);
$rest_url = add_query_arg( $args, rest_url( $this->namespace . '/' . $this->rest_base ) );
$links['children'] = array(
'href' => $rest_url,
'embeddable' => true,
);
}
return $links;
}

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-beta2-61104';
$wp_version = '6.9-beta2-61105';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.