A lightweight plugin that forces login for backend access in a headless WordPress setup. Keeps your WordPress dashboard private while allowing your front end (e.g. Astro, Next.js) to pull content via GraphQL/REST.
/wp-admin/ and other backend pages/wp-json/ (REST API)/graphql (WPGraphQL)/wp-admin/admin-ajax.php (AJAX)/wp-cron.php (cron)/robots.txt/sitemap*.xml (sitemaps and indexes)/wp-content/uploads/* (media)/favicon.ico/newrelic (New Relic monitoring)/wp/)Developers can customize allowed endpoints using the force_login_allowed_patterns filter:
add_filter('force_login_allowed_patterns', function($patterns) {
$patterns[] = '#^/healthz$#'; // custom health check
$patterns[] = '#^/status$#'; // uptime checks
$patterns[] = '#^/wp-json/acf/v3/.*#'; // specific REST namespace
return $patterns;
});