diff --git a/includes/class-psa-admin.php b/includes/class-psa-admin.php
index a1ff9ea..ab5e29f 100755
--- a/includes/class-psa-admin.php
+++ b/includes/class-psa-admin.php
@@ -1,5 +1,4 @@
$api_key_value,
- 'ai_model' => sanitize_text_field( $input['ai_model'] ?? '' ),
- 'validation_model' => sanitize_text_field( $input['validation_model'] ?? '' ),
- 'auto_publish' => sanitize_text_field( $input['auto_publish'] ?? 'draft' ),
- 'use_pubchem' => ! empty( $input['use_pubchem'] ) ? '1' : '0',
- 'monthly_budget' => max( 0, floatval( $input['monthly_budget'] ?? PSA_Config::DEFAULT_MONTHLY_BUDGET ) ),
+ 'api_key' => $api_key_value,
+ 'ai_model' => sanitize_text_field( $input['ai_model'] ?? '' ),
+ 'validation_model' => sanitize_text_field( $input['validation_model'] ?? '' ),
+ 'auto_publish' => sanitize_text_field( $input['auto_publish'] ?? 'draft' ),
+ 'use_pubchem' => ! empty( $input['use_pubchem'] ) ? '1' : '0',
+ 'monthly_budget' => max( 0, floatval( $input['monthly_budget'] ?? PSA_Config::DEFAULT_MONTHLY_BUDGET ) ),
);
}
@@ -106,20 +106,28 @@ class PSA_Admin {
if ( 'migrate_categories' === $action && wp_verify_nonce( $nonce, 'psa_migrate_categories' ) ) {
self::run_category_migration();
- add_action( 'admin_notices', function () {
- echo '
' . esc_html__( 'Category migration completed.', 'peptide-search-ai' ) . '
';
- } );
+ add_action(
+ 'admin_notices',
+ function () {
+ echo '' . esc_html__( 'Category migration completed.', 'peptide-search-ai' ) . '
';
+ }
+ );
}
if ( 'reenrich' === $action && wp_verify_nonce( $nonce, 'psa_reenrich' ) ) {
$queued = self::queue_reenrichment();
- add_action( 'admin_notices', function () use ( $queued ) {
- echo '' . esc_html( sprintf(
- /* translators: %d = number of peptides queued */
- __( '%d peptides queued for re-enrichment.', 'peptide-search-ai' ),
- $queued
- ) ) . '
';
- } );
+ add_action(
+ 'admin_notices',
+ function () use ( $queued ) {
+ echo '' . esc_html(
+ sprintf(
+ /* translators: %d = number of peptides queued */
+ __( '%d peptides queued for re-enrichment.', 'peptide-search-ai' ),
+ $queued
+ )
+ ) . '
';
+ }
+ );
}
}
diff --git a/includes/class-psa-ai-generator.php b/includes/class-psa-ai-generator.php
index 7051500..cef5d54 100755
--- a/includes/class-psa-ai-generator.php
+++ b/includes/class-psa-ai-generator.php
@@ -1,5 +1,4 @@
120,
'headers' => array(
- 'Content-Type' => 'application/json',
- 'Authorization' => 'Bearer ' . $api_key,
- 'HTTP-Referer' => $site_url,
- 'X-Title' => $site_name,
+ 'Content-Type' => 'application/json',
+ 'Authorization' => 'Bearer ' . $api_key,
+ 'HTTP-Referer' => $site_url,
+ 'X-Title' => $site_name,
),
'body' => wp_json_encode(
array(
- 'model' => $model,
- 'messages' => array(
+ 'model' => $model,
+ 'messages' => array(
array(
'role' => 'system',
'content' => 'You are a scientific database assistant. Return only valid JSON.',
@@ -108,8 +108,8 @@ class PSA_OpenRouter {
'content' => $prompt,
),
),
- 'max_tokens' => $max_tokens,
- 'temperature' => 0.3,
+ 'max_tokens' => $max_tokens,
+ 'temperature' => 0.3,
)
),
)
@@ -152,13 +152,13 @@ class PSA_OpenRouter {
PSA_Cost_Tracker::log_api_call(
array(
- 'provider' => 'openrouter',
- 'model' => $model,
- 'prompt_tokens' => $prompt_tokens,
- 'completion_tokens' => $completion_tokens,
- 'request_type' => $request_type,
- 'peptide_name' => $peptide_name,
- 'success' => true,
+ 'provider' => 'openrouter',
+ 'model' => $model,
+ 'prompt_tokens' => $prompt_tokens,
+ 'completion_tokens' => $completion_tokens,
+ 'request_type' => $request_type,
+ 'peptide_name' => $peptide_name,
+ 'success' => true,
)
);
diff --git a/includes/class-psa-post-type.php b/includes/class-psa-post-type.php
index f9e3387..3b6c707 100755
--- a/includes/class-psa-post-type.php
+++ b/includes/class-psa-post-type.php
@@ -1,5 +1,4 @@
admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'psa_search_nonce' ),
'i18n' => array(
- 'error' => __( 'Error:', 'peptide-search-ai' ),
- 'searchFailed' => __( 'Search failed.', 'peptide-search-ai' ),
- 'unexpected' => __( 'Unexpected response.', 'peptide-search-ai' ),
- 'rateLimited' => __( 'Too many requests. Please try again later.', 'peptide-search-ai' ),
- 'networkError' => __( 'Could not connect to the server. Please try again.', 'peptide-search-ai' ),
- 'timeout' => __( 'Request timed out. The server took too long to respond. Please try again.', 'peptide-search-ai' ),
- 'connectionError' => __( 'Network error. Please check your connection and try again.', 'peptide-search-ai' ),
- 'serverError' => __( 'Server error. Please try again later.', 'peptide-search-ai' ),
- 'unavailable' => __( 'Server is temporarily unavailable. Please try again later.', 'peptide-search-ai' ),
- 'peptidesFound' => __( 'peptide(s) found', 'peptide-search-ai' ),
- 'pendingMsg' => __( 'is currently being added to our database. Please check back again later.', 'peptide-search-ai' ),
- 'invalidMsg' => __( 'does not appear to be a recognized peptide. Please check the spelling or try a different search term.', 'peptide-search-ai' ),
- 'verified' => __( 'Verified', 'peptide-search-ai' ),
- 'curated' => __( 'Curated', 'peptide-search-ai' ),
+ 'error' => __( 'Error:', 'peptide-search-ai' ),
+ 'searchFailed' => __( 'Search failed.', 'peptide-search-ai' ),
+ 'unexpected' => __( 'Unexpected response.', 'peptide-search-ai' ),
+ 'rateLimited' => __( 'Too many requests. Please try again later.', 'peptide-search-ai' ),
+ 'networkError' => __( 'Could not connect to the server. Please try again.', 'peptide-search-ai' ),
+ 'timeout' => __( 'Request timed out. The server took too long to respond. Please try again.', 'peptide-search-ai' ),
+ 'connectionError' => __( 'Network error. Please check your connection and try again.', 'peptide-search-ai' ),
+ 'serverError' => __( 'Server error. Please try again later.', 'peptide-search-ai' ),
+ 'unavailable' => __( 'Server is temporarily unavailable. Please try again later.', 'peptide-search-ai' ),
+ 'peptidesFound' => __( 'peptide(s) found', 'peptide-search-ai' ),
+ 'pendingMsg' => __( 'is currently being added to our database. Please check back again later.', 'peptide-search-ai' ),
+ 'invalidMsg' => __( 'does not appear to be a recognized peptide. Please check the spelling or try a different search term.', 'peptide-search-ai' ),
+ 'verified' => __( 'Verified', 'peptide-search-ai' ),
+ 'curated' => __( 'Curated', 'peptide-search-ai' ),
),
)
);
diff --git a/tests/unit/AIGeneratorTest.php b/tests/unit/AIGeneratorTest.php
index 207b73b..0140314 100755
--- a/tests/unit/AIGeneratorTest.php
+++ b/tests/unit/AIGeneratorTest.php
@@ -116,9 +116,9 @@ class AIGeneratorTest extends TestCase {
*/
public function test_parse_response_with_markdown_fences() {
$response_text = <<