Skip to content

Skip Comment Moderation Analysis if marked as spam/trash#743

Open
Intenzi wants to merge 4 commits into
WordPress:developfrom
Intenzi:feat/spam-comment-moderation
Open

Skip Comment Moderation Analysis if marked as spam/trash#743
Intenzi wants to merge 4 commits into
WordPress:developfrom
Intenzi:feat/spam-comment-moderation

Conversation

@Intenzi

@Intenzi Intenzi commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What?

Follow up to #516 (comment)

This PR enables skipping of comment moderation AI analysis when comment is flagged as spam/trash by WordPress moderation/external plugins.

Why?

We should avoid token usage and sentiment analysis when a comment has been flagged to be spam by auto moderation beforehand.

How?

Adds a check in moderate_comment() function to validate comment_approved status.
Skips comment analysis when comment approval status is spam/trash

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity IDE
Model(s): Gemini 3.5 Flash (Low)
Used for: Creating the boilerplate of the integration test. Reviewed and modified by me to function properly.

Testing Instructions

  1. Enable Comment Moderation experiment.

For spam testing:

  • Install Akismet Anti-spam: Spam protection plugin.
  • Enter valid API key to enable the plugin.
  • Comment on a post with akismet-guaranteed-spam
  • Go to comments list in admin, verify that it is flagged as spam and check sentiment, toxicity analysis to be empty.
image

For trash testing:

  • Go to WordPress settings -> Discussion
  • Scroll down to Disallowed Comment Keys and add trash as a keyword.
  • Save settings.
  • Comment a post with trash word.
  • Go to comments list in admin, verify that it is flagged as trash and check sentiment, toxicity analysis to be empty.
image

Screenshots or screencast

Visible empty sentiment, toxicity analysis.
image
image

Changelog Entry

Changed - moderate_comment() function to skip comment analysis and moderation when comment is flagged as spam/trash.

Open WordPress Playground Preview

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Intenzi <intenzi@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@speedyprem speedyprem left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants