Wp Refinr
Refine is a must-use plugin that centralises a large collection of WordPress cleanup and hardening tweaks: it disables unused features, trims front-end assets, blocks unwanted endpoints, and exposes a consistent API so you can toggle each optimisation from code, WP‑CLI, or custom dashboards.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/lrtrln/wp-refinr/archive/refs/heads/main.zipWP Refine
Refine is a must-use plugin that centralises a large collection of WordPress cleanup and hardening tweaks: it disables unused features, trims front-end assets, blocks unwanted endpoints, and exposes a consistent API so you can toggle each optimisation from code, WP‑CLI, or custom dashboards.
Features
- Optimisation registry – 39 individual switches covering performance, security, and UI tweaks (REST, XML‑RPC, emoji, feeds, automatic updates, Gutenberg assets, etc.).
- Autoloaded and idempotent – drop the folder into
wp-content/mu-plugins/and the defaults apply immediately. - Config persistence – settings are stored under the single option
refine_settings; you can override them programmatically or via CLI. - REST integration – endpoints under
refine/v1/...expose the current configuration and an interactive toggle list (ideal for headless dashboards). - Interactive WP‑CLI UX –
wp refine interactivereturns paginated JSON/table payloads and supports toggles, so other tools (e.g. WP+) can offer modern UIs.
Requirements
- WordPress 6.0+
- PHP 8.1+
- (Optional) WP‑CLI 2.9+ for the CLI integration
Refine is designed as an MU plugin; it must reside in wp-content/mu-plugins/wp-refinr/ (or similar) to load automatically.
Installation
mkdir -p wp-content/mu-plugins
cp -R wp-refinr wp-content/mu-plugins/
When WordPress boots it will require wp-refinr/wp-refinr.php, autoload every file under inc/, and instantiate Refine with the currently saved settings (or defaults on first run).
Default configuration
Every optimisation has a machine key, a human-friendly label, a description, and a boolean default. The full catalogue is available via Refine::getOptionSchema() or the CLI:
wp refine schema
wp refine list_ # shows enabled/default columns
To override settings programmatically, call either:
\Refine\Refine::saveSettings([
'disableEmoji' => true,
'enableSvgUpload'=> true,
]);
or instantiate the class manually if you want an isolated instance:
require_once WP_CONTENT_DIR . '/mu-plugins/wp-refinr/inc/Refine.php';
new \Refine\Refine([
'disableEmoji' => false,
// …
]);
All values are normalised with FILTER_VALIDATE_BOOLEAN, so strings such as '0', 'false', 'yes' are handled gracefully.
WP‑CLI commands
The CLI integration lives in inc/RefineCli.php and is registered only when refinr-cli.php is required by WP‑CLI (no impact on normal page loads).
wp refine list_ # table of options (enabled/default/description)
wp refine schema --format=json # schema without current status
wp refine enable <key>
wp refine disable <key>
wp refine set <key> --value=true
wp refine reset # back to defaults
wp refine interactive --format=json # paginated payload for dashboards
wp refine interactive --config # metadata describing the interactive list
The interactive command returns JSON with the following structure:
{
"type": "toggle-list",
"title": "Refine options",
"description": "Toggle optimisation options.",
"page": 1,
"per_page": 12,
"total_items": 39,
"total_pages": 4,
"items": [
{"key":"disableEmoji","label":"Disable emoji support","description":"...", "checked": true}
],
"message": "Optional status string after a toggle"
}
This is the same contract consumed by the REST API (see below) and by tools such as WP+ CLI Dashboard.
REST API
Two endpoints are exposed under the namespace refine/v1/ (authentication: any user with manage_options):
| Method | Route | Description |
|---|---|---|
GET |
/refine/v1/options |
Returns { settings, schema } (all current values). |
POST |
/refine/v1/options |
Persists a new settings map ({ "settings": {...} }). |
GET |
/refine/v1/interactive |
Returns the paginated interactive payload. |
POST |
/refine/v1/interactive |
Toggles a key: body { "key": "...", "enable": true }. |
Query parameters page and per_page are supported on the interactive endpoint, matching the CLI behaviour.
Lifecycle & bootstrap
Refine::bootstrap() (invoked from wp-refinr.php) is idempotent:
- ensures the option key exists (
refine_settings); - loads persisted settings and instantiates
Refine; - registers REST routes on
rest_api_init.
If you need to initialise Refine from another plugin or theme, simply require inc/Refine.php and call \Refine\Refine::bootstrap()—the method takes no parameters and reads the database option.
Extending or customising
- Hook additional clean-up logic inside your own code by checking
Refine::loadSettings()before attaching new filters/actions. - Use
apply_filtersoradd_filteraround the defaults by wrappingRefine::getDefaultOptions()(e.g. create a MU plugin that callssaveSettings()very early). - Build admin UIs on top of the REST endpoints or on top of the WP‑CLI interactive command without reimplementing individual toggles.
Project status
This module is part of the lrtrln toolchain (see WP+ CLI Dashboard). Issues and PRs are welcome—feel free to open a ticket if you want to contribute more optimisations or additional output formats.
© lrtrln – GPLv3+. Use, modify, and distribute under the terms of the license.