Add protected options, quarantine, and JSON export/import#79
Draft
ilicfilip wants to merge 3 commits into
Draft
Conversation
Adopts three safety/portability features inspired by orpharion: - Protected options (Protected_Options class) — hardcoded WP core list + prefix-based protection for the plugin's own options, transients, and quarantine rows. Exposes the `aaa_option_optimizer_protected_options` filter. Enforced server-side in REST delete/autoload handlers. - Quarantine workflow (Quarantine class + new wp_option_optimizer_quarantine table) — deleting an option moves it to a soft-delete table where it can be Restored or Permanently Deleted. Retention is configurable (1–30 days, default 7); expiry action is `keep` (default) or `delete`, with a daily wp-cron cleanup. 50-row cap prevents runaway growth. - JSON export/import (Exporter + Importer classes) — per-row and bulk export download a versioned JSON payload of option_name/value/autoload; import restores from the same format with an overwrite toggle and always refuses protected option names. REST: existing delete handlers default to quarantine (pass force=true to skip). New routes under /aaa-option-optimizer/v1/: /quarantine, /quarantine/restore, /quarantine/delete, /export, /import. Admin UI: new Quarantine tab and Import tab, retention + expiry settings, lock icon replaces Delete for protected rows, per-row Export button, bulk Export action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Test on Playground |
Removing the legacy `.button-delete { margin-right: 0 }` rule — that
override made sense when Delete was the last button in the cell, but now
Export sits after it. Apply margin-right:0 only to the actual last child
button.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The 50-row cap was a foot-gun guard, but it cut against the goal: quarantine exists specifically so users can be brave about deleting options and recover later. Capping at 50 means a bulk delete of 80 rows partially succeeds with no UI surface for the failures — worse UX than just letting it through. Replaces the hard cap with a browser confirmation prompt when bulk deleting more than 25 selected options. The prompt names the count and reminds the user that quarantine is recoverable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three safety/portability features inspired by orpharion:
option_optimizer*,aaa_option_optimizer*,_aaaoo_q__*,_transient_*,_site_transient_*). Extensible via theaaa_option_optimizer_protected_optionsfilter. In the UI, a lock icon replaces the Delete button.wp_option_optimizer_quarantinetable; it can be Restored or Permanently Deleted from a new Quarantine tab. Retention is configurable (1–30 days, default 7) and the expiry action iskeep(default — manual cleanup) ordelete(auto-cleanup via daily wp-cron). Bulk-delete operations over 25 options prompt the user to confirm. Passforce=trueon the REST call to skip quarantine.version,exported_at,site_url,wp_version,options[]). Import accepts the same format with an overwrite toggle; protected option names are always rejected.REST changes
/delete-option,/delete-options,/update-autoloadnow refuse protected options (HTTP 403)./delete-optionand/delete-optionsquarantine by default (useforce=trueto hard-delete)./wp-json/aaa-option-optimizer/v1/:GET /quarantine— listPOST /quarantine/restore— restore an optionPOST /quarantine/delete— permanently deletePOST /export— returns JSON payload +X-AAAOO-FilenameheaderPOST /import— accepts{ payload, overwrite }Files
New: `src/class-protected-options.php`, `src/class-quarantine.php`, `src/class-exporter.php`, `src/class-importer.php`. Modified: database (new table + helpers), REST (handler updates + new routes), Admin Page (new tabs + settings fields), JS (lock UI, export/import flows, quarantine table).
Test plan
🤖 Generated with Claude Code