How It Works
The plugin uses the rest_authentication_errors filter — the correct, modern WordPress approach — to intercept REST API requests early in the lifecycle.
Request Flow
1.REST API request comes in2.WordPress runs rest_authentication_errors filter (priority 99)3.Plugin checks: is the API disabled?4.If disabled, check: is the user logged in?5.If logged in: check per-role restrictions and role-specific whitelist6.If not logged in: check global endpoint whitelist7.If the route is whitelisted → allow. If not → return 401 error.Blocked requests exit before any endpoint logic executes. This means virtually zero performance impact for blocked requests.
One-Click Disable
A single toggle blocks all REST API access for unauthenticated visitors. No configuration needed for the basic use case.
Endpoint Auto-Discovery
The plugin discovers all registered REST API endpoints at runtime using WordPress's rest_get_server()->get_routes(). This includes:
WordPress core endpoints (wp/v2)Plugin endpoints (contact-form-7, wc/store, jetpack, etc.)Theme endpointsCustom endpoints from any code that registers REST routesEndpoints are organized into a collapsible namespace tree with:
Namespace-level checkboxes (whitelist entire namespace)Individual route checkboxesSelect All / Deselect All buttons per namespaceRoute count per namespacePer-Role Access Control
Beyond the global toggle, you can restrict specific user roles:
Each role gets its own restricted/unrestricted toggleRestricted roles get their own endpoint whitelistRole restrictions apply even when "Allow all logged-in users" is enabledMultiple roles on a single user: if ANY role is restricted, the restriction appliesSmart Defaults
On activation, the plugin detects known plugins and whitelists their required endpoints:
Contact Form 7 → contact-form-7 namespaceWooCommerce → wc/store and wc/store/v1 namespacesCompatibility warnings appear on the settings page if it detects an active plugin whose endpoints are not whitelisted.
Known plugin detection covers: Contact Form 7, WooCommerce, Jetpack, WPForms.
Performance
Zero frontend footprint — No CSS, JavaScript, or HTTP requests on public pagesAdmin assets load only on the plugin's own settings page (hook_suffix check)Single autoloaded option — One wp_options entry, autoloaded by WordPressIn-memory caching — Settings read once per request and cached in PHP propertyEarly exit — Blocked requests return before endpoint logic runsImport / Export
Export all settings as JSON (toggle state, whitelists, per-role configs)Import previously exported JSON with full validation and sanitizationReset to defaults with confirmation dialogClean Uninstall
When the plugin is deleted (not deactivated):
Removes mdra_settings optionMultisite: cleans up across all network sitesNo custom tables, no transients, no user meta to cleanDeactivation preserves settings for reactivation.
Translation Support
Fully translation-ready with .pot file at languages/maxtdesign-disable-rest-api.pot.