=== Autoloaded Options Manager ===
Contributors:      wpstack
Tags:              performance, optimization, options, autoload, database, speed
Requires at least: 6.2
Tested up to:      6.6
Requires PHP:      7.4
Stable tag:        1.2.0
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Inspect, toggle, clean up, and monitor the autoloaded options WordPress loads on every request — with a safety analyzer, snapshots, and zero dependencies.

== Description ==

WordPress loads every option flagged `autoload = yes` into memory on **every single request** — frontend, admin, AJAX, REST, cron. Over time, plugins pile up options that bloat the `wp_options` table, and there is **no built-in UI to see or change which options autoload**. Autoloaded Options Manager gives you full visibility and control.

The dashboard shows every autoloaded option with its real byte size, attributes each to its source (Core, plugin, theme, or unknown), and lets you toggle the autoload flag with a single click — with correct cache invalidation that works under Redis and Memcached. A hardened guardlist prevents you from ever touching critical options like `siteurl`, `active_plugins`, `cron`, salts, and transients.

Beyond manual inspection, the **Safety Analyzer** runs a time-limited tracking session to measure which options your site actually uses, scans your code for risky patterns, and produces per-option Safe / Caution / Keep verdicts with one-click apply. Every destructive action is preceded by an automatic snapshot, so any change is fully reversible.

 = Features =

* **Real size analysis** — see every autoloaded option with its byte size (MySQL `LENGTH()`), sorted to find the worst offenders.
* **Safe one-click toggle** — flip the autoload flag on any option with correct cache invalidation (works under Redis/Memcached persistent object caches).
* **Protected critical options** — a hardened guardlist prevents you from ever touching `siteurl`, `active_plugins`, `cron`, salts, widgets, transients and more.
* **Owner/source detection** — each option is attributed to WordPress Core, a plugin, your theme, or "Unknown" so you know who to blame.
* **Safety Analyzer** — runtime access tracking, static code risk scan, and per-option Safe / Caution / Keep verdicts with one-click apply.
* **Quick Wins** — actionable summary of the biggest impact items, surfaced front and center.
* **Snapshots + one-click restore** — automatic snapshots before every change. Restore autoload state at any time.
* **Scheduled scans + email alerts** — WP-Cron job watches for new bloated/orphaned options and emails you when your footprint crosses a threshold.
* **Bulk actions** — select many options and toggle or delete them in one go, with confirmation and auto-snapshot.
* **Activity log** — full audit trail of who changed what, when.
* **CSV export** — export the full list for offline analysis.
* **Site Health integration** — appears in WordPress Site Health with a size-based recommendation.
* **Health bar** — at-a-glance indicator of your autoloaded options footprint.
* **Zero dependencies** — no JS build step, no composer, no external libraries. Pure WordPress.

 = Safety =

* Protected list enforced at the repository, REST controller, and UI layers.
* Auto-snapshot before every destructive action (toggle, bulk toggle, delete, restore).
* The scanner is **alert-only** — it never modifies your data.
* Full capability checks (`manage_options` by default, filterable) and REST nonces on every endpoint.
* All plugin data is removed cleanly on uninstall.

== Screenshots ==

1. Dashboard overview — stat tiles, health bar, and Quick Wins panel.
2. Full page view — the complete dashboard from header to settings.
3. Options table — searchable, sortable table with source detection, size, autoload state, safety verdicts, and bulk actions.
4. Safety Analyzer — runtime tracking, code risk scan, and per-option Safe / Caution / Keep recommendations.
5. Snapshots, recent activity, and settings — rollback, audit trail, scheduled scans, and alert configuration.

== Installation ==

1. Upload the `autoloaded-options-manager` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **Tools → Autoloaded Options** to begin.

== Frequently Asked Questions ==

= Is it safe to change the autoload flag? =

For non-critical options, yes — the option stays in the database, it just isn't loaded into memory automatically. Code that calls `get_option()` for it will still work. The plugin's protected list blocks the truly critical options. When in doubt, take a snapshot first.

= How does it work with persistent object caches (Redis/Memcached)? =

Every toggle deletes the per-option cache key, the combined `alloptions` cache key, and the `notoptions` negative cache key. This is the correct sequence that many plugins get wrong.

= Will it slow down my site? =

No. The plugin's own options are non-autoloaded, and all dashboard reads happen only when you view the admin page.

== Changelog ==

= 1.2.0 =
* Safety Analyzer: runtime access tracking, static code risk scan, and per-option Safe / Caution / Keep verdicts with one-click apply.
* Quick Wins panel: actionable summary of the biggest impact items.
* Health bar: at-a-glance autoloaded options footprint indicator.
* Dashboard redesign with refined table, cohesive OKLCH color system, and improved accessibility.
* Fail-safe architecture: every hook callback wrapped in try/catch — the plugin can never cause a blank screen.
* Filesystem hardening: risk scanner gracefully handles open_basedir restrictions and disabled functions on managed hosts.
* Correct WordPress 6.6+ autoload detection (on/off/auto-on/auto values).
* Proper activation hook registration (fires at include time, not plugins_loaded).

= 1.0.0 =
* Initial release — size analysis, autoload toggle, protected list, source detection, snapshots, scheduled scans, bulk actions, activity log, CSV export, Site Health integration.
