[WordPress] 外掛分享: Headless

首頁外掛目錄 › Headless
10+
安裝啟用
尚無評分
43 天前
最後更新
問題解決
WordPress 5.0+ PHP 8.0+ v3.0.4 上架:2022-05-24

內容簡介

Headless 外掛讓 WordPress 成為一個無頭內容管理系統,提供額外的欄位和準備好的區塊內容,並支援自訂路由、預覽功能及快取重新驗證,適合需要前端與後端分離的網站。

【主要功能】
• 提供 REST API 的額外欄位和區塊內容
• 自訂菜單和網站設定的路由
• 前端預覽功能指向自訂網址
• 支援快取重新驗證功能
• 簡單配置與 wp-config.php 常數設定

外掛標籤

開發者團隊

⬇ 下載最新版 (v3.0.4) 或搜尋安裝

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

原文外掛簡介

Adds features to use WordPress as a headless CMS: extra fields and prepared block
content on the REST API, custom routes for menus and site settings, a preview that
points at your frontend instead of the WordPress theme, and cache revalidation for
frontends that support it.
Configuration
The plugin is configured with constants in wp-config.php:

HEADLESS_HEAD_BASE_URL — base URL of your frontend. Preview and revalidation requests go here.
HEADLESS_SECRET_TOKEN — shared token sent to the frontend’s /api/preview and /api/revalidate endpoints.
HEADLESS_API_KEY_HEADER_KEY and HEADLESS_API_KEY_HEADER_VALUE — require this HTTP header on requests that use the plugin’s REST additions.

Who can read the responses
The plugin’s REST additions activate on requests carrying ?headless=true. That
query parameter is a routing flag, not authentication — anyone can set it. Unless
you configure HEADLESS_API_KEY_HEADER_KEY and HEADLESS_API_KEY_HEADER_VALUE, the
/headless/v1/menus and /headless/v1/settings routes and the added post fields are
readable by anyone who can reach your REST API. Configure the API key if that is not
what you want.
HEADLESS_SECRET_TOKEN is a single shared secret, and the admin pages hand it to the

browser so the editor can open a preview. Every user who can edit posts — Contributor
upwards — can therefore read it and use it against your frontend’s preview and
revalidation endpoints directly. Treat it as a secret shared with your whole editorial
team, and give the frontend its own rate limiting.
Arbitrary section

BREAKING CHANGE 1.7.0: core/block for block references has changed

延伸相關外掛

文章
Filter
Mastodon