Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
259451d
feat: add dashboard pills to recent comments widget
Intenzi May 7, 2026
f5bf6f2
feat: add sorting to sentiment and toxicity columns
Intenzi May 7, 2026
4b96b11
feat: add sentiment and toxicity filtering to comments list
Intenzi May 7, 2026
36f6b32
fix: prevent rounding of toxicity score to nearest whole number durin…
Intenzi May 7, 2026
5d19592
test: sentiment, toxicity filtering logic
Intenzi May 7, 2026
e9f7be3
test: dashboard pills visibility
Intenzi May 7, 2026
ff70b65
fix: static analysis tests error of strict comparison between 'low' a…
Intenzi May 7, 2026
3ba1513
Merge branch 'develop' into feature/sort-filter-label-comment-moderation
dkotter May 7, 2026
48893d9
refactor: use scoped CSS classes for comment moderation styles
Intenzi May 11, 2026
d510516
refactor: use standard query_vars for meta query handling
Intenzi May 11, 2026
e7bfab5
fix: add screen guard to comment filter dropdowns
Intenzi May 11, 2026
56ff2b4
fix: add missing newline between functions
Intenzi May 11, 2026
d5988de
refactor: centralized comment moderation configurations
Intenzi May 11, 2026
4b775b9
test: expand comment moderation e2e suite with sorting and filtering …
Intenzi May 11, 2026
8dd1d4e
fix: align comment analysis sentiment enum order with implementation
Intenzi May 11, 2026
ccb6b6b
fix: add specific return type shapes to moderation config for PHPStan
Intenzi May 11, 2026
3771b97
fix: update e2e tests with dynamic sentiment mocking and locator refi…
Intenzi May 11, 2026
8752392
test: expand comment moderation E2E with neutral sentiment filtering
Intenzi May 11, 2026
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
7 changes: 4 additions & 3 deletions includes/Abilities/Comment_Moderation/Comment_Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function output_schema(): array {
),
'sentiment' => array(
'type' => 'string',
'enum' => array( 'positive', 'negative', 'neutral' ),
'enum' => array_keys( Comment_Moderation::get_sentiment_config() ),
'description' => esc_html__( 'The sentiment of the comment.', 'ai' ),
),
),
Expand Down Expand Up @@ -294,14 +294,15 @@ private function get_prompt_builder( string $prompt ) {
* @return array{toxicity_score: float, sentiment: string} Sanitized analysis result.
*/
private function sanitize_analysis_result( array $result ): array {
// Validate and sanitize the response.
$toxicity_score = isset( $result['toxicity_score'] )
? max( 0, min( 1, (float) $result['toxicity_score'] ) )
: 0;

$valid_sentiments = array( 'positive', 'negative', 'neutral' );
$valid_sentiments = array_keys( Comment_Moderation::get_sentiment_config() );
$sentiment = isset( $result['sentiment'] ) && in_array( $result['sentiment'], $valid_sentiments, true )
? $result['sentiment']
: 'neutral';
: Comment_Moderation::SENTIMENT_NEUTRAL;

return array(
'toxicity_score' => $toxicity_score,
Expand Down
Loading
Loading