Fix enabled-sources checkbox not persisting when all unchecked
Browser omits checkbox fields from POST when none are checked, so the prautoblogger_enabled_sources option retained its previous value (with Reddit). Added a hidden input to the checkboxes renderer so an empty value is always submitted. Also replaced the hardcoded "Collecting sources from Reddit…" pipeline status with a dynamic message reflecting actually-enabled sources. Bump 0.6.2 → 0.6.3. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -156,7 +156,10 @@ class PRAutoBlogger_Pipeline_Runner {
|
||||
private function orchestrate( PRAutoBlogger_Cost_Tracker $cost_tracker ): array {
|
||||
$target = absint( get_option( 'prautoblogger_daily_article_target', 1 ) );
|
||||
|
||||
$this->broadcast_stage( __( 'Collecting sources from Reddit…', 'prautoblogger' ) );
|
||||
$enabled = json_decode( get_option( 'prautoblogger_enabled_sources', '["reddit"]' ), true );
|
||||
$source_labels = is_array( $enabled ) ? implode( ', ', $enabled ) : 'reddit';
|
||||
/* translators: %s is a comma-separated list of enabled source names, e.g. "reddit, llm_research". */
|
||||
$this->broadcast_stage( sprintf( __( 'Collecting sources from %s…', 'prautoblogger' ), $source_labels ) );
|
||||
( new PRAutoBlogger_Source_Collector() )
|
||||
->set_cost_tracker( $cost_tracker )
|
||||
->collect_from_all_sources();
|
||||
|
||||
@@ -46,7 +46,10 @@ class PRAutoBlogger_Source_Collector {
|
||||
* @return int Total number of new records inserted.
|
||||
*/
|
||||
public function collect_from_all_sources(): int {
|
||||
$enabled = json_decode( get_option( 'prautoblogger_enabled_sources', '["reddit"]' ), true );
|
||||
$raw = get_option( 'prautoblogger_enabled_sources', '["reddit"]' );
|
||||
$enabled = json_decode( (string) $raw, true );
|
||||
// Only fall back to reddit if the option is corrupt (non-JSON).
|
||||
// An empty array '[]' is a valid choice — the user disabled all sources.
|
||||
if ( ! is_array( $enabled ) ) {
|
||||
$enabled = [ 'reddit' ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user