Deploy 6796121 from main
This commit is contained in:
@@ -250,7 +250,9 @@ class Peptide_News_Admin {
|
|||||||
'rss_enabled' => 'absint',
|
'rss_enabled' => 'absint',
|
||||||
'rss_feeds' => 'sanitize_textarea_field',
|
'rss_feeds' => 'sanitize_textarea_field',
|
||||||
'newsapi_enabled' => 'absint',
|
'newsapi_enabled' => 'absint',
|
||||||
'newsapi_key' => function ( $value ) { return $this->sanitize_api_key( $value, 'peptide_news_newsapi_key' ); },
|
'newsapi_key' => function ( $value ) {
|
||||||
|
return $this->sanitize_api_key( $value, 'peptide_news_newsapi_key' );
|
||||||
|
},
|
||||||
'article_retention' => 'absint',
|
'article_retention' => 'absint',
|
||||||
'analytics_retention' => 'absint',
|
'analytics_retention' => 'absint',
|
||||||
'anonymize_ip' => 'absint',
|
'anonymize_ip' => 'absint',
|
||||||
@@ -262,7 +264,9 @@ class Peptide_News_Admin {
|
|||||||
'filter_body_keywords' => 'sanitize_textarea_field',
|
'filter_body_keywords' => 'sanitize_textarea_field',
|
||||||
'filter_blocked_domains' => 'sanitize_textarea_field',
|
'filter_blocked_domains' => 'sanitize_textarea_field',
|
||||||
'llm_enabled' => 'absint',
|
'llm_enabled' => 'absint',
|
||||||
'openrouter_api_key' => function ( $value ) { return $this->sanitize_api_key( $value, 'peptide_news_openrouter_api_key' ); },
|
'openrouter_api_key' => function ( $value ) {
|
||||||
|
return $this->sanitize_api_key( $value, 'peptide_news_openrouter_api_key' );
|
||||||
|
},
|
||||||
'llm_keywords_model' => array( $this, 'sanitize_model_id' ),
|
'llm_keywords_model' => array( $this, 'sanitize_model_id' ),
|
||||||
'llm_summary_model' => array( $this, 'sanitize_model_id' ),
|
'llm_summary_model' => array( $this, 'sanitize_model_id' ),
|
||||||
'llm_max_articles' => 'absint',
|
'llm_max_articles' => 'absint',
|
||||||
@@ -550,7 +554,13 @@ class Peptide_News_Admin {
|
|||||||
);
|
);
|
||||||
echo '<p class="description">' . wp_kses(
|
echo '<p class="description">' . wp_kses(
|
||||||
__( 'Get an API key at <a href="https://openrouter.ai/keys" target="_blank" rel="noopener">openrouter.ai/keys</a>.', 'peptide-news' ),
|
__( 'Get an API key at <a href="https://openrouter.ai/keys" target="_blank" rel="noopener">openrouter.ai/keys</a>.', 'peptide-news' ),
|
||||||
array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) )
|
array(
|
||||||
|
'a' => array(
|
||||||
|
'href' => array(),
|
||||||
|
'target' => array(),
|
||||||
|
'rel' => array(),
|
||||||
|
),
|
||||||
|
)
|
||||||
) . '</p>';
|
) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,13 +728,15 @@ class Peptide_News_Admin {
|
|||||||
if ( $last_fetch ) {
|
if ( $last_fetch ) {
|
||||||
$extra_info = '';
|
$extra_info = '';
|
||||||
if ( isset( $last_fetch['filtered_out'] ) && $last_fetch['filtered_out'] > 0 ) {
|
if ( isset( $last_fetch['filtered_out'] ) && $last_fetch['filtered_out'] > 0 ) {
|
||||||
$extra_info .= sprintf( ' | %s: %d',
|
$extra_info .= sprintf(
|
||||||
|
' | %s: %d',
|
||||||
esc_html__( 'Filtered out', 'peptide-news' ),
|
esc_html__( 'Filtered out', 'peptide-news' ),
|
||||||
$last_fetch['filtered_out']
|
$last_fetch['filtered_out']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( isset( $last_fetch['ai_processed'] ) ) {
|
if ( isset( $last_fetch['ai_processed'] ) ) {
|
||||||
$extra_info .= sprintf( ' | %s: %d',
|
$extra_info .= sprintf(
|
||||||
|
' | %s: %d',
|
||||||
esc_html__( 'AI analyzed', 'peptide-news' ),
|
esc_html__( 'AI analyzed', 'peptide-news' ),
|
||||||
$last_fetch['ai_processed']
|
$last_fetch['ai_processed']
|
||||||
);
|
);
|
||||||
@@ -734,10 +746,10 @@ class Peptide_News_Admin {
|
|||||||
esc_html__( 'Last fetch', 'peptide-news' ),
|
esc_html__( 'Last fetch', 'peptide-news' ),
|
||||||
esc_html( $last_fetch['time'] ),
|
esc_html( $last_fetch['time'] ),
|
||||||
esc_html__( 'Found', 'peptide-news' ),
|
esc_html__( 'Found', 'peptide-news' ),
|
||||||
$last_fetch['found'],
|
intval( $last_fetch['found'] ),
|
||||||
esc_html__( 'New stored', 'peptide-news' ),
|
esc_html__( 'New stored', 'peptide-news' ),
|
||||||
$last_fetch['new_stored'],
|
intval( $last_fetch['new_stored'] ),
|
||||||
$extra_info
|
esc_html( $extra_info )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -398,8 +398,7 @@ class Peptide_News_Content_Filter {
|
|||||||
|
|
||||||
// Use XML-style delimiters to isolate untrusted article data from the prompt.
|
// Use XML-style delimiters to isolate untrusted article data from the prompt.
|
||||||
// This mitigates prompt injection by clearly separating instructions from data.
|
// This mitigates prompt injection by clearly separating instructions from data.
|
||||||
return
|
$prompt = "You are a content classifier. Your ONLY task is to classify the article below.\n" .
|
||||||
"You are a content classifier. Your ONLY task is to classify the article below.\n" .
|
|
||||||
"Respond with EXACTLY one word: EDITORIAL or PROMOTIONAL.\n" .
|
"Respond with EXACTLY one word: EDITORIAL or PROMOTIONAL.\n" .
|
||||||
"EDITORIAL = genuine news, research, or journalism.\n" .
|
"EDITORIAL = genuine news, research, or journalism.\n" .
|
||||||
"PROMOTIONAL = press releases, ads, sponsored content, product launches, " .
|
"PROMOTIONAL = press releases, ads, sponsored content, product launches, " .
|
||||||
@@ -412,6 +411,7 @@ class Peptide_News_Content_Filter {
|
|||||||
sprintf( "<content>%s</content>\n", $content_trimmed ) .
|
sprintf( "<content>%s</content>\n", $content_trimmed ) .
|
||||||
"</article_to_classify>\n\n" .
|
"</article_to_classify>\n\n" .
|
||||||
"Classification (one word only):";
|
"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 ) ) {
|
if ( ! preg_match( '/^\\d{4}-\\d{2}-\\d{2}$/', $value ) ) {
|
||||||
return new WP_Error(
|
return new WP_Error(
|
||||||
'rest_invalid_date',
|
'rest_invalid_date',
|
||||||
|
/* translators: %s: parameter name */
|
||||||
sprintf( __( 'Invalid date format for %s. Expected Y-m-d.', 'peptide-news' ), $param ),
|
sprintf( __( 'Invalid date format for %s. Expected Y-m-d.', 'peptide-news' ), $param ),
|
||||||
array( 'status' => 400 )
|
array( 'status' => 400 )
|
||||||
);
|
);
|
||||||
@@ -184,7 +185,6 @@ class Peptide_News_Rest_API {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
|||||||
Reference in New Issue
Block a user