Add PRV_Key_Store (resolver), PRV_Crypto_Helper (libsodium/OpenSSL), PRV_Key_Manager_Renderer (write-only Settings card), PRV_Key_Test_Ajax. Key resolver: PRV_OPENROUTER_API_KEY constant > prv_provider_key_enc option > none. All probe + test paths read key through PRV_Key_Store::get_key(). Security: - Ciphertext only in prv_provider_key_enc (hex nonce:hex ciphertext). - Enc key from SHA-256(AUTH_KEY+SECURE_AUTH_KEY) — never stored. - Plaintext never in options, logs, exceptions, page source, REST, or JS. - manage_options + nonce on set/remove/test. wp-config precedence enforced. - write-only UI: password input always renders empty; status text only. - uninstall.php prv_ wildcard DELETE covers prv_provider_key_enc. Files: 4 new (all ≤300 lines), 14 modified. Tests: test-key-store.php (encrypt/decrypt round-trip, wrong-key fails silently, resolver precedence, write-only render, Remove, constant wins). ARCHITECTURE/CONVENTIONS/CONTEXT/ CHANGELOG all updated in this commit. Agent-Session: 2026-06-15-pr-vision-v0.2.3-api-key-ui
70 lines
2.7 KiB
PHP
70 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: PR Vision
|
|
* Plugin URI: https://peptiderepo.com
|
|
* Description: Weekly server-side LLM probes for AI-visibility (GEO) tracking. Records whether peptiderepo.com is cited by LLMs across core peptides, stores time-series, and renders an admin dashboard + settings UI.
|
|
* Version: 0.2.3
|
|
* Author: peptiderepo
|
|
* Author URI: https://peptiderepo.com
|
|
* License: GPL-2.0-or-later
|
|
* Text Domain: pr-vision
|
|
* Requires PHP: 8.1
|
|
*
|
|
* @see ARCHITECTURE.md -- Full data flow and file tree.
|
|
* @see CONVENTIONS.md -- Naming patterns and extension guide.
|
|
* @see CONTEXT.md -- Domain glossary incl. the visibility score formula.
|
|
* @package PrVision
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/* ── Constants ────────────────────────────────────────────────────────── */
|
|
|
|
define( 'PRV_VERSION', '0.2.3' );
|
|
define( 'PRV_PLUGIN_FILE', __FILE__ );
|
|
define( 'PRV_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'PRV_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
|
define( 'PRV_SCHEMA_VERSION', 2 );
|
|
|
|
/** Maximum HTTP retries for LLM API calls. @var int */
|
|
define( 'PRV_MAX_RETRIES', 3 );
|
|
|
|
/** API request timeout in seconds. @var int */
|
|
define( 'PRV_API_TIMEOUT_SECONDS', 60 );
|
|
|
|
/** Base backoff delay (seconds) between retries. @var int */
|
|
define( 'PRV_RETRY_BASE_DELAY_SECONDS', 2 );
|
|
|
|
/** Default monthly budget cap in USD. @var float */
|
|
define( 'PRV_DEFAULT_MONTHLY_BUDGET_USD', 5.0 );
|
|
|
|
/** WP-Cron hook name for the weekly probe run. @var string */
|
|
define( 'PRV_CRON_HOOK', 'prv_weekly_probe' );
|
|
|
|
/** The site we are tracking citations for. @var string */
|
|
define( 'PRV_TARGET_DOMAIN', 'peptiderepo.com' );
|
|
|
|
/* ── Autoloader ───────────────────────────────────────────────────────── */
|
|
|
|
require_once PRV_PLUGIN_DIR . 'includes/core/class-prv-autoloader.php';
|
|
PRV_Autoloader::register();
|
|
|
|
/* ── Activation / Deactivation ────────────────────────────────────────── */
|
|
|
|
register_activation_hook( __FILE__, array( 'PRV_Activator', 'activate' ) );
|
|
register_deactivation_hook( __FILE__, array( 'PRV_Deactivator', 'deactivate' ) );
|
|
|
|
/* ── Boot ──────────────────────────────────────────────────────────────── */
|
|
|
|
add_action(
|
|
'plugins_loaded',
|
|
static function (): void {
|
|
$plugin = new PRV_Plugin();
|
|
$plugin->init();
|
|
}
|
|
);
|