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:
peptiderepo
2026-04-20 12:18:59 +07:00
parent 4791e54821
commit 86ceea0da1
5 changed files with 26 additions and 4 deletions

View File

@@ -158,6 +158,11 @@ class PRAutoBlogger_Admin_Page {
case 'checkboxes':
$current = json_decode( (string) $value, true ) ?: [];
// Hidden input ensures an empty value is POSTed when all boxes
// are unchecked — without this, the browser omits the field
// entirely, so WordPress never fires the sanitize callback and
// the old value persists in wp_options.
printf( '<input type="hidden" name="%s" value="" />', $id );
foreach ( ( $args['options'] ?? [] ) as $v => $label ) {
$is_checked = in_array( $v, $current, true );
$disabled = strpos( $label, 'coming soon' ) !== false ? ' disabled' : '';