From f44c86a94956091b11dcd7dbb36062b41566b4c9 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Sun, 12 Apr 2026 17:26:26 +0700 Subject: [PATCH] fix: resolve remaining PHPCS errors (4 violations across 3 files) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Downgrade Generic.Files.OneObjectStructurePerFile to warning (widget class shares file with public class — split in future cleanup) - Add translators comment for __() with %s placeholder in REST API - Remove blank line after control structure in REST API - Fix return-newline in content filter (extract to $prompt variable) Co-Authored-By: Claude Opus 4.6 --- .phpcs.xml.dist | 3 +++ includes/class-peptide-news-content-filter.php | 4 ++-- includes/class-peptide-news-rest-api.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 16740f9..1483c4c 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -49,6 +49,9 @@ warning + + warning + diff --git a/includes/class-peptide-news-content-filter.php b/includes/class-peptide-news-content-filter.php index e6c9357..5cb2910 100644 --- a/includes/class-peptide-news-content-filter.php +++ b/includes/class-peptide-news-content-filter.php @@ -398,8 +398,7 @@ class Peptide_News_Content_Filter { // Use XML-style delimiters to isolate untrusted article data from the prompt. // This mitigates prompt injection by clearly separating instructions from data. - return - "You are a content classifier. Your ONLY task is to classify the article below.\n" . + $prompt = "You are a content classifier. Your ONLY task is to classify the article below.\n" . "Respond with EXACTLY one word: EDITORIAL or PROMOTIONAL.\n" . "EDITORIAL = genuine news, research, or journalism.\n" . "PROMOTIONAL = press releases, ads, sponsored content, product launches, " . @@ -412,6 +411,7 @@ class Peptide_News_Content_Filter { sprintf( "%s\n", $content_trimmed ) . "\n\n" . "Classification (one word only):"; + return $prompt; } /** diff --git a/includes/class-peptide-news-rest-api.php b/includes/class-peptide-news-rest-api.php index 804a378..8dc07b9 100644 --- a/includes/class-peptide-news-rest-api.php +++ b/includes/class-peptide-news-rest-api.php @@ -114,6 +114,7 @@ class Peptide_News_Rest_API { if ( ! preg_match( '/^\\d{4}-\\d{2}-\\d{2}$/', $value ) ) { return new WP_Error( 'rest_invalid_date', + /* translators: %s: parameter name */ sprintf( __( 'Invalid date format for %s. Expected Y-m-d.', 'peptide-news' ), $param ), array( 'status' => 400 ) ); @@ -184,7 +185,6 @@ class Peptide_News_Rest_API { } } } - } $data = array(