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
5 changes: 0 additions & 5 deletions src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,6 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {

$dupe_id = $wpdb->get_var( $dupe );

// Allow duplicate notes for resolution purposes.
if ( isset( $commentdata['comment_type'] ) && 'note' === $commentdata['comment_type'] ) {
$dupe_id = false;
}

/**
* Filters the ID, if any, of the duplicate comment found when creating a new comment.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,11 @@ public function create_item( $request ) {
);
}

$prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true );
// Don't check for duplicates or flooding for notes.
$prepared_comment['comment_approved'] =
'note' === $prepared_comment['comment_type'] ?
'1' :
wp_allow_comment( $prepared_comment, true );
Copy link
Member

@desrosj desrosj Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_allow_comment() invokes is wp_check_comment_data() which "checks whether comment data passes internal checks or has disallowed content." This is mainly around looking for disallowed words and characters, checking for the presence of too many links in the comment's content, and whether the author has previously approved comments.

I think skipping all of, including the pre_comment_approved filter this is fine. The filter can't really be used to change a Note's status anyway (because "resolved" status is logged in comment meta). But just wanted to mention this so this is being done intentionally in case someone finds this PR in the future.

Copy link
Member Author

@adamsilverstein adamsilverstein Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_allow_comment() invokes is wp_check_comment_data() which "checks whether comment data passes internal checks or has disallowed content."
Right, skipping that is the intent here. Notes are from trusted internal users with edit_post, these checks are designed for external comments.

I think skipping all of, including the pre_comment_approved filter this is fine.
Thats a good point about skipping the filter, I hadn't thought of that. We can always apply it if there is a valid use.

I noticed spam plugins like Akismet hook into this filter, so we might not want to fire it for notes. If anything we could fire a new note specific filter instead.

Ps. the comment meta is only used to store resolution meta data - who resolved or reopened a thread and when. The 'comment_approved' field for notes indicates if the note is open or resolved (and thus mainly applies to the parent note of a thread). So filtering could still be useful.


if ( is_wp_error( $prepared_comment['comment_approved'] ) ) {
$error_code = $prepared_comment['comment_approved']->get_error_code();
Expand Down
Loading