Skip to content

About

WordPress plugin to track autoloaded option usage, quarantine and restore options safely, and export/import options to JSON.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

44 stars

Watchers

4 watching

Forks

CS PHPStan Lint Security

WordPress Plugin Version WordPress Plugin: Tested WP Version WordPress Plugin Active Installs WordPress Plugin Downloads WordPress Plugin Rating GitHub

Try this plugin on the WordPress playground

GitHub banner

AAA Autoload Optimizer

This plugin tracks which of the autoloaded options are used on a page, and stores that data at the end of page render. It keeps an array of options that it has seen as being used. On the admin page, it compares all the autoloaded options to the array of stored options, and shows the autoloaded options that have not been used as you were browsing the site. If you've been to every page on your site, or you've kept the plugin around for a week or so, this means that those options probably don't need to be autoloaded.

How to use this plugin

Install this plugin, and go through your entire site. Best is to use it normally for a couple of days, or to visit every page on your site and in your admin manually. Then go to the plugin's settings screen, and go through the unused options. You can either decide to remove an unused option (they might for instance be for plugins you no longer use), or to set it to not autoload. The latter action is much less destructive: it'll still be there, but it just won't be autoloaded.

Screenshot of the admin panel

Frequently Asked Questions

Why the AAA prefix in the plugin name?

Because the plugin needs to measure options being loaded, it benefits from being loaded itself first. As WordPress loads plugins alphabetically, starting the name with AAA made sense.

Do I need to take precautions?

Yes!! Backup your database.

Who can view option values?

Every REST route requires manage_options. Option values can include API keys, SMTP passwords and licence keys, and the tables return these values to authorized administrators. This also applies to site administrators on multisite. Only enable the plugin where those administrators are trusted to inspect all site options.

Which actions are protected?

Essential WordPress options, including site URLs, active plugins, the active theme's settings, salts and keys stored in the database, and the current site's roles option, cannot be deleted, created with a false value, or have their autoload state changed through this plugin. Single and bulk deletion require confirmation in the admin screen. Autoload changes preserve the stored value and use WordPress's cache-aware autoload API.

Why are unused-option recommendations paused?

Tracking stores up to about 10,000 distinct names. The limit is checked without locking, so concurrent requests can push slightly past it. Once it is reached, names already recorded keep counting, but a new name is dropped, and the plugin then marks observations incomplete and pauses unused-option recommendations, because a dropped name could otherwise be reported as unused. Data migrated from older versions is kept in full, even past the limit. A failed tracking write does not pause recommendations; it loses at most that request's counts. Reset tracking to start a fresh observation period.

How can I add recognized plugins?

Please do a pull request via GitHub on this file in the plugin.

How can I report security bugs?

You can report security bugs through the Patchstack Vulnerability Disclosure Program. The Patchstack team help validate, triage and handle any security vulnerabilities. Report a security vulnerability.

Development checks

Run composer lint, composer check-cs, composer phpstan, and composer lint-known-plugins with the development dependencies installed, and npm run test:hardening:js for the admin action regressions. The plugin-map validator requires an object keyed by plugin slug, with exactly a non-empty name and a non-empty array of unique string option_prefixes per entry.

Run wp eval-file /path/to/aaa-option-optimizer/tests/hardening.php only on a disposable WordPress installation with an administrator at user ID 1 and define( 'AAAOO_DISPOSABLE_TEST_SITE', true ); in its configuration. The test creates and deletes fixtures and resets tracking data. It covers REST validation, exact option names, protected options, failed autoload updates, raw-value preservation, malformed sorting, and tracking limits.

About

WordPress plugin to track autoloaded option usage, quarantine and restore options safely, and export/import options to JSON.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

44 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages