first commit all files

This commit is contained in:
dwindown
2026-01-28 00:26:00 +07:00
parent 65dd207a74
commit 97426d5ab1
72 changed files with 91484 additions and 0 deletions

132
views/settings/layout.php Normal file
View File

@@ -0,0 +1,132 @@
<?php
/**
* Settings Layout - Bootstrap 5 wrapper
*
* @package WP_Agentic_Writer
* @var array $view_data Prepared view data from class-settings-v2.php
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Extract view data for easier access
extract( $view_data );
?>
<div class="wrap wpaw-settings-v2-wrap">
<div class="container py-4">
<!-- Header -->
<div class="wpaw-agentic-header mb-4">
<div class="d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center gap-3">
<img src="<?php echo esc_url( WP_AGENTIC_WRITER_URL . 'assets/img/icon.svg' ); ?>"
alt="WP Agentic Writer"
style="width: 48px; height: 48px; filter: invert(1)">
<div>
<h1 class="h3 mb-1"><?php esc_html_e( 'WP Agentic Writer', 'wp-agentic-writer' ); ?></h1>
<p class="text-muted mb-0">
v<?php echo esc_html( WP_AGENTIC_WRITER_VERSION ); ?> ·
<?php esc_html_e( 'Settings & Configuration', 'wp-agentic-writer' ); ?>
</p>
</div>
</div>
</div>
</div>
<!-- Tab Navigation -->
<div class="row mb-4">
<div class="col-12">
<ul class="nav nav-pills nav-fill gap-2 p-2" id="wpaw-settings-tabs" role="tablist">
<li class="nav-item mb-0" role="presentation">
<button class="nav-link active d-flex align-items-center justify-content-center gap-2" id="general-tab" data-bs-toggle="pill" data-bs-target="#general" type="button" role="tab" aria-controls="general" aria-selected="true">
<i class="bi bi-sliders"></i>
<?php esc_html_e( 'General', 'wp-agentic-writer' ); ?>
</button>
</li>
<li class="nav-item mb-0" role="presentation">
<button class="nav-link d-flex align-items-center justify-content-center gap-2" id="models-tab" data-bs-toggle="pill" data-bs-target="#models" type="button" role="tab" aria-controls="models" aria-selected="false">
<i class="bi bi-stars"></i>
<?php esc_html_e( 'AI Models', 'wp-agentic-writer' ); ?>
</button>
</li>
<li class="nav-item mb-0" role="presentation">
<button class="nav-link d-flex align-items-center justify-content-center gap-2" id="cost-log-tab" data-bs-toggle="pill" data-bs-target="#cost-log" type="button" role="tab" aria-controls="cost-log" aria-selected="false">
<i class="bi bi-graph-up"></i>
<?php esc_html_e( 'Cost Log', 'wp-agentic-writer' ); ?>
</button>
</li>
<li class="nav-item mb-0" role="presentation">
<button class="nav-link d-flex align-items-center justify-content-center gap-2" id="guide-tab" data-bs-toggle="pill" data-bs-target="#guide" type="button" role="tab" aria-controls="guide" aria-selected="false">
<i class="bi bi-book"></i>
<?php esc_html_e( 'Model Guide', 'wp-agentic-writer' ); ?>
</button>
</li>
</ul>
</div>
</div>
<!-- Form Start -->
<form method="post" action="options.php" id="wpaw-settings-form">
<?php settings_fields( 'wp_agentic_writer_settings' ); ?>
<!-- Tab Content -->
<div class="tab-content" id="wpaw-settings-tab-content">
<!-- General Tab -->
<div class="tab-pane fade show active" id="general" role="tabpanel" aria-labelledby="general-tab">
<?php include WP_AGENTIC_WRITER_DIR . 'views/settings/tab-general.php'; ?>
</div>
<!-- Models Tab -->
<div class="tab-pane fade" id="models" role="tabpanel" aria-labelledby="models-tab">
<?php include WP_AGENTIC_WRITER_DIR . 'views/settings/tab-models.php'; ?>
</div>
<!-- Cost Log Tab -->
<div class="tab-pane fade" id="cost-log" role="tabpanel" aria-labelledby="cost-log-tab">
<?php include WP_AGENTIC_WRITER_DIR . 'views/settings/tab-cost-log.php'; ?>
</div>
<!-- Guide Tab -->
<div class="tab-pane fade" id="guide" role="tabpanel" aria-labelledby="guide-tab">
<?php include WP_AGENTIC_WRITER_DIR . 'views/settings/tab-guide.php'; ?>
</div>
</div>
<!-- Sticky Save Button -->
<div class="row mt-4">
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-body d-flex justify-content-between align-items-center py-3">
<div class="text-muted small">
<span class="dashicons dashicons-info-outline me-1"></span>
<?php esc_html_e( 'Changes are saved immediately after clicking Save.', 'wp-agentic-writer' ); ?>
</div>
<div class="d-flex gap-2">
<button type="button" class="btn btn-outline-secondary" id="wpaw-reset-settings">
<span class="dashicons dashicons-image-rotate me-1"></span>
<?php esc_html_e( 'Reset to Defaults', 'wp-agentic-writer' ); ?>
</button>
<button type="submit" class="btn btn-primary btn-lg px-4" id="wpaw-save-settings">
<span class="dashicons dashicons-saved me-1"></span>
<?php esc_html_e( 'Save Settings', 'wp-agentic-writer' ); ?>
</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- Toast Container for Notifications -->
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="wpaw-toast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<span class="me-2">✨</span>
<strong class="me-auto"><?php esc_html_e( 'WP Agentic Writer', 'wp-agentic-writer' ); ?></strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body" id="wpaw-toast-message"></div>
</div>
</div>

View File

@@ -0,0 +1,171 @@
<?php
/**
* Settings Tab: Cost Log
*
* Uses AJAX for server-side pagination and filtering.
*
* @package WP_Agentic_Writer
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="row g-4">
<!-- Summary Stats -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">📊</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'Cost Summary', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Overview of your API spending', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-6 col-md-3">
<div class="p-3 rounded bg-primary bg-opacity-10 text-center">
<div class="fs-4 fw-bold text-primary" id="wpaw-stat-all-time">$0.0000</div>
<div class="text-muted small"><?php esc_html_e( 'All Time', 'wp-agentic-writer' ); ?></div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 rounded bg-success bg-opacity-10 text-center">
<div class="fs-4 fw-bold text-success" id="wpaw-stat-monthly">$0.0000</div>
<div class="text-muted small"><?php esc_html_e( 'This Month', 'wp-agentic-writer' ); ?></div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 rounded bg-info bg-opacity-10 text-center">
<div class="fs-4 fw-bold text-info" id="wpaw-stat-today">$0.0000</div>
<div class="text-muted small"><?php esc_html_e( 'Today', 'wp-agentic-writer' ); ?></div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 rounded bg-warning bg-opacity-10 text-center">
<div class="fs-4 fw-bold text-warning" id="wpaw-stat-avg">$0.0000</div>
<div class="text-muted small"><?php esc_html_e( 'Avg Per Post', 'wp-agentic-writer' ); ?></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Filters -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">🔍</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'Filter Cost Log', 'wp-agentic-writer' ); ?></h5>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3 align-items-end">
<div class="col-md-2">
<label for="wpaw-filter-post" class="form-label small"><?php esc_html_e( 'Post ID', 'wp-agentic-writer' ); ?></label>
<input type="number" class="form-control form-control-sm" id="wpaw-filter-post" placeholder="<?php esc_attr_e( 'All', 'wp-agentic-writer' ); ?>" />
</div>
<div class="col-md-2">
<label for="wpaw-filter-model" class="form-label small"><?php esc_html_e( 'Model', 'wp-agentic-writer' ); ?></label>
<select class="form-select form-select-sm" id="wpaw-filter-model">
<option value=""><?php esc_html_e( 'All models', 'wp-agentic-writer' ); ?></option>
</select>
</div>
<div class="col-md-2">
<label for="wpaw-filter-type" class="form-label small"><?php esc_html_e( 'Type', 'wp-agentic-writer' ); ?></label>
<select class="form-select form-select-sm" id="wpaw-filter-type">
<option value=""><?php esc_html_e( 'All types', 'wp-agentic-writer' ); ?></option>
</select>
</div>
<div class="col-md-2">
<label for="wpaw-filter-date-from" class="form-label small"><?php esc_html_e( 'Date From', 'wp-agentic-writer' ); ?></label>
<input type="date" class="form-control form-control-sm" id="wpaw-filter-date-from" />
</div>
<div class="col-md-2">
<label for="wpaw-filter-date-to" class="form-label small"><?php esc_html_e( 'Date To', 'wp-agentic-writer' ); ?></label>
<input type="date" class="form-control form-control-sm" id="wpaw-filter-date-to" />
</div>
<div class="col-md-2">
<div class="d-flex gap-2">
<button type="button" class="btn btn-primary btn-sm flex-grow-1" id="wpaw-apply-filters">
<span class="dashicons dashicons-filter"></span>
</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="wpaw-clear-filters">
<span class="dashicons dashicons-dismiss"></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Cost Log Table -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">📋</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'Detailed Cost Log', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0" id="wpaw-records-info"><?php esc_html_e( 'Loading...', 'wp-agentic-writer' ); ?></p>
</div>
</div>
<button type="button" class="btn btn-outline-primary btn-sm" id="wpaw-export-csv">
<span class="dashicons dashicons-download me-1"></span>
<?php esc_html_e( 'Export CSV', 'wp-agentic-writer' ); ?>
</button>
</div>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0" id="wpaw-cost-log-table">
<thead class="table-light">
<tr>
<th class="px-3" style="width: 50%;"><?php esc_html_e( 'Post Title', 'wp-agentic-writer' ); ?></th>
<th class="text-center"><?php esc_html_e( 'API Calls', 'wp-agentic-writer' ); ?></th>
<th class="text-end px-3"><?php esc_html_e( 'Total Cost', 'wp-agentic-writer' ); ?></th>
</tr>
</thead>
<tbody id="wpaw-cost-log-tbody">
<tr>
<td colspan="3" class="text-center py-5">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden"><?php esc_html_e( 'Loading...', 'wp-agentic-writer' ); ?></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="d-flex justify-content-between align-items-center p-3 border-top" id="wpaw-pagination-wrapper">
<div class="d-flex align-items-center gap-2">
<label for="wpaw-per-page" class="form-label mb-0 small"><?php esc_html_e( 'Per page:', 'wp-agentic-writer' ); ?></label>
<select class="form-select form-select-sm" id="wpaw-per-page" style="width: auto;">
<option value="10">10</option>
<option value="25" selected>25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
<nav aria-label="Cost log pagination">
<ul class="pagination pagination-sm mb-0" id="wpaw-pagination">
<!-- Pagination will be populated by JS -->
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,315 @@
<?php
/**
* Settings Tab: General
*
* @package WP_Agentic_Writer
* @var string $api_key
* @var float $monthly_budget
* @var float $monthly_used
* @var float $budget_percent
* @var string $budget_status
* @var bool $cost_tracking_enabled
* @var bool $web_search_enabled
* @var string $search_engine
* @var string $search_depth
* @var bool $enable_clarification_quiz
* @var string $clarity_confidence_threshold
* @var array $required_context_categories
* @var int $chat_history_limit
* @var array $preferred_languages
* @var array $custom_languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$settings_instance = WP_Agentic_Writer_Settings_V2::get_instance();
$available_languages = $settings_instance->get_available_languages();
?>
<div class="row g-4">
<!-- API Configuration -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-key-fill text-warning"></i><?php esc_html_e( 'API Configuration', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Connect to OpenRouter to access AI models', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row align-items-end">
<div class="col-md-8">
<label for="openrouter_api_key" class="form-label fw-semibold">
<?php esc_html_e( 'OpenRouter API Key', 'wp-agentic-writer' ); ?>
<span class="text-danger ms-2">*</span>
</label>
<div class="form-text">
<?php printf( wp_kses_post( __( 'Get your API key from <a href="%s" target="_blank" class="text-decoration-none">OpenRouter <i class="bi bi-box-arrow-up-right"></i></a>', 'wp-agentic-writer' ) ), 'https://openrouter.ai/keys' ); ?>
</div>
<div class="input-group">
<span class="input-group-text"><span class="dashicons dashicons-admin-network"></span></span>
<input type="password" class="form-control" id="openrouter_api_key" name="wp_agentic_writer_settings[openrouter_api_key]" value="<?php echo esc_attr( $api_key ); ?>" placeholder="sk-or-v1-..." />
<button class="btn" type="button" id="wpaw-toggle-api-key" style="border-color:#3a4a5e !important">
<span class="bi bi-eye"></span>
</button>
</div>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-outline-primary w-100" id="wpaw-test-api-key">
<i class="bi bi-check-circle-fill"></i>
<?php esc_html_e( 'Test Connection', 'wp-agentic-writer' ); ?>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Budget & Cost Tracking -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-currency-dollar text-warning"></i><?php esc_html_e( 'Budget & Cost Tracking', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Monitor and control your API spending', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<!-- Budget Overview -->
<div class="row mb-4">
<div class="col-md-4">
<div class="p-3 rounded bg-light text-center">
<div class="fs-3 fw-bold text-primary">$<?php echo number_format( $monthly_used, 2 ); ?></div>
<div class="text-muted small"><?php esc_html_e( 'Used This Month', 'wp-agentic-writer' ); ?></div>
</div>
</div>
<div class="col-md-4">
<div class="p-3">
<div class="d-flex justify-content-between mb-1">
<span class="small text-muted"><?php esc_html_e( 'Budget Usage', 'wp-agentic-writer' ); ?></span>
<span class="small fw-semibold"><?php echo number_format( $budget_percent, 1 ); ?>%</span>
</div>
<div class="progress" style="height: 10px;">
<div class="progress-bar bg-<?php echo esc_attr( $budget_status ); ?>" role="progressbar" style="width: <?php echo min( $budget_percent, 100 ); ?>%"></div>
</div>
<div class="small text-muted mt-1">
$<?php echo number_format( $monthly_used, 2 ); ?> / $<?php echo number_format( $monthly_budget, 2 ); ?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="p-3 rounded bg-light text-center">
<div class="fs-3 fw-bold text-success">$<?php echo number_format( max( 0, $monthly_budget - $monthly_used ), 2 ); ?></div>
<div class="text-muted small"><?php esc_html_e( 'Remaining', 'wp-agentic-writer' ); ?></div>
</div>
</div>
</div>
<!-- Budget Input -->
<div class="row g-3">
<div class="col-md-6">
<label for="monthly_budget" class="form-label fw-semibold"><?php esc_html_e( 'Monthly Budget (USD)', 'wp-agentic-writer' ); ?></label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" class="form-control" id="monthly_budget" name="wp_agentic_writer_settings[monthly_budget]" value="<?php echo esc_attr( $monthly_budget ); ?>" min="0" step="0.01" />
</div>
<div class="form-text"><?php esc_html_e( 'Maximum spend per month. Set to 0 for unlimited.', 'wp-agentic-writer' ); ?></div>
</div>
<div class="col-md-6">
<label class="form-label fw-semibold"><?php esc_html_e( 'Cost Tracking', 'wp-agentic-writer' ); ?></label>
<div class="form-check form-switch d-flex align-items-center gap-2">
<input class="form-check-input" type="checkbox" id="cost_tracking_enabled" name="wp_agentic_writer_settings[cost_tracking_enabled]" value="1" <?php checked( $cost_tracking_enabled ); ?> />
<label class="form-check-label" for="cost_tracking_enabled">
<?php esc_html_e( 'Enable cost tracking in editor sidebar', 'wp-agentic-writer' ); ?>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Research & Web Search -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-search text-warning"></i><?php esc_html_e( 'Research & Web Search', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Configure web search for up-to-date content', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-12">
<div class="form-check form-switch d-flex align-items-center gap-2">
<input class="form-check-input" type="checkbox" id="web_search_enabled" name="wp_agentic_writer_settings[web_search_enabled]" value="1" <?php checked( $web_search_enabled ); ?> />
<label class="form-check-label" for="web_search_enabled">
<?php esc_html_e( 'Enable Web Search', 'wp-agentic-writer' ); ?>
<span class="badge text-bg-warning ms-2">~$0.02 per search</span>
</label>
</div>
<div class="form-text"><?php esc_html_e( 'Search the web for current information. Can be toggled per-request in sidebar.', 'wp-agentic-writer' ); ?></div>
</div>
<div class="col-md-6">
<label for="search_engine" class="form-label fw-semibold"><?php esc_html_e( 'Search Engine', 'wp-agentic-writer' ); ?></label>
<select class="form-select" id="search_engine" name="wp_agentic_writer_settings[search_engine]">
<option value="auto" <?php selected( $search_engine, 'auto' ); ?>><?php esc_html_e( 'Auto (Native if available, Exa fallback)', 'wp-agentic-writer' ); ?></option>
<option value="native" <?php selected( $search_engine, 'native' ); ?>><?php esc_html_e( 'Native (Provider\'s built-in search)', 'wp-agentic-writer' ); ?></option>
<option value="exa" <?php selected( $search_engine, 'exa' ); ?>><?php esc_html_e( 'Exa (Always use Exa search)', 'wp-agentic-writer' ); ?></option>
</select>
</div>
<div class="col-md-6">
<label for="search_depth" class="form-label fw-semibold"><?php esc_html_e( 'Search Depth', 'wp-agentic-writer' ); ?></label>
<select class="form-select" id="search_depth" name="wp_agentic_writer_settings[search_depth]">
<option value="low" <?php selected( $search_depth, 'low' ); ?>><?php esc_html_e( 'Low (Basic queries)', 'wp-agentic-writer' ); ?></option>
<option value="medium" <?php selected( $search_depth, 'medium' ); ?>><?php esc_html_e( 'Medium (General queries)', 'wp-agentic-writer' ); ?></option>
<option value="high" <?php selected( $search_depth, 'high' ); ?>><?php esc_html_e( 'High (Detailed research)', 'wp-agentic-writer' ); ?></option>
</select>
</div>
</div>
</div>
</div>
</div>
<!-- Clarification Quiz -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-question-circle text-warning"></i><?php esc_html_e( 'Clarification Quiz', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Gather context before writing for better results', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-12">
<div class="form-check form-switch d-flex align-items-center gap-2">
<input class="form-check-input" type="checkbox" id="enable_clarification_quiz" name="wp_agentic_writer_settings[enable_clarification_quiz]" value="1" <?php checked( $enable_clarification_quiz ); ?> />
<label class="form-check-label" for="enable_clarification_quiz">
<?php esc_html_e( 'Ask clarifying questions when context is missing', 'wp-agentic-writer' ); ?>
</label>
</div>
</div>
<div class="col-md-6">
<label for="clarity_confidence_threshold" class="form-label fw-semibold"><?php esc_html_e( 'Confidence Threshold', 'wp-agentic-writer' ); ?></label>
<select class="form-select" id="clarity_confidence_threshold" name="wp_agentic_writer_settings[clarity_confidence_threshold]">
<option value="0.5" <?php selected( $clarity_confidence_threshold, '0.5' ); ?>><?php esc_html_e( 'Very Sensitive (50%)', 'wp-agentic-writer' ); ?></option>
<option value="0.6" <?php selected( $clarity_confidence_threshold, '0.6' ); ?>><?php esc_html_e( 'Sensitive (60%) - Recommended', 'wp-agentic-writer' ); ?></option>
<option value="0.7" <?php selected( $clarity_confidence_threshold, '0.7' ); ?>><?php esc_html_e( 'Balanced (70%)', 'wp-agentic-writer' ); ?></option>
<option value="0.8" <?php selected( $clarity_confidence_threshold, '0.8' ); ?>><?php esc_html_e( 'Strict (80%)', 'wp-agentic-writer' ); ?></option>
<option value="0.9" <?php selected( $clarity_confidence_threshold, '0.9' ); ?>><?php esc_html_e( 'Very Strict (90%)', 'wp-agentic-writer' ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'When to trigger the clarification quiz', 'wp-agentic-writer' ); ?></div>
</div>
<div class="col-md-6">
<label class="form-label fw-semibold"><?php esc_html_e( 'Context Categories', 'wp-agentic-writer' ); ?></label>
<div class="border rounded p-3" style="max-height: 200px; overflow-y: auto;">
<?php
$categories = array(
'target_outcome' => __( 'Target Outcome', 'wp-agentic-writer' ),
'target_audience' => __( 'Target Audience', 'wp-agentic-writer' ),
'tone' => __( 'Tone of Voice', 'wp-agentic-writer' ),
'content_depth' => __( 'Content Depth', 'wp-agentic-writer' ),
'expertise_level' => __( 'Expertise Level', 'wp-agentic-writer' ),
'content_type' => __( 'Content Type', 'wp-agentic-writer' ),
'pov' => __( 'Point of View', 'wp-agentic-writer' ),
);
foreach ( $categories as $value => $label ) :
?>
<div class="form-check d-flex align-items-center gap-2">
<input class="form-check-input" type="checkbox" id="cat_<?php echo esc_attr( $value ); ?>" name="wp_agentic_writer_settings[required_context_categories][]" value="<?php echo esc_attr( $value ); ?>" <?php checked( in_array( $value, $required_context_categories, true ) ); ?> />
<label class="form-check-label" for="cat_<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></label>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Content Settings / Language -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-globe text-warning"></i><?php esc_html_e( 'Content Settings', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Configure language preferences for your content', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-12">
<label class="form-label fw-semibold"><?php esc_html_e( 'Preferred Languages', 'wp-agentic-writer' ); ?></label>
<div class="row row-cols-2 row-cols-md-4 g-2">
<?php foreach ( $available_languages as $code => $label ) : ?>
<div class="col">
<div class="form-check d-flex align-items-center gap-2">
<input class="form-check-input" type="checkbox" id="lang_<?php echo esc_attr( $code ); ?>" name="wp_agentic_writer_settings[preferred_languages][]" value="<?php echo esc_attr( $code ); ?>" <?php checked( in_array( $code, $preferred_languages, true ) ); ?> />
<label class="form-check-label small" for="lang_<?php echo esc_attr( $code ); ?>"><?php echo esc_html( $label ); ?></label>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="form-text mt-2"><?php esc_html_e( 'Select which languages will appear in the language selector when creating articles.', 'wp-agentic-writer' ); ?></div>
</div>
<div class="col-12">
<label class="form-label fw-semibold"><?php esc_html_e( 'Custom Languages', 'wp-agentic-writer' ); ?></label>
<div id="wpaw-custom-languages-list">
<?php if ( ! empty( $custom_languages ) ) : ?>
<?php foreach ( $custom_languages as $lang ) : ?>
<div class="input-group mb-2 wpaw-custom-language-item">
<input type="text" class="form-control" name="wp_agentic_writer_settings[custom_languages][]" value="<?php echo esc_attr( $lang ); ?>" placeholder="<?php esc_attr_e( 'e.g., Betawi, Minangkabau', 'wp-agentic-writer' ); ?>" />
<button type="button" class="btn btn-outline-danger wpaw-remove-language">
<span class="dashicons dashicons-no-alt"></span>
</button>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<button type="button" id="wpaw-add-custom-language" class="btn btn-outline-secondary btn-sm">
<span class="dashicons dashicons-plus-alt2 me-1"></span>
<?php esc_html_e( 'Add Custom Language', 'wp-agentic-writer' ); ?>
</button>
<div class="form-text mt-2"><?php esc_html_e( 'Add any language not listed above (e.g., regional dialects, minority languages).', 'wp-agentic-writer' ); ?></div>
</div>
</div>
</div>
</div>
</div>
<!-- Advanced Settings -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-gear text-warning"></i><?php esc_html_e( 'Advanced Settings', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Additional configuration options', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-6">
<label for="chat_history_limit" class="form-label fw-semibold"><?php esc_html_e( 'Chat History Limit', 'wp-agentic-writer' ); ?></label>
<input type="number" class="form-control" id="chat_history_limit" name="wp_agentic_writer_settings[chat_history_limit]" value="<?php echo esc_attr( $chat_history_limit ); ?>" min="0" max="200" style="max-width: 120px;" />
<div class="form-text"><?php esc_html_e( 'Messages stored per post. Set to 0 to disable chat history.', 'wp-agentic-writer' ); ?></div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,229 @@
<?php
/**
* Settings Tab: Model Guide
*
* @package WP_Agentic_Writer
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="row g-4">
<!-- How Models Are Used -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">📖</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'How AI Models Are Used', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Understanding which model handles each task', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th class="px-3"><?php esc_html_e( 'Task', 'wp-agentic-writer' ); ?></th>
<th><?php esc_html_e( 'Model Used', 'wp-agentic-writer' ); ?></th>
<th><?php esc_html_e( 'Est. Cost', 'wp-agentic-writer' ); ?></th>
<th class="px-3"><?php esc_html_e( 'Description', 'wp-agentic-writer' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Planning', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-info-subtle text-info"><?php esc_html_e( 'Planning Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.001</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Creates article outline with sections and structure', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Clarity Check', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-secondary-subtle text-secondary"><?php esc_html_e( 'Clarity Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.0005</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Analyzes your prompt and asks clarifying questions', 'wp-agentic-writer' ); ?></td>
</tr>
<tr class="table-primary">
<td class="px-3 fw-semibold"><?php esc_html_e( 'Writing', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-primary"><?php esc_html_e( 'Writing Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.05-0.15</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Generates full article content section by section', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Chat', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-success-subtle text-success"><?php esc_html_e( 'Chat Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.001</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Answers questions and provides quick assistance', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Block Refinement', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-warning-subtle text-warning"><?php esc_html_e( 'Refinement Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.01-0.03</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Improves or rewrites selected content blocks', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Web Search', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-dark-subtle text-dark"><?php esc_html_e( 'OpenRouter Plugin', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">~$0.02</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Searches web for current information (toggle in sidebar)', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold"><?php esc_html_e( 'Image Generation', 'wp-agentic-writer' ); ?></td>
<td><span class="badge bg-danger-subtle text-danger"><?php esc_html_e( 'Image Model', 'wp-agentic-writer' ); ?></span></td>
<td class="text-muted">$0.003-0.04</td>
<td class="px-3 small text-muted"><?php esc_html_e( 'Creates images for articles', 'wp-agentic-writer' ); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Recommended Models -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">⭐</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'Recommended Models', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Best models for each purpose based on quality and cost', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th class="px-3"><?php esc_html_e( 'Model', 'wp-agentic-writer' ); ?></th>
<th><?php esc_html_e( 'Best For', 'wp-agentic-writer' ); ?></th>
<th><?php esc_html_e( 'Cost (per 1M tokens)', 'wp-agentic-writer' ); ?></th>
<th class="px-3"><?php esc_html_e( 'Notes', 'wp-agentic-writer' ); ?></th>
</tr>
</thead>
<tbody>
<tr class="table-success">
<td class="px-3 fw-semibold">Gemini 2.5 Flash</td>
<td><?php esc_html_e( 'Chat, Clarity, Planning', 'wp-agentic-writer' ); ?></td>
<td><code>$0.15 / $0.60</code></td>
<td class="px-3 small">⭐ <?php esc_html_e( 'Best balanced option. Fast reasoning.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold">Gemini 3 Flash Preview</td>
<td><?php esc_html_e( 'Chat, Clarity, Planning (Premium)', 'wp-agentic-writer' ); ?></td>
<td><code>$0.50 / $3.00</code></td>
<td class="px-3 small">🏆 <?php esc_html_e( 'Latest Gemini. Near Pro performance.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr class="table-primary">
<td class="px-3 fw-semibold">Claude 3.5 Sonnet</td>
<td><?php esc_html_e( 'Writing, Refinement', 'wp-agentic-writer' ); ?></td>
<td><code>$3.00 / $15.00</code></td>
<td class="px-3 small">⭐ <?php esc_html_e( 'Best quality writing. Recommended.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold">Mistral Small Creative</td>
<td><?php esc_html_e( 'Writing (Budget)', 'wp-agentic-writer' ); ?></td>
<td><code>$0.10 / $0.30</code></td>
<td class="px-3 small">💰 <?php esc_html_e( 'Best budget writing. Creative style.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold">GPT-4.1</td>
<td><?php esc_html_e( 'Writing, Refinement (Premium)', 'wp-agentic-writer' ); ?></td>
<td><code>$2.00 / $8.00</code></td>
<td class="px-3 small">🏆 <?php esc_html_e( 'Premium option. Excellent instruction following.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr>
<td class="px-3 fw-semibold">Claude Sonnet 4</td>
<td><?php esc_html_e( 'Clarity (Premium)', 'wp-agentic-writer' ); ?></td>
<td><code>$3.00 / $15.00</code></td>
<td class="px-3 small">🏆 <?php esc_html_e( 'Latest Claude. Deep analysis.', 'wp-agentic-writer' ); ?></td>
</tr>
<tr class="table-warning">
<td class="px-3 fw-semibold">GPT-4o</td>
<td><?php esc_html_e( 'Image Prompts', 'wp-agentic-writer' ); ?></td>
<td><code>$2.50 / $10.00</code></td>
<td class="px-3 small">⭐ <?php esc_html_e( 'Generates image descriptions for prompts.', 'wp-agentic-writer' ); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Cost Examples -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
<div class="d-flex align-items-center">
<span class="me-3 fs-4">💡</span>
<div>
<h5 class="card-title mb-1"><?php esc_html_e( 'Cost Examples', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'Real-world cost estimates for common tasks', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<!-- Single Article -->
<div class="col-md-4">
<div class="card h-100 border">
<div class="card-body">
<h6 class="card-title"><?php esc_html_e( 'Single Article (Balanced)', 'wp-agentic-writer' ); ?></h6>
<ul class="list-unstyled small text-muted mb-3">
<li><?php esc_html_e( 'Clarity Check', 'wp-agentic-writer' ); ?>: ~$0.001</li>
<li><?php esc_html_e( 'Planning', 'wp-agentic-writer' ); ?>: ~$0.001</li>
<li><?php esc_html_e( 'Writing (5 sections)', 'wp-agentic-writer' ); ?>: ~$0.10</li>
<li><?php esc_html_e( '1 Image', 'wp-agentic-writer' ); ?>: ~$0.003</li>
</ul>
<div class="d-flex justify-content-between align-items-center border-top pt-2">
<span class="text-muted"><?php esc_html_e( 'Total', 'wp-agentic-writer' ); ?></span>
<span class="fs-5 fw-bold text-primary">~$0.10-0.15</span>
</div>
</div>
</div>
</div>
<!-- 10 Articles/Month -->
<div class="col-md-4">
<div class="card h-100 border">
<div class="card-body">
<h6 class="card-title"><?php esc_html_e( '10 Articles/Month (Balanced)', 'wp-agentic-writer' ); ?></h6>
<ul class="list-unstyled small text-muted mb-3">
<li><?php esc_html_e( '10 articles × $0.15', 'wp-agentic-writer' ); ?></li>
<li><?php esc_html_e( 'Some chat interactions', 'wp-agentic-writer' ); ?>: ~$0.05</li>
<li><?php esc_html_e( 'Refinements', 'wp-agentic-writer' ); ?>: ~$0.20</li>
</ul>
<div class="d-flex justify-content-between align-items-center border-top pt-2">
<span class="text-muted"><?php esc_html_e( 'Total', 'wp-agentic-writer' ); ?></span>
<span class="fs-5 fw-bold text-primary">~$1.50-2.00</span>
</div>
</div>
</div>
</div>
<!-- With Web Search -->
<div class="col-md-4">
<div class="card h-100 border">
<div class="card-body">
<h6 class="card-title"><?php esc_html_e( 'With Web Search', 'wp-agentic-writer' ); ?></h6>
<ul class="list-unstyled small text-muted mb-3">
<li><?php esc_html_e( 'Add ~$0.02 per search request', 'wp-agentic-writer' ); ?></li>
<li><?php esc_html_e( 'Typical: 1-2 searches per article', 'wp-agentic-writer' ); ?></li>
</ul>
<div class="d-flex justify-content-between align-items-center border-top pt-2">
<span class="text-muted"><?php esc_html_e( 'Extra', 'wp-agentic-writer' ); ?></span>
<span class="fs-5 fw-bold text-warning">~$0.02-0.04</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,267 @@
<?php
/**
* Settings Tab: AI Models
*
* @package WP_Agentic_Writer
* @var string $chat_model
* @var string $clarity_model
* @var string $planning_model
* @var string $writing_model
* @var string $refinement_model
* @var string $image_model
* @var array $custom_models
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="row g-4">
<!-- Quick Presets -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-lightning-fill text-warning"></i><?php esc_html_e( 'Quick Presets', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( 'One-click configurations for different budgets', 'wp-agentic-writer' ); ?></p>
</div>
</div>
</div>
<div class="card-body">
<div class="row g-3">
<!-- Budget Preset -->
<div class="col-md-4">
<div class="card border-2 preset-card" data-preset="budget" role="button" tabindex="0">
<div class="card-body">
<div class="d-flex justify-content-between align-items-start mb-2">
<h6 class="card-title mb-0"><?php esc_html_e( 'Budget', 'wp-agentic-writer' ); ?></h6>
<span class="badge text-success" style="color: rgba(var(--bs-success-rgb),var(--bs-text-opacity))!important;">💰 ~$0.06/article</span>
</div>
<div class="small text-muted">
<div><strong>Chat/Clarity/Planning/Refinement:</strong> Gemini 2.5 Flash</div>
<div><strong>Writing:</strong> Mistral Small Creative</div>
<div><strong>Image:</strong> GPT-4o</div>
</div>
</div>
</div>
</div>
<!-- Balanced Preset -->
<div class="col-md-4">
<div class="card border-2 border-primary preset-card" data-preset="balanced" role="button" tabindex="0">
<div class="card-body">
<div class="d-flex justify-content-between align-items-start mb-2">
<h6 class="card-title mb-0"><?php esc_html_e( 'Balanced', 'wp-agentic-writer' ); ?></h6>
<span class="badge bg-primary">⭐ ~$0.14/article</span>
</div>
<div class="small text-muted">
<div><strong>Chat/Clarity/Planning:</strong> Gemini 2.5 Flash</div>
<div><strong>Writing/Refinement:</strong> Claude 3.5 Sonnet</div>
<div><strong>Image:</strong> GPT-4o</div>
</div>
</div>
</div>
</div>
<!-- Premium Preset -->
<div class="col-md-4">
<div class="card border-2 preset-card" data-preset="premium" role="button" tabindex="0">
<div class="card-body">
<div class="d-flex justify-content-between align-items-start mb-2">
<h6 class="card-title mb-0"><?php esc_html_e( 'Premium', 'wp-agentic-writer' ); ?></h6>
<span class="badge text-warning" style="color:rgba(var(--bs-warning-rgb),var(--bs-text-opacity))!important;" >✨ ~$0.31/article</span>
</div>
<div class="small text-muted">
<div><strong>Chat/Planning:</strong> Gemini 3 Flash Preview</div>
<div><strong>Clarity:</strong> Claude Sonnet 4</div>
<div><strong>Writing/Refinement:</strong> GPT-4.1</div>
<div><strong>Image:</strong> GPT-4o</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Individual Model Selectors -->
<div class="col-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3">
<div class="d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center">
<div>
<h5 class="card-title mb-1 d-flex align-items-center gap-2"><i class="bi bi-robot text-warning"></i><?php esc_html_e( 'AI Model Configuration', 'wp-agentic-writer' ); ?></h5>
<p class="text-muted small mb-0"><?php esc_html_e( '6 specialized models for optimal results. Use search to find models.', 'wp-agentic-writer' ); ?></p>
</div>
</div>
<button type="button" class="btn btn-outline-primary btn-sm" id="wpaw-refresh-models">
<span class="spinner-border spinner-border-sm d-none me-1" id="wpaw-models-spinner"></span>
<span class="dashicons dashicons-update me-1"></span>
<?php esc_html_e( 'Refresh Models', 'wp-agentic-writer' ); ?>
</button>
</div>
</div>
<div class="card-body">
<div id="wpaw-models-message" class="alert d-none mb-3"></div>
<div class="row g-4">
<!-- Chat Model -->
<div class="col-md-6">
<label for="chat_model" class="form-label fw-semibold">
<?php esc_html_e( 'Chat Model', 'wp-agentic-writer' ); ?>
<span class="badge bg-info-subtle text-info ms-2">Discussion</span>
</label>
<select id="chat_model" name="wp_agentic_writer_settings[chat_model]" class="form-select wpaw-select2-model" data-model-type="chat">
<option value="<?php echo esc_attr( $chat_model ); ?>"><?php echo esc_html( $chat_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Discussion, research, recommendations', 'wp-agentic-writer' ); ?></div>
</div>
<!-- Clarity Model -->
<div class="col-md-6">
<label for="clarity_model" class="form-label fw-semibold">
<?php esc_html_e( 'Clarity Model', 'wp-agentic-writer' ); ?>
<span class="badge bg-info-subtle text-info ms-2">Analysis</span>
</label>
<select id="clarity_model" name="wp_agentic_writer_settings[clarity_model]" class="form-select wpaw-select2-model" data-model-type="clarity">
<option value="<?php echo esc_attr( $clarity_model ); ?>"><?php echo esc_html( $clarity_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Prompt analysis, quiz generation', 'wp-agentic-writer' ); ?></div>
</div>
<!-- Planning Model -->
<div class="col-md-6">
<label for="planning_model" class="form-label fw-semibold">
<?php esc_html_e( 'Planning Model', 'wp-agentic-writer' ); ?>
<span class="badge bg-info-subtle text-info ms-2">Outline</span>
</label>
<select id="planning_model" name="wp_agentic_writer_settings[planning_model]" class="form-select wpaw-select2-model" data-model-type="planning">
<option value="<?php echo esc_attr( $planning_model ); ?>"><?php echo esc_html( $planning_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Article outline generation', 'wp-agentic-writer' ); ?></div>
</div>
<!-- Writing Model -->
<div class="col-md-6">
<label for="writing_model" class="form-label fw-semibold">
<?php esc_html_e( 'Writing Model', 'wp-agentic-writer' ); ?>
<span class="badge bg-primary ms-2">Main Writer</span>
</label>
<select id="writing_model" name="wp_agentic_writer_settings[writing_model]" class="form-select wpaw-select2-model" data-model-type="execution">
<option value="<?php echo esc_attr( $writing_model ); ?>"><?php echo esc_html( $writing_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Article draft generation (2-5k words)', 'wp-agentic-writer' ); ?></div>
</div>
<!-- Refinement Model -->
<div class="col-md-6">
<label for="refinement_model" class="form-label fw-semibold">
<?php esc_html_e( 'Refinement Model', 'wp-agentic-writer' ); ?>
<span class="badge bg-info text-info ms-2">Editing</span>
</label>
<select id="refinement_model" name="wp_agentic_writer_settings[refinement_model]" class="form-select wpaw-select2-model" data-model-type="execution">
<option value="<?php echo esc_attr( $refinement_model ); ?>"><?php echo esc_html( $refinement_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Paragraph edits, rewrites, polish', 'wp-agentic-writer' ); ?></div>
</div>
<!-- Image Model -->
<div class="col-md-6">
<label for="image_model" class="form-label fw-semibold">
<?php esc_html_e( 'Image Model', 'wp-agentic-writer' ); ?>
<span class="badge text-bg-warning ms-2">Visual</span>
</label>
<select id="image_model" name="wp_agentic_writer_settings[image_model]" class="form-select wpaw-select2-model" data-model-type="image">
<option value="<?php echo esc_attr( $image_model ); ?>"><?php echo esc_html( $image_model ); ?></option>
</select>
<div class="form-text"><?php esc_html_e( 'Image generation', 'wp-agentic-writer' ); ?></div>
</div>
</div>
<!-- Custom Models Section -->
<div class="mt-4 pt-4 border-top">
<div class="d-flex align-items-center justify-content-between mb-3">
<div>
<h6 class="mb-1 d-flex align-items-center gap-2">
<i class="bi bi-plus-circle text-success"></i>
<?php esc_html_e( 'Custom Models', 'wp-agentic-writer' ); ?>
</h6>
<p class="text-muted small mb-0"><?php esc_html_e( 'Add models not listed in API (e.g., black-forest-labs/flux.2-klein-4b). They work if you know the exact ID.', 'wp-agentic-writer' ); ?></p>
</div>
<button type="button" class="btn btn-outline-success btn-sm" id="wpaw-add-custom-model">
<i class="bi bi-plus"></i> <?php esc_html_e( 'Add Model', 'wp-agentic-writer' ); ?>
</button>
</div>
<div id="wpaw-custom-models-list">
<?php
if ( ! empty( $custom_models ) ) :
foreach ( $custom_models as $custom_model ) :
?>
<div class="custom-model-row d-flex gap-2 mb-2 align-items-center" data-saved="true">
<input type="text"
data-field="id"
value="<?php echo esc_attr( $custom_model['id'] ?? '' ); ?>"
class="form-control form-control-sm wpaw-custom-model-id"
placeholder="model-provider/model-name"
style="flex: 2;">
<input type="text"
data-field="name"
value="<?php echo esc_attr( $custom_model['name'] ?? '' ); ?>"
class="form-control form-control-sm wpaw-custom-model-name"
placeholder="Display Name (optional)"
style="flex: 2;">
<select data-field="type" class="form-select form-select-sm wpaw-custom-model-type" style="flex: 1;">
<option value="text" <?php selected( ( $custom_model['type'] ?? 'text' ), 'text' ); ?>><?php esc_html_e( 'Text', 'wp-agentic-writer' ); ?></option>
<option value="image" <?php selected( ( $custom_model['type'] ?? 'text' ), 'image' ); ?>><?php esc_html_e( 'Image', 'wp-agentic-writer' ); ?></option>
</select>
<button type="button" class="btn btn-outline-danger btn-sm wpaw-remove-custom-model">
<i class="bi bi-trash"></i>
</button>
</div>
<?php
endforeach;
endif;
?>
</div>
<template id="wpaw-custom-model-template">
<div class="custom-model-row d-flex gap-2 mb-2 align-items-center">
<input type="text"
data-field="id"
class="form-control form-control-sm wpaw-custom-model-id"
placeholder="model-provider/model-name"
style="flex: 2;">
<input type="text"
data-field="name"
class="form-control form-control-sm wpaw-custom-model-name"
placeholder="Display Name (optional)"
style="flex: 2;">
<select data-field="type" class="form-select form-select-sm wpaw-custom-model-type" style="flex: 1;">
<option value="text"><?php esc_html_e( 'Text', 'wp-agentic-writer' ); ?></option>
<option value="image"><?php esc_html_e( 'Image', 'wp-agentic-writer' ); ?></option>
</select>
<button type="button" class="btn btn-outline-danger btn-sm wpaw-remove-custom-model">
<i class="bi bi-trash"></i>
</button>
</div>
</template>
</div>
<!-- Cost Estimate Display -->
<div class="mt-4 p-4 bg-dark rounded-3">
<div class="d-flex align-items-center justify-content-between">
<div>
<h6 class="mb-1"><?php esc_html_e( 'Estimated Cost Per Article', 'wp-agentic-writer' ); ?></h6>
<p class="text-muted small mb-0"><?php esc_html_e( 'Based on ~2K planning tokens, ~4K execution tokens, and 1 image.', 'wp-agentic-writer' ); ?></p>
</div>
<div class="text-end">
<div id="wpaw-cost-estimate" class="fs-3 fw-bold text-primary">~$0.00</div>
<div class="text-muted small"><?php esc_html_e( 'per article', 'wp-agentic-writer' ); ?></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>