feat: Pipeline Settings M2 — decompose Content/AI Models/Sources into per-step panels + Global Content Context (#172, v0.24.0)
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
This commit is contained in:
243
includes/admin/class-pipeline-settings-option-fields-data.php
Normal file
243
includes/admin/class-pipeline-settings-option-fields-data.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- class naming convention differs from WordPress standard
|
||||
*
|
||||
* Raw field-array data for PRAutoBlogger_Pipeline_Settings_Option_Fields.
|
||||
*
|
||||
* What: Declarative arrays of field definitions per step context. Extracted
|
||||
* from Option_Fields to satisfy the 300-line/file rule. Contains no
|
||||
* logic — only data. Option keys are the same wp_option names that were
|
||||
* previously registered in the retired AI Models, Content, and Sources
|
||||
* Settings tabs.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Option_Fields::get_fields_for_context().
|
||||
* Dependencies: WP i18n helpers (__) only.
|
||||
*
|
||||
* @see admin/class-pipeline-settings-option-fields.php — Public API wrapper + sanitizer.
|
||||
* @see CONVENTIONS.md §Retired Settings Tabs — retirement pattern.
|
||||
*/
|
||||
class PRAutoBlogger_Pipeline_Settings_Option_Fields_Data {
|
||||
|
||||
/**
|
||||
* Route a context string to its field definitions array.
|
||||
*
|
||||
* @param string $context One of: global|research|analysis|writer|editorial.
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public static function fields_for( string $context ): array {
|
||||
switch ( $context ) {
|
||||
case 'global':
|
||||
return self::global_fields();
|
||||
case 'research':
|
||||
return self::research_fields();
|
||||
case 'analysis':
|
||||
return self::analysis_fields();
|
||||
case 'writer':
|
||||
return self::writer_fields();
|
||||
case 'editorial':
|
||||
return self::editorial_fields();
|
||||
default:
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global context: niche description fed to all pipeline stages.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private static function global_fields(): array {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'prautoblogger_niche_description',
|
||||
'label' => __( 'Niche Description', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Describe your site\'s niche. Passed to every pipeline stage as context.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Research step context fields (moved from Sources Settings tab).
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private static function research_fields(): array {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'prautoblogger_enabled_sources',
|
||||
'label' => __( 'Enabled Sources', 'prautoblogger' ),
|
||||
'type' => 'checkboxes',
|
||||
'choices' => array(
|
||||
'reddit' => __( 'Reddit (RSS + .json)', 'prautoblogger' ),
|
||||
'llm_research' => __( 'LLM Deep Research (reasoning model)', 'prautoblogger' ),
|
||||
),
|
||||
'default' => '["reddit"]',
|
||||
'description' => __( 'Select which platforms to monitor for topics.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_target_subreddits',
|
||||
'label' => __( 'Target Subreddits', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Comma-separated, without r/. E.g.: peptides, Nootropics, biohackers', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reddit_time_filter',
|
||||
'label' => __( 'Reddit Time Window', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'default' => 'day',
|
||||
'options' => array(
|
||||
'day' => __( 'Past 24 hours', 'prautoblogger' ),
|
||||
'week' => __( 'Past week', 'prautoblogger' ),
|
||||
'month' => __( 'Past month', 'prautoblogger' ),
|
||||
),
|
||||
'description' => __( 'How far back to search for trending posts.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reddit_posts_per_subreddit',
|
||||
'label' => __( 'Posts per Subreddit', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'default' => 25,
|
||||
'min' => 5,
|
||||
'max' => 100,
|
||||
'description' => __( 'Maximum posts to fetch per subreddit per collection run.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_pullpush_cache_ttl',
|
||||
'label' => __( 'Research Cache (hours)', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'default' => 6,
|
||||
'min' => 1,
|
||||
'max' => 72,
|
||||
'description' => __( 'How long to cache Reddit research results before re-fetching.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_research_prompt',
|
||||
'label' => __( 'Research Prompt', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'The research brief sent to the LLM. Use {niche} as a placeholder for your niche description.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysis step context fields (moved from Content Settings tab).
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private static function analysis_fields(): array {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'prautoblogger_analysis_instructions',
|
||||
'label' => __( 'Analysis Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions for the topic analysis LLM.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_topic_exclusions',
|
||||
'label' => __( 'Topic Exclusions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Comma-separated topics to never write about.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writer step context fields (moved from AI Models + Content Settings tabs).
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private static function writer_fields(): array {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'prautoblogger_writing_pipeline',
|
||||
'label' => __( 'Writing Pipeline', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'default' => 'multi_step',
|
||||
'options' => array(
|
||||
'multi_step' => __( 'Multi-step (outline → draft → polish)', 'prautoblogger' ),
|
||||
'single_pass' => __( 'Single-pass (one LLM call)', 'prautoblogger' ),
|
||||
),
|
||||
'description' => __( 'Controls which writer sub-stage prompts are active.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_tone',
|
||||
'label' => __( 'Content Tone', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'default' => 'informational',
|
||||
'options' => array(
|
||||
'informational' => __( 'Informational', 'prautoblogger' ),
|
||||
'conversational' => __( 'Conversational', 'prautoblogger' ),
|
||||
'professional' => __( 'Professional', 'prautoblogger' ),
|
||||
'casual' => __( 'Casual', 'prautoblogger' ),
|
||||
'authoritative' => __( 'Authoritative', 'prautoblogger' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_min_word_count',
|
||||
'label' => __( 'Min Word Count', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'default' => 800,
|
||||
'min' => 200,
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_max_word_count',
|
||||
'label' => __( 'Max Word Count', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'default' => 2000,
|
||||
'min' => 500,
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_writing_instructions',
|
||||
'label' => __( 'Writing Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions appended to the writing LLM system prompt.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reasoning_enabled',
|
||||
'label' => __( 'Enable Reasoning', 'prautoblogger' ),
|
||||
'type' => 'toggle',
|
||||
'default' => '0',
|
||||
'description' => __( 'Send reasoning instructions to models that support it. Reasoning tokens are billed as output tokens.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reasoning_effort',
|
||||
'label' => __( 'Reasoning Effort', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'default' => 'medium',
|
||||
'options' => array(
|
||||
'xhigh' => __( 'Extra High — maximum depth, highest cost', 'prautoblogger' ),
|
||||
'high' => __( 'High — thorough reasoning', 'prautoblogger' ),
|
||||
'medium' => __( 'Medium — balanced (recommended)', 'prautoblogger' ),
|
||||
'low' => __( 'Low — light reasoning, lower cost', 'prautoblogger' ),
|
||||
'minimal' => __( 'Minimal — barely any reasoning', 'prautoblogger' ),
|
||||
),
|
||||
'description' => __( 'Only applies when reasoning is enabled.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editorial step context fields (moved from Content Settings tab).
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private static function editorial_fields(): array {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'prautoblogger_editor_instructions',
|
||||
'label' => __( 'Editor Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions for the chief editor LLM review pass.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
125
includes/admin/class-pipeline-settings-option-fields.php
Normal file
125
includes/admin/class-pipeline-settings-option-fields.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -- class naming convention differs from WordPress standard
|
||||
*
|
||||
* Per-step-context option field definitions for the Pipeline Settings page.
|
||||
*
|
||||
* What: Central registry mapping step context identifiers to their editable
|
||||
* wp_option fields. Provides allowlist enforcement, field-type metadata,
|
||||
* and a single sanitize_option() entry point used by the save handler.
|
||||
* Fields were previously under Settings tabs (AI Models, Content, Sources)
|
||||
* retired in M2 — the wp_options themselves are unchanged, only the UI
|
||||
* surface that edits them has moved.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Save_Handler (save_step_settings),
|
||||
* PRAutoBlogger_Pipeline_Settings_Renderer (view data assembly).
|
||||
* Dependencies: PRAutoBlogger_Pipeline_Settings_Option_Fields_Data (field arrays).
|
||||
*
|
||||
* @see admin/class-pipeline-settings-option-fields-data.php — Raw field arrays per context.
|
||||
* @see admin/class-pipeline-settings-save-handler.php — save_step_settings dispatch.
|
||||
* @see admin/class-pipeline-settings-renderer.php — passes field values to template.
|
||||
* @see CONVENTIONS.md §Retired Settings Tabs — retirement pattern.
|
||||
*/
|
||||
class PRAutoBlogger_Pipeline_Settings_Option_Fields {
|
||||
|
||||
/**
|
||||
* All step context identifiers.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function contexts(): array {
|
||||
return array( 'global', 'research', 'analysis', 'writer', 'editorial' );
|
||||
}
|
||||
|
||||
/**
|
||||
* All allowed option names across every context (for allowlist enforcement).
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function allowed_options(): array {
|
||||
$names = array();
|
||||
foreach ( self::contexts() as $ctx ) {
|
||||
foreach ( self::get_fields_for_context( $ctx ) as $field ) {
|
||||
$names[] = $field['id'];
|
||||
}
|
||||
}
|
||||
return array_unique( $names );
|
||||
}
|
||||
|
||||
/**
|
||||
* Field definitions for a given step context.
|
||||
*
|
||||
* Each field definition array contains at minimum:
|
||||
* id string wp_option name.
|
||||
* type string 'textarea'|'select'|'number'|'toggle'|'checkboxes'.
|
||||
* Additional keys per type:
|
||||
* options array For 'select': key => label map of allowed values.
|
||||
* choices array For 'checkboxes': key => label map.
|
||||
* min/max int For 'number': enforced bounds.
|
||||
* default mixed Fallback when option is not set.
|
||||
* label string Human-readable field label.
|
||||
* description string Help text shown below the field.
|
||||
*
|
||||
* @param string $context One of self::contexts().
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public static function get_fields_for_context( string $context ): array {
|
||||
return PRAutoBlogger_Pipeline_Settings_Option_Fields_Data::fields_for( $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a raw POST value for a single field.
|
||||
*
|
||||
* Handles each field type independently: textarea → sanitize_textarea_field,
|
||||
* select → key validated against the options allowlist, number → absint +
|
||||
* bounds clamp, toggle → '0'|'1', checkboxes → JSON array of allowed keys.
|
||||
*
|
||||
* @param mixed $value Raw value from $_POST.
|
||||
* @param array<string, mixed> $field Field definition from get_fields_for_context().
|
||||
* @return mixed Sanitized value ready for update_option().
|
||||
*/
|
||||
public static function sanitize_option( mixed $value, array $field ): mixed {
|
||||
$type = (string) ( $field['type'] ?? 'textarea' );
|
||||
|
||||
switch ( $type ) {
|
||||
case 'textarea':
|
||||
return sanitize_textarea_field( (string) $value );
|
||||
|
||||
case 'toggle':
|
||||
return ( '1' === (string) $value ) ? '1' : '0';
|
||||
|
||||
case 'number':
|
||||
$int = absint( $value );
|
||||
if ( isset( $field['min'] ) && $int < (int) $field['min'] ) {
|
||||
$int = (int) $field['min'];
|
||||
}
|
||||
if ( isset( $field['max'] ) && $int > (int) $field['max'] ) {
|
||||
$int = (int) $field['max'];
|
||||
}
|
||||
return $int;
|
||||
|
||||
case 'select':
|
||||
$key = sanitize_key( (string) $value );
|
||||
$allowed = array_keys( (array) ( $field['options'] ?? array() ) );
|
||||
return in_array( $key, $allowed, true ) ? $key : (string) ( $field['default'] ?? '' );
|
||||
|
||||
case 'checkboxes':
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = array();
|
||||
}
|
||||
$allowed = array_keys( (array) ( $field['choices'] ?? array() ) );
|
||||
$filtered = array();
|
||||
foreach ( $value as $item ) {
|
||||
$item = sanitize_key( (string) $item );
|
||||
if ( in_array( $item, $allowed, true ) ) {
|
||||
$filtered[] = $item;
|
||||
}
|
||||
}
|
||||
return wp_json_encode( $filtered );
|
||||
|
||||
default:
|
||||
return sanitize_text_field( (string) $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,29 +8,28 @@ declare(strict_types=1);
|
||||
*
|
||||
* What: Reads current option values, active prompt versions, and registry
|
||||
* params, then passes a typed data structure to the pipeline-settings-
|
||||
* page.php template. The renderer contains NO business logic — it only
|
||||
* reads and shapes data for the view. All output is escaped by the
|
||||
* template or by helper methods on this class.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Page::render_page() after
|
||||
* the save handler runs.
|
||||
* page.php template. Also reads current values of all per-step option
|
||||
* fields (M2) so the template can render editable forms without touching
|
||||
* WP globals. The renderer contains NO business logic — it only reads
|
||||
* and shapes data for the view.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Page::render_page() after save.
|
||||
* Dependencies: PRAutoBlogger_Pipeline_Settings_Step_Map (step list),
|
||||
* PRAutoBlogger_Pipeline_Settings_Option_Fields (step option defs),
|
||||
* PRAutoBlogger_Prompt_Registry (active row, versions, defs),
|
||||
* PRAutoBlogger_OpenRouter_Model_Field (model picker render),
|
||||
* PRAutoBlogger_Cost_Reporter (monthly spend header).
|
||||
*
|
||||
* @see admin/class-pipeline-settings-step-map.php — Step + key definitions.
|
||||
* @see admin/fields/class-open-router-model-field.php — Model picker component.
|
||||
* @see core/class-prompt-registry.php — Registry read API.
|
||||
* @see templates/admin/pipeline-settings-page.php — HTML template.
|
||||
* @see admin/class-pipeline-settings-step-map.php — Step + key definitions.
|
||||
* @see admin/class-pipeline-settings-option-fields.php — Step option field defs.
|
||||
* @see admin/fields/class-open-router-model-field.php — Model picker component.
|
||||
* @see core/class-prompt-registry.php — Registry read API.
|
||||
* @see templates/admin/pipeline-settings-page.php — HTML template.
|
||||
*/
|
||||
class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
|
||||
/**
|
||||
* Build the view-data array and include the page template.
|
||||
*
|
||||
* Gathers budget and spend data here so the template receives plain scalars
|
||||
* and performs no business-logic instantiation of its own.
|
||||
*
|
||||
* @param array{status: string, message: string} $save_result Result from save handler.
|
||||
* @return void
|
||||
*/
|
||||
@@ -39,11 +38,15 @@ class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
$steps = PRAutoBlogger_Pipeline_Settings_Step_Map::steps();
|
||||
$step = PRAutoBlogger_Pipeline_Settings_Step_Map::find( $active_step ) ?? $steps[0];
|
||||
|
||||
// Gather cost-header data in the renderer so the template stays logic-free.
|
||||
$cost_reporter = new PRAutoBlogger_Cost_Reporter();
|
||||
$monthly_spend = $cost_reporter->get_monthly_spend();
|
||||
$budget = (float) get_option( 'prautoblogger_monthly_budget_usd', 50.00 );
|
||||
|
||||
// Determine the step context for the step-options panel.
|
||||
$step_context = in_array( $step['id'], PRAutoBlogger_Pipeline_Settings_Option_Fields::contexts(), true )
|
||||
? $step['id']
|
||||
: null;
|
||||
|
||||
$view = array(
|
||||
'steps' => $steps,
|
||||
'active_step' => $step,
|
||||
@@ -54,11 +57,33 @@ class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
'step_data' => $this->build_step_data( $step ),
|
||||
'monthly_spend' => $monthly_spend,
|
||||
'budget' => $budget,
|
||||
'global_fields' => $this->build_option_field_values( 'global' ),
|
||||
'step_context' => $step_context,
|
||||
'step_fields' => $step_context ? $this->build_option_field_values( $step_context ) : array(),
|
||||
);
|
||||
|
||||
include PRAUTOBLOGGER_PLUGIN_DIR . 'templates/admin/pipeline-settings-page.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build current option values for all fields in a context.
|
||||
*
|
||||
* Returns an array of [ field_def_with_current_value ] — each field
|
||||
* definition from Option_Fields augmented with a 'current' key holding
|
||||
* the live wp_option value (or the field's default when not set).
|
||||
*
|
||||
* @param string $context Step context identifier.
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function build_option_field_values( string $context ): array {
|
||||
$fields = PRAutoBlogger_Pipeline_Settings_Option_Fields::get_fields_for_context( $context );
|
||||
foreach ( $fields as &$field ) {
|
||||
$field['current'] = get_option( $field['id'], $field['default'] ?? '' );
|
||||
}
|
||||
unset( $field );
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assemble all data needed to render a single step panel.
|
||||
*
|
||||
@@ -69,21 +94,17 @@ class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
$defs = PRAutoBlogger_Prompt_Registry::defs();
|
||||
$active_versions_map = PRAutoBlogger_Prompt_Registry::active_versions();
|
||||
|
||||
// Model info.
|
||||
$model_option = (string) ( $step['model_option'] ?? '' );
|
||||
$model_value = '' !== $model_option ? (string) get_option( $model_option, '' ) : '';
|
||||
|
||||
// System prompt.
|
||||
$system_key = (string) ( $step['system_key'] ?? '' );
|
||||
$system_data = $this->build_prompt_panel_data( $system_key, $defs, $active_versions_map );
|
||||
|
||||
// Agent/user prompts.
|
||||
$agent_panels = array();
|
||||
foreach ( ( $step['agent_keys'] ?? array() ) as $key ) {
|
||||
$agent_panels[ $key ] = $this->build_prompt_panel_data( $key, $defs, $active_versions_map );
|
||||
}
|
||||
|
||||
// Params from the def for the system key (canonical params are on system).
|
||||
$params = isset( $defs[ $system_key ] ) ? ( $defs[ $system_key ]['params'] ?? array() ) : array();
|
||||
|
||||
return array(
|
||||
@@ -116,8 +137,7 @@ class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
$is_default = ( $body === $default_body );
|
||||
$created_at = null !== $active_row ? (string) $active_row['created_at'] : '';
|
||||
$author = null !== $active_row ? (string) $active_row['author'] : 'seed';
|
||||
|
||||
$versions = PRAutoBlogger_Prompt_Registry_Writer::list_versions( $key );
|
||||
$versions = PRAutoBlogger_Prompt_Registry_Writer::list_versions( $key );
|
||||
|
||||
return array(
|
||||
'key' => $key,
|
||||
@@ -134,10 +154,9 @@ class PRAutoBlogger_Pipeline_Settings_Renderer {
|
||||
/**
|
||||
* Render the model picker for a step using the existing field component.
|
||||
*
|
||||
* Public so the template can call it directly. Keeps markup generation
|
||||
* in one place and avoids duplicating the picker rendering logic.
|
||||
* Public so the template can call it directly.
|
||||
*
|
||||
* @param string $model_option wp_option name (e.g. 'prautoblogger_writing_model').
|
||||
* @param string $model_option wp_option name.
|
||||
* @param string $model_value Current model id stored in the option.
|
||||
* @param array<string, mixed> $field_args Field args forwarded to the picker.
|
||||
* @return void Side effect: outputs HTML.
|
||||
|
||||
@@ -8,30 +8,27 @@ declare(strict_types=1);
|
||||
*
|
||||
* What: A stateless save handler for the Pipeline Settings page. On a valid
|
||||
* POST it verifies the nonce, checks capabilities, sanitizes inputs,
|
||||
* and either:
|
||||
* - saves the model option via update_option(), or
|
||||
* - creates a new immutable prompt version in the registry
|
||||
* (PRAutoBlogger_Prompt_Registry_Writer::create_version()).
|
||||
* Saving a prompt NEVER mutates the existing version — it creates a
|
||||
* new one (the registry's core invariant). A "reset to default" POST
|
||||
* creates a new version with the canonical default body.
|
||||
* Model values are read from the POST key that matches the option name
|
||||
* (e.g. $_POST['prautoblogger_research_model']), which is the hidden
|
||||
* input name that PRAutoBlogger_OpenRouter_Model_Field::render() emits.
|
||||
* Prompt keys arrive as a slug-encoded form value that is matched
|
||||
* against the allowlist; the raw POST value is never used as a key
|
||||
* before allowlist validation.
|
||||
* and dispatches to the correct sub-handler:
|
||||
* - save_model — persists a step model option via update_option().
|
||||
* - save_prompt — creates a new immutable prompt version in the registry.
|
||||
* - reset_prompt — creates a new version with the canonical default body.
|
||||
* - save_step_settings — persists one or more relocated option fields for
|
||||
* a step context (global/research/analysis/writer/editorial).
|
||||
* Saving a prompt NEVER mutates the existing version — the registry's core
|
||||
* invariant. Model + step-option values read from POST keys matching the
|
||||
* option name. Prompt keys are slug-matched against the allowlist.
|
||||
* Returns a result array that render_page() passes to the template.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Page::render_page() before
|
||||
* any output is produced.
|
||||
* Who calls it: PRAutoBlogger_Pipeline_Settings_Page::render_page() before output.
|
||||
* Dependencies: PRAutoBlogger_Pipeline_Settings_Step_Map (key allowlists),
|
||||
* PRAutoBlogger_Pipeline_Settings_Option_Fields (step option allowlist),
|
||||
* PRAutoBlogger_Prompt_Registry_Writer (create_version),
|
||||
* PRAutoBlogger_Prompt_Registry (default_body, flush_cache).
|
||||
*
|
||||
* @see admin/class-pipeline-settings-step-map.php — Allowed key definitions.
|
||||
* @see admin/fields/class-open-router-model-field.php — Emits name="$option_name" hidden input.
|
||||
* @see core/class-prompt-registry-writer.php — Immutable version writes.
|
||||
* @see core/class-prompt-registry.php — Read side + default_body.
|
||||
* @see admin/class-pipeline-settings-step-map.php — Model/prompt key allowlists.
|
||||
* @see admin/class-pipeline-settings-option-fields.php — Step option allowlist + sanitizer.
|
||||
* @see admin/fields/class-open-router-model-field.php — Emits name="$option_name".
|
||||
* @see core/class-prompt-registry-writer.php — Immutable version writes.
|
||||
* @see core/class-prompt-registry.php — Read side + default_body.
|
||||
*/
|
||||
class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
|
||||
@@ -39,15 +36,11 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
* Inspect the current request and process the save when it is a valid
|
||||
* Pipeline Settings form submission.
|
||||
*
|
||||
* Side effects: may call update_option() or
|
||||
* PRAutoBlogger_Prompt_Registry_Writer::create_version();
|
||||
* returns error on nonce/cap failure.
|
||||
*
|
||||
* @return array{status: string, message: string} 'idle'|'saved'|'error'.
|
||||
*/
|
||||
public static function maybe_process_save(): array {
|
||||
$idle = array(
|
||||
'status' => 'idle',
|
||||
'status' => 'idle',
|
||||
'message' => '',
|
||||
);
|
||||
|
||||
@@ -59,19 +52,17 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
return $idle;
|
||||
}
|
||||
|
||||
// Capability check.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'You do not have permission to save settings.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
|
||||
// Nonce verification.
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
if ( ! wp_verify_nonce( wp_unslash( $_POST[ PRAutoBlogger_Pipeline_Settings_Page::NONCE_FIELD ] ), PRAutoBlogger_Pipeline_Settings_Page::NONCE_ACTION ) ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'Security check failed. Please reload and try again.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
@@ -81,6 +72,9 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
if ( 'save_model' === $action ) {
|
||||
return self::handle_model_save();
|
||||
}
|
||||
if ( 'save_step_settings' === $action ) {
|
||||
return self::handle_step_settings_save();
|
||||
}
|
||||
if ( 'save_prompt' === $action || 'reset_prompt' === $action ) {
|
||||
return self::handle_prompt_save( $action );
|
||||
}
|
||||
@@ -88,14 +82,53 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
return $idle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist option fields for a step context.
|
||||
*
|
||||
* Reads step_context from POST, validates it, then for each field in that
|
||||
* context reads the corresponding POST value, sanitizes via
|
||||
* PRAutoBlogger_Pipeline_Settings_Option_Fields::sanitize_option(), and
|
||||
* calls update_option(). Only allowlisted option names are written.
|
||||
*
|
||||
* @return array{status: string, message: string}
|
||||
*/
|
||||
private static function handle_step_settings_save(): array {
|
||||
$context = isset( $_POST['step_context'] ) ? sanitize_key( $_POST['step_context'] ) : '';
|
||||
|
||||
if ( ! in_array( $context, PRAutoBlogger_Pipeline_Settings_Option_Fields::contexts(), true ) ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => __( 'Unknown step context.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
|
||||
$fields = PRAutoBlogger_Pipeline_Settings_Option_Fields::get_fields_for_context( $context );
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
$id = (string) $field['id'];
|
||||
$raw = isset( $_POST[ $id ] ) ? wp_unslash( $_POST[ $id ] ) : ( $field['default'] ?? '' );
|
||||
// For checkboxes the POST value is an array (or absent = empty array).
|
||||
if ( 'checkboxes' === ( $field['type'] ?? '' ) ) {
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$raw = isset( $_POST[ $id ] ) && is_array( $_POST[ $id ] ) ? $_POST[ $id ] : array();
|
||||
}
|
||||
$sanitized = PRAutoBlogger_Pipeline_Settings_Option_Fields::sanitize_option( $raw, $field );
|
||||
update_option( $id, $sanitized );
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => 'saved',
|
||||
'message' => __( 'Settings saved.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a model selection for one step.
|
||||
*
|
||||
* The model value is read from $_POST[$option_name] — the same key that
|
||||
* PRAutoBlogger_OpenRouter_Model_Field::render($option_name, ...) emits as
|
||||
* <input type="hidden" name="$option_name" ...>. model-picker.js writes to
|
||||
* that hidden input directly via DOM id, so the value is present under the
|
||||
* option-name key in the submitted POST body.
|
||||
* that hidden input directly via DOM id.
|
||||
*
|
||||
* Only allowlisted model option names from Step_Map may be updated.
|
||||
*
|
||||
@@ -106,22 +139,15 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
|
||||
if ( ! in_array( $option_name, PRAutoBlogger_Pipeline_Settings_Step_Map::allowed_model_options(), true ) ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'Unknown model option.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
|
||||
// Read the value from the named hidden input that render() produced.
|
||||
// PRAutoBlogger_OpenRouter_Model_Field::render($id, ...) emits:
|
||||
// <input type="hidden" id="$id" name="$id" value="..." />
|
||||
// model-picker.js writes the chosen model to that input by DOM id,
|
||||
// so the form posts under the option name, not a separate 'model_id' key.
|
||||
$model_id = isset( $_POST[ $option_name ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $option_name ] ) )
|
||||
: '';
|
||||
|
||||
// For the image model, delegate to the same sanitizer logic as
|
||||
// PRAutoBlogger_Settings_Sanitizer to derive + store provider consistently.
|
||||
if ( 'prautoblogger_image_model' === $option_name ) {
|
||||
$candidate = sanitize_text_field( $model_id );
|
||||
$provider = PRAutoBlogger_Image_Model_Registry::provider_for( $candidate );
|
||||
@@ -129,19 +155,19 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
update_option( 'prautoblogger_image_provider', $provider );
|
||||
update_option( $option_name, $candidate );
|
||||
return array(
|
||||
'status' => 'saved',
|
||||
'status' => 'saved',
|
||||
'message' => __( 'Model saved.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'Image model not recognised. Selection unchanged.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
|
||||
update_option( $option_name, sanitize_text_field( $model_id ) );
|
||||
return array(
|
||||
'status' => 'saved',
|
||||
'status' => 'saved',
|
||||
'message' => __( 'Model saved.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
@@ -151,25 +177,17 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
*
|
||||
* The prompt key is received as a slug (dots replaced with hyphens in the
|
||||
* form value). We match the slug against the allowlist by resolving each
|
||||
* allowed key to its slug form — this avoids any reverse-parsing ambiguity
|
||||
* for keys that contain underscores (e.g. content.single_pass).
|
||||
*
|
||||
* Prompt bodies are treated as privileged — only sanitize_textarea_field()
|
||||
* is applied to strip any script injection, but content is not further
|
||||
* mangled — the operator is intentionally writing LLM instructions.
|
||||
* allowed key to its slug form — avoiding reverse-parsing ambiguity.
|
||||
*
|
||||
* @param string $action 'save_prompt' or 'reset_prompt'.
|
||||
* @return array{status: string, message: string}
|
||||
*/
|
||||
private static function handle_prompt_save( string $action ): array {
|
||||
// The form sends the key with dots replaced by hyphens (HTML-safe slug).
|
||||
$slug = isset( $_POST['prompt_key'] ) ? sanitize_key( wp_unslash( $_POST['prompt_key'] ) ) : '';
|
||||
|
||||
// Resolve slug back to the real registry key via allowlist lookup.
|
||||
$slug = isset( $_POST['prompt_key'] ) ? sanitize_key( wp_unslash( $_POST['prompt_key'] ) ) : '';
|
||||
$prompt_key = self::resolve_key_from_slug( $slug );
|
||||
if ( null === $prompt_key ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'Unknown prompt key.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
@@ -178,7 +196,7 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
$body = PRAutoBlogger_Prompt_Registry::default_body( $prompt_key );
|
||||
if ( null === $body ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'No default found for this prompt key.', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
@@ -200,7 +218,7 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
|
||||
if ( 0 === $version ) {
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'status' => 'error',
|
||||
'message' => __( 'Failed to save prompt. Is the prompts table available?', 'prautoblogger' ),
|
||||
);
|
||||
}
|
||||
@@ -215,10 +233,6 @@ class PRAutoBlogger_Pipeline_Settings_Save_Handler {
|
||||
/**
|
||||
* Resolve a URL/form slug back to the canonical registry key.
|
||||
*
|
||||
* Each allowed key is converted to a slug (dots → hyphens, everything
|
||||
* lowercased by sanitize_key) and compared against the submitted value.
|
||||
* No string-reverse parsing — only allowlist membership determines a match.
|
||||
*
|
||||
* @param string $slug Slug as received from the form (after sanitize_key).
|
||||
* @return string|null Canonical key, or null when not in the allowlist.
|
||||
*/
|
||||
|
||||
@@ -11,17 +11,23 @@ declare(strict_types=1);
|
||||
* Dependencies: PRAUTOBLOGGER_DEFAULT_IMAGE_MODEL, PRAUTOBLOGGER_DEFAULT_IMAGE_STYLE_TEMPLATE constants,
|
||||
* PRAutoBlogger_Article_Typography (font choices), PRAutoBlogger_Image_Model_Registry.
|
||||
*
|
||||
* @see admin/class-settings-fields.php — Core fields and sections; calls get_extended_fields().
|
||||
* @see admin/class-admin-page.php — Renders fields registered from these definitions.
|
||||
* @see admin/class-image-model-registry.php — Static image model list extracted for 300-line compliance.
|
||||
* @see frontend/class-article-typography.php — Reads Display settings on the frontend.
|
||||
* @see CONVENTIONS.md — "How To: Add a New Admin Setting".
|
||||
* 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.
|
||||
* Delegates to Image_Model_Registry (extracted for 300-line file limit).
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
@@ -30,58 +36,16 @@ class PRAutoBlogger_Settings_Fields_Extended {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schedule, publishing, analytics, and image settings fields.
|
||||
* 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(
|
||||
// ── Sources (extended) ──────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_research_model',
|
||||
'label' => __( 'Research Model', 'prautoblogger' ),
|
||||
'type' => 'model_select',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'default' => PRAUTOBLOGGER_DEFAULT_ANALYSIS_MODEL,
|
||||
'capability' => 'text→text',
|
||||
'description' => __( 'Model for LLM Deep Research. Pick a reasoning-capable model (e.g. Grok 4.1 Fast, DeepSeek-R1) for best results. Only used when LLM Deep Research is enabled above.', 'prautoblogger' ),
|
||||
'badge' => __( 'Reasoning', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_research_prompt',
|
||||
'label' => __( 'Research Prompt', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'default' => 'Conduct a deep research sweep of the {niche} space and identify the most substantive, actionable topics that practitioners and curious newcomers are searching for or actively discussing.' . "\n\n" . 'Focus on:' . "\n" . '- Practical questions real readers would search for (not theoretical debates)' . "\n" . '- Emerging trends gaining momentum in the community' . "\n" . '- Common misconceptions that deserve clarification' . "\n" . '- Comparative analysis (product vs. product, protocol vs. protocol)' . "\n" . '- Safety and efficacy topics that drive concern or curiosity' . "\n" . '- Beginner-to-advanced mix — cover entry-level and depth-focused topics' . "\n\n" . 'Aim for topics that feel timely, underserved by existing content, and likely to drive reader engagement. Return 8-12 findings with detailed analysis in each.',
|
||||
'description' => __( 'The research brief sent to the LLM. Use {niche} as a placeholder for your niche description. The system prompt handles output format — this controls WHAT to research.', 'prautoblogger' ),
|
||||
),
|
||||
|
||||
// ── AI Models (extended) ────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_reasoning_enabled',
|
||||
'label' => __( 'Enable Reasoning', 'prautoblogger' ),
|
||||
'type' => 'toggle',
|
||||
'section' => 'prautoblogger_models',
|
||||
'default' => '0',
|
||||
'description' => __( 'Send reasoning instructions to models that support it (e.g. Grok, DeepSeek-R1). Reasoning tokens are billed as output tokens — expect higher costs per call. Models that don\'t support reasoning will ignore this.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reasoning_effort',
|
||||
'label' => __( 'Reasoning Effort', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'section' => 'prautoblogger_models',
|
||||
'default' => 'medium',
|
||||
'options' => array(
|
||||
'xhigh' => __( 'Extra High — maximum depth, highest cost', 'prautoblogger' ),
|
||||
'high' => __( 'High — thorough reasoning', 'prautoblogger' ),
|
||||
'medium' => __( 'Medium — balanced (recommended)', 'prautoblogger' ),
|
||||
'low' => __( 'Low — light reasoning, lower cost', 'prautoblogger' ),
|
||||
'minimal' => __( 'Minimal — barely any reasoning', 'prautoblogger' ),
|
||||
),
|
||||
'description' => __( 'How much effort the model spends reasoning before answering. Higher effort = more reasoning tokens = higher cost. Only applies when reasoning is enabled above.', 'prautoblogger' ),
|
||||
),
|
||||
|
||||
// ── Board Settings ─────────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_board_poll_interval',
|
||||
|
||||
@@ -8,21 +8,31 @@ declare(strict_types=1);
|
||||
*
|
||||
* Centralizes all field and section definitions in one place, making it trivial
|
||||
* to add new settings (just add one array entry). Decoupled from page rendering logic.
|
||||
* Core fields (API, Models, Content, Sources) live here; operational fields
|
||||
* (Schedule, Publishing, Analytics, Images) are in Settings_Fields_Extended.
|
||||
* Core fields (API Keys) live here; operational fields (Schedule, Publishing, Analytics,
|
||||
* Display, Images) are in Settings_Fields_Extended.
|
||||
*
|
||||
* M2 change: AI Models, Content, and Sources sections were retired. Those fields
|
||||
* are now edited exclusively in Pipeline Settings per-step panels. The underlying
|
||||
* wp_options are unchanged — only the UI surface has moved. See CONVENTIONS.md
|
||||
* §Retired Settings Tabs for the retirement pattern.
|
||||
*
|
||||
* Triggered by: PRAutoBlogger_Admin_Page::on_register_settings() calls static methods here.
|
||||
* Dependencies: PRAutoBlogger_Settings_Fields_Extended for operational field definitions.
|
||||
*
|
||||
* @see admin/class-settings-fields-extended.php — Schedule, publishing, analytics, images fields.
|
||||
* @see admin/class-admin-page.php — Calls get_sections() and get_fields() to register settings.
|
||||
* @see CONVENTIONS.md — "How To: Add a New Admin Setting".
|
||||
* @see admin/class-settings-fields-extended.php — Schedule, publishing, analytics, images.
|
||||
* @see admin/class-admin-page.php — Calls get_sections() + get_fields().
|
||||
* @see admin/class-pipeline-settings-option-fields.php — Now owns AI Models/Content/Sources fields.
|
||||
* @see CONVENTIONS.md §Retired Settings Tabs — Retirement pattern.
|
||||
* @see CONVENTIONS.md §How To: Add a New Admin Setting — Extension guide.
|
||||
*/
|
||||
class PRAutoBlogger_Settings_Fields {
|
||||
|
||||
/**
|
||||
* Get all settings sections. Each section maps to a tab in the admin UI.
|
||||
*
|
||||
* AI Models, Content, and Sources sections were retired in M2 — those fields
|
||||
* moved to Pipeline Settings per-step panels.
|
||||
*
|
||||
* @return array<string, array{title: string, icon: string, description: string}>
|
||||
*/
|
||||
public static function get_sections(): array {
|
||||
@@ -32,21 +42,6 @@ class PRAutoBlogger_Settings_Fields {
|
||||
'icon' => 'dashicons-admin-network',
|
||||
'description' => __( 'Connect your external services. Keys are encrypted at rest.', 'prautoblogger' ),
|
||||
),
|
||||
'prautoblogger_models' => array(
|
||||
'title' => __( 'AI Models', 'prautoblogger' ),
|
||||
'icon' => 'dashicons-superhero-alt',
|
||||
'description' => __( 'Choose which models power each stage of the pipeline.', 'prautoblogger' ),
|
||||
),
|
||||
'prautoblogger_content' => array(
|
||||
'title' => __( 'Content', 'prautoblogger' ),
|
||||
'icon' => 'dashicons-edit-large',
|
||||
'description' => __( 'Control tone, length, pipeline mode, and topic guardrails.', 'prautoblogger' ),
|
||||
),
|
||||
'prautoblogger_sources' => array(
|
||||
'title' => __( 'Sources', 'prautoblogger' ),
|
||||
'icon' => 'dashicons-rss',
|
||||
'description' => __( 'Configure where PRAutoBlogger finds trending topics.', 'prautoblogger' ),
|
||||
),
|
||||
'prautoblogger_schedule' => array(
|
||||
'title' => __( 'Schedule & Budget', 'prautoblogger' ),
|
||||
'icon' => 'dashicons-calendar-alt',
|
||||
@@ -85,7 +80,10 @@ class PRAutoBlogger_Settings_Fields {
|
||||
}
|
||||
|
||||
/**
|
||||
* Core fields: API Keys, AI Models, Content, and Sources.
|
||||
* Core fields: API Keys section only.
|
||||
*
|
||||
* AI Models, Content, and Sources fields have moved to Pipeline Settings
|
||||
* per-step panels (M2). Do not re-add them here.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
@@ -127,173 +125,6 @@ class PRAutoBlogger_Settings_Fields {
|
||||
'max' => 2592000,
|
||||
'description' => __( 'How long Cloudflare may serve cached responses for identical LLM calls. 0 disables caching. Only used when a gateway URL is set above. Safe values: 0 for article generation (always fresh), 3600+ for repeated classification/scoring calls.', 'prautoblogger' ),
|
||||
),
|
||||
|
||||
// ── AI Models ───────────────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_analysis_model',
|
||||
'label' => __( 'Analysis Model', 'prautoblogger' ),
|
||||
'type' => 'model_select',
|
||||
'section' => 'prautoblogger_models',
|
||||
'default' => PRAUTOBLOGGER_DEFAULT_ANALYSIS_MODEL,
|
||||
'capability' => 'text→text',
|
||||
'description' => __( 'Used for source analysis. Pick a cheap, fast model.', 'prautoblogger' ),
|
||||
'badge' => __( 'Low cost', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_writing_model',
|
||||
'label' => __( 'Writing Model', 'prautoblogger' ),
|
||||
'type' => 'model_select',
|
||||
'section' => 'prautoblogger_models',
|
||||
'default' => PRAUTOBLOGGER_DEFAULT_WRITING_MODEL,
|
||||
'capability' => 'text→text',
|
||||
'description' => __( 'Used for article generation. Quality matters here.', 'prautoblogger' ),
|
||||
'badge' => __( 'Quality', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_editor_model',
|
||||
'label' => __( 'Editor Model', 'prautoblogger' ),
|
||||
'type' => 'model_select',
|
||||
'section' => 'prautoblogger_models',
|
||||
'default' => PRAUTOBLOGGER_DEFAULT_EDITOR_MODEL,
|
||||
'capability' => 'text→text',
|
||||
'description' => __( 'Used for the chief editor review pass.', 'prautoblogger' ),
|
||||
'badge' => __( 'Quality', 'prautoblogger' ),
|
||||
),
|
||||
|
||||
// ── Content ─────────────────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_niche_description',
|
||||
'label' => __( 'Niche Description', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_content',
|
||||
'description' => __( 'Describe your site\'s niche. Guides content analysis and generation.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_analysis_instructions',
|
||||
'label' => __( 'Analysis Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions for the topic analysis LLM. Steers how source data is evaluated and which ideas get surfaced — e.g. "Prioritize questions over news. Ignore price-related discussions."', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_tone',
|
||||
'label' => __( 'Content Tone', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => 'informational',
|
||||
'options' => array(
|
||||
'informational' => __( 'Informational', 'prautoblogger' ),
|
||||
'conversational' => __( 'Conversational', 'prautoblogger' ),
|
||||
'professional' => __( 'Professional', 'prautoblogger' ),
|
||||
'casual' => __( 'Casual', 'prautoblogger' ),
|
||||
'authoritative' => __( 'Authoritative', 'prautoblogger' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_writing_pipeline',
|
||||
'label' => __( 'Writing Pipeline', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => 'multi_step',
|
||||
'options' => array(
|
||||
'multi_step' => __( 'Multi-step (outline → draft → polish)', 'prautoblogger' ),
|
||||
'single_pass' => __( 'Single-pass (one LLM call)', 'prautoblogger' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_min_word_count',
|
||||
'label' => __( 'Min Word Count', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => 800,
|
||||
'min' => 200,
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_max_word_count',
|
||||
'label' => __( 'Max Word Count', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => 2000,
|
||||
'min' => 500,
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_writing_instructions',
|
||||
'label' => __( 'Writing Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions appended to the LLM\'s system prompt when writing articles. Use this to steer style, structure, voice, and formatting — e.g. "Always open with a hook question. Use short paragraphs. Cite at least two studies."', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_editor_instructions',
|
||||
'label' => __( 'Editor Instructions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_content',
|
||||
'default' => '',
|
||||
'description' => __( 'Custom instructions for the chief editor LLM review pass. Steers what the editor looks for and how it revises — e.g. "Be strict about medical disclaimers. Reject any article under 800 words."', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_topic_exclusions',
|
||||
'label' => __( 'Topic Exclusions', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_content',
|
||||
'description' => __( 'Comma-separated topics to never write about.', 'prautoblogger' ),
|
||||
),
|
||||
|
||||
// ── Sources ─────────────────────────────────────────────────
|
||||
array(
|
||||
'id' => 'prautoblogger_target_subreddits',
|
||||
'label' => __( 'Target Subreddits', 'prautoblogger' ),
|
||||
'type' => 'textarea',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'description' => __( 'Comma-separated, without r/. E.g.: peptides, Nootropics, biohackers', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_enabled_sources',
|
||||
'label' => __( 'Enabled Sources', 'prautoblogger' ),
|
||||
'type' => 'checkboxes',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'options' => array(
|
||||
'reddit' => __( 'Reddit (RSS + .json)', 'prautoblogger' ),
|
||||
'llm_research' => __( 'LLM Deep Research (reasoning model)', 'prautoblogger' ),
|
||||
),
|
||||
'default' => '["reddit"]',
|
||||
'description' => __( 'Select which platforms to monitor for topics.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_pullpush_cache_ttl',
|
||||
'label' => __( 'Research Cache (hours)', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'default' => 6,
|
||||
'min' => 1,
|
||||
'max' => 72,
|
||||
'description' => __( 'How long to cache Reddit research results before re-fetching. Saves bandwidth on low-traffic sites.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reddit_time_filter',
|
||||
'label' => __( 'Reddit Time Window', 'prautoblogger' ),
|
||||
'type' => 'select',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'default' => 'day',
|
||||
'options' => array(
|
||||
'day' => __( 'Past 24 hours', 'prautoblogger' ),
|
||||
'week' => __( 'Past week', 'prautoblogger' ),
|
||||
'month' => __( 'Past month', 'prautoblogger' ),
|
||||
),
|
||||
'description' => __( 'How far back to search for trending posts and comments.', 'prautoblogger' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'prautoblogger_reddit_posts_per_subreddit',
|
||||
'label' => __( 'Posts per Subreddit', 'prautoblogger' ),
|
||||
'type' => 'number',
|
||||
'section' => 'prautoblogger_sources',
|
||||
'default' => 25,
|
||||
'min' => 5,
|
||||
'max' => 100,
|
||||
'description' => __( 'Maximum posts to fetch per subreddit per collection run.', 'prautoblogger' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user