Relocates Content/AI Models/Sources fields into the per-step Pipeline panels; adds a Global Content Context block; retires the 3 duplicate Settings tabs. Option keys unchanged (no migration). QA APPROVE for 80d8e5f; CI green. Agent-Session: pipeline-settings-m2-merge
193 lines
8.9 KiB
PHP
193 lines
8.9 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
/**
|
||
* phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- class naming convention differs from WordPress standard
|
||
*
|
||
* Extended settings fields: schedule, publishing, analytics, display, and images.
|
||
*
|
||
* What: Declarative field definitions for operational settings sections.
|
||
* Who calls it: PRAutoBlogger_Settings_Fields::get_fields() merges these in.
|
||
* Dependencies: PRAUTOBLOGGER_DEFAULT_IMAGE_MODEL, PRAUTOBLOGGER_DEFAULT_IMAGE_STYLE_TEMPLATE constants,
|
||
* PRAutoBlogger_Article_Typography (font choices), PRAutoBlogger_Image_Model_Registry.
|
||
*
|
||
* M2 change: AI Models (reasoning_enabled, reasoning_effort) and Sources
|
||
* (research_model, research_prompt) extended fields have been retired from
|
||
* Settings — they now live in Pipeline Settings per-step panels. The
|
||
* underlying wp_options are unchanged. See CONVENTIONS.md §Retired Settings Tabs.
|
||
*
|
||
* @see admin/class-settings-fields.php — Core fields and sections.
|
||
* @see admin/class-admin-page.php — Renders fields from these definitions.
|
||
* @see admin/class-image-model-registry.php — Static image model list.
|
||
* @see admin/class-pipeline-settings-option-fields.php — Now owns Models + Sources fields.
|
||
* @see frontend/class-article-typography.php — Reads Display settings on frontend.
|
||
* @see CONVENTIONS.md §Retired Settings Tabs — Retirement pattern.
|
||
* @see CONVENTIONS.md §How To: Add a New Admin Setting.
|
||
*/
|
||
class PRAutoBlogger_Settings_Fields_Extended {
|
||
|
||
/**
|
||
* Static image model list for the admin model picker.
|
||
*
|
||
* @return array<int, array<string, mixed>>
|
||
*/
|
||
public static function get_image_models(): array {
|
||
return PRAutoBlogger_Image_Model_Registry::get_models();
|
||
}
|
||
|
||
/**
|
||
* Get schedule, publishing, analytics, display, and image settings fields.
|
||
*
|
||
* Board settings, schedule, publishing, analytics, display, and images only.
|
||
* AI Models and Sources fields are retired from Settings — now in Pipeline Settings.
|
||
*
|
||
* @return array<int, array<string, mixed>>
|
||
*/
|
||
public static function get_fields(): array {
|
||
return array_merge(
|
||
array(
|
||
// ── Board Settings ─────────────────────────────────────────
|
||
array(
|
||
'id' => 'prautoblogger_board_poll_interval',
|
||
'label' => __( 'Board Poll Interval (seconds)', 'prautoblogger' ),
|
||
'type' => 'number',
|
||
'section' => 'prautoblogger_schedule',
|
||
'default' => 5,
|
||
'min' => 3,
|
||
'max' => 60,
|
||
'description' => __( 'How often the kanban board polls for status updates (seconds). Minimum 3s. Doubles automatically when no article is actively generating.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_board_published_window_days',
|
||
'label' => __( 'Published Column Window (days)', 'prautoblogger' ),
|
||
'type' => 'number',
|
||
'section' => 'prautoblogger_schedule',
|
||
'default' => 7,
|
||
'min' => 1,
|
||
'max' => 90,
|
||
'description' => __( 'How many days back the Published column shows articles. Increase to see older published articles on the board.', 'prautoblogger' ),
|
||
),
|
||
|
||
// ── Schedule & Budget ───────────────────────────────────────
|
||
array(
|
||
'id' => 'prautoblogger_daily_article_target',
|
||
'label' => __( 'Articles per Day', 'prautoblogger' ),
|
||
'type' => 'number',
|
||
'section' => 'prautoblogger_schedule',
|
||
'default' => 1,
|
||
'min' => 1,
|
||
'max' => 10,
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_schedule_time',
|
||
'label' => __( 'Generation Time', 'prautoblogger' ),
|
||
'type' => 'time',
|
||
'section' => 'prautoblogger_schedule',
|
||
'default' => '03:00',
|
||
'description' => sprintf(
|
||
/* translators: %s: site timezone string, e.g. "Asia/Singapore". */
|
||
esc_html__( "Daily generation runs at this time in your site's configured timezone (Settings → General → Timezone). Current site timezone: %s.", 'prautoblogger' ),
|
||
esc_html( function_exists( 'wp_timezone_string' ) ? wp_timezone_string() : 'UTC' )
|
||
),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_monthly_budget_usd',
|
||
'label' => __( 'Monthly Budget (USD)', 'prautoblogger' ),
|
||
'type' => 'number',
|
||
'section' => 'prautoblogger_schedule',
|
||
'default' => 50,
|
||
'min' => 0,
|
||
'step' => '0.01',
|
||
'description' => __( 'Hard stop when reached. 0 = unlimited.', 'prautoblogger' ),
|
||
),
|
||
|
||
// ── Publishing ──────────────────────────────────────────────
|
||
array(
|
||
'id' => 'prautoblogger_auto_publish',
|
||
'label' => __( 'Auto-Publish', 'prautoblogger' ),
|
||
'type' => 'toggle',
|
||
'section' => 'prautoblogger_publishing',
|
||
'default' => '0',
|
||
'description' => __( 'Automatically publish editor-approved posts. When off, all posts go to the Review Queue as drafts.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_default_author',
|
||
'label' => __( 'Default Author', 'prautoblogger' ),
|
||
'type' => 'author_select',
|
||
'section' => 'prautoblogger_publishing',
|
||
'default' => 0,
|
||
'description' => __( 'WordPress user assigned as author of generated posts.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_default_category',
|
||
'label' => __( 'Default Category', 'prautoblogger' ),
|
||
'type' => 'category_select',
|
||
'section' => 'prautoblogger_publishing',
|
||
'default' => 0,
|
||
'description' => __( 'Fallback category for generated posts.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_log_level',
|
||
'label' => __( 'Log Level', 'prautoblogger' ),
|
||
'type' => 'select',
|
||
'section' => 'prautoblogger_publishing',
|
||
'default' => 'info',
|
||
'options' => array(
|
||
'error' => __( 'Error — only failures', 'prautoblogger' ),
|
||
'warning' => __( 'Warning — errors + warnings', 'prautoblogger' ),
|
||
'info' => __( 'Info — key events (recommended)', 'prautoblogger' ),
|
||
'debug' => __( 'Debug — everything (verbose)', 'prautoblogger' ),
|
||
),
|
||
'description' => __( 'Controls detail level in the Activity Log.', 'prautoblogger' ),
|
||
),
|
||
|
||
// ── Analytics ───────────────────────────────────────────────
|
||
array(
|
||
'id' => 'prautoblogger_ga4_property_id',
|
||
'label' => __( 'GA4 Property ID', 'prautoblogger' ),
|
||
'type' => 'text',
|
||
'section' => 'prautoblogger_analytics',
|
||
'description' => __( 'Your GA4 Property ID — digits only, e.g. 123456789 (the code adds the "properties/" prefix internally). Find it in GA4 → Admin → Property details. Leave blank to skip GA4.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_ga4_credentials_json',
|
||
'label' => __( 'Service Account JSON', 'prautoblogger' ),
|
||
'type' => 'password',
|
||
'section' => 'prautoblogger_analytics',
|
||
'description' => __( 'Paste the full JSON key file for a service account with Analytics read access.', 'prautoblogger' ),
|
||
),
|
||
|
||
// ── Display ────────────────────────────────────────────────
|
||
array(
|
||
'id' => 'prautoblogger_article_font_family',
|
||
'label' => __( 'Article Font', 'prautoblogger' ),
|
||
'type' => 'select',
|
||
'section' => 'prautoblogger_display',
|
||
'default' => 'default',
|
||
'options' => PRAutoBlogger_Article_Typography::get_font_choices(),
|
||
'description' => __( 'Font family used for generated article body text. Serif fonts improve long-form readability.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_article_font_size',
|
||
'label' => __( 'Article Font Size (px)', 'prautoblogger' ),
|
||
'type' => 'number',
|
||
'section' => 'prautoblogger_display',
|
||
'default' => 0,
|
||
'min' => 0,
|
||
'max' => 32,
|
||
'description' => __( 'Base font size for article body text. 0 uses the theme default (13px). Recommended: 16–18px for comfortable reading.', 'prautoblogger' ),
|
||
),
|
||
array(
|
||
'id' => 'prautoblogger_table_borders',
|
||
'label' => __( 'Table Borders', 'prautoblogger' ),
|
||
'type' => 'toggle',
|
||
'section' => 'prautoblogger_display',
|
||
'default' => '1',
|
||
'description' => __( 'Add visible borders, padding, and alternating row colors to tables in generated articles.', 'prautoblogger' ),
|
||
),
|
||
),
|
||
PRAutoBlogger_Settings_Fields_Images::get_fields()
|
||
);
|
||
}
|
||
}
|