[WordPress] 外掛分享: Headless Login Guard

首頁外掛目錄 › Headless Login Guard
WordPress 外掛 Headless Login Guard 的封面圖片
全新外掛
安裝啟用
尚無評分
8 天前
最後更新
問題解決
WordPress 6.0+ PHP 8.1+ v1.0.1 上架:2026-05-17

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Headless Login Guard」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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.
What it does

Requires authentication for /wp-admin/ and other backend pages
Always allows the login page to avoid redirect loops
Leaves key endpoints open for headless use:

/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)

Logged-in users visiting the backend root get redirected to the dashboard
Works with Bedrock layouts (handles root path vs /wp/)

Use case

WordPress is the content backend
Public site is built with Astro/Next.js/etc
Editors log in to WordPress. Visitors never see the backend
Front end builds and live pages can still query GraphQL/REST without authentication

Customization
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;
});

延伸相關外掛

文章
Filter
Apply Filters
Mastodon