fix: resolve remaining PHPCS errors (4 violations across 3 files)
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,9 @@
|
||||
<rule ref="Universal.Files.SeparateFunctionsFromOO">
|
||||
<type>warning</type>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.OneObjectStructurePerFile">
|
||||
<type>warning</type>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress-Extra">
|
||||
<!-- Don't require Yoda conditions for readability -->
|
||||
|
||||
@@ -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( "<content>%s</content>\n", $content_trimmed ) .
|
||||
"</article_to_classify>\n\n" .
|
||||
"Classification (one word only):";
|
||||
return $prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user