Settings
**Site relevance:** Spiralist.org
**Memory type:** plugin source memory
**Source path:** Spiralist/wp-content/plugins/spiralist-ai-runtime/includes/Config/Settings.php
**Size:** 3.5 KB
Summary
namespace SpiralistAIRuntime\Config;
Source Preview
This source file is short enough to preview directly on its source-memory page.
<?php
namespace SpiralistAIRuntime\Config;
if (!defined('ABSPATH')) {
exit;
}
class Settings
{
public const OPTION = 'spiralist_ai_runtime_settings';
public function all(): array
{
$stored = get_option(self::OPTION, []);
return $this->merge_defaults(self::defaults(), is_array($stored) ? $stored : []);
}
public function get(string $key, $default = null)
{
$all = $this->all();
return array_key_exists($key, $all) ? $all[$key] : $default;
}
public function get_provider_config(string $provider): array
{
unset($provider);
return [];
}
public function get_default_provider(): string
{
return 'prompt_art_only';
}
public function is_provider_enabled(string $provider): bool
{
unset($provider);
return false;
}
public function allow_user_provider_override(): bool
{
return false;
}
public function allow_user_keys(): bool
{
return false;
}
public function get_default_credential_preference(): string
{
return 'site_only';
}
public function get_heavy_request_token_threshold(): int
{
return max(1, (int) $this->get('heavy_request_token_threshold', '5000'));
}
public function register_admin_page(): void
{
add_options_page(
'Spiralist AI Runtime',
'AI Runtime',
'manage_options',
'spiralist-ai-runtime',
[$this, 'render_admin_page']
);
}
public function register_settings(): void
{
register_setting(
'spiralist_ai_runtime',
self::OPTION,
[$this, 'sanitize']
);
}
public function sanitize(array $input): array
{
unset($input);
return self::defaults();
}
public function render_admin_page(): void
{
if (!current_user_can('manage_options')) {
wp_die(esc_html__('You do not have permission to access this page.', 'spiralist-ai-runtime'));
}
?>
<div class="wrap">
<h1>Spiralist Prompt/Art Runtime Guard</h1>
<p>Spiralist is currently prompt/art only. Outside model-service calls, runtime routing, site keys, and user-stored runtime keys are disabled by project policy.</p>
<p>Use the prompt library, manuscript surfaces, and art records as copyable creative artifacts. This plugin now exists only as a compatibility guard for older code paths.</p>
</div>
<?php
}
public static function provider_labels(): array
{
return [
'prompt_art_only' => 'Prompt/art only',
];
}
public static function defaults(): array
{
return [
'default_provider' => 'prompt_art_only',
'allow_user_provider_override' => '0',
'allow_user_keys' => '0',
'default_credential_preference' => 'site_only',
'heavy_request_token_threshold' => '5000',
'providers' => [],
];
}
private function merge_defaults(array $defaults, array $stored): array
{
foreach ($defaults as $key => $value) {
if (is_array($value)) {
$defaults[$key] = $this->merge_defaults($value, is_array($stored[$key] ?? null) ? $stored[$key] : []);
continue;
}
if (array_key_exists($key, $stored)) {
$defaults[$key] = $stored[$key];
}
}
return $defaults;
}
}