Add content filter to block ads, press releases, and promotional content

Two-tier filtering during article fetch: keyword/pattern rules as a fast
first pass, then optional LLM classification for borderline cases via
OpenRouter. Configurable sensitivity (strict/moderate/lenient), editable
keyword lists, blocked domain list, and admin stats display. Includes
30 unit tests covering domain blocking, title/body keywords, URL paths,
edge cases, and prompt structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Terence Ong
2026-04-06 14:14:16 +07:00
parent 849ffa1260
commit e6887e810f
6 changed files with 1275 additions and 6 deletions

View File

@@ -66,6 +66,13 @@ class Peptide_News_Fetcher {
}
}
// Filter out ads, press releases, and promotional content.
$pre_filter_count = count( $articles );
if ( class_exists( 'Peptide_News_Content_Filter' ) && Peptide_News_Content_Filter::is_enabled() ) {
$articles = Peptide_News_Content_Filter::filter_articles( $articles );
}
$filtered_out = $pre_filter_count - count( $articles );
// Store articles (deduplication handled by hash).
$stored = 0;
foreach ( $articles as $article ) {
@@ -76,9 +83,10 @@ class Peptide_News_Fetcher {
// Log the fetch result.
update_option( 'peptide_news_last_fetch', array(
'time' => current_time( 'mysql' ),
'found' => count( $articles ),
'new_stored' => $stored,
'time' => current_time( 'mysql' ),
'found' => $pre_filter_count,
'filtered_out' => $filtered_out,
'new_stored' => $stored,
) );
// Scrape OG images for articles missing thumbnails.