內容簡介
這個外掛只有一個功能:禁用沒有登入 WordPress 的訪客使用 WP REST API。不需要任何設定。
這個外掛只有 22 行短小的程式碼(少於 2KB)。因此它非常輕量、快速和有效。
功能
只有訪客(非登入者)使用 REST/JSON 時會被禁用
關閉所有使用者的 REST header
關閉所有使用者的 REST links
100% 即插即用,安裝好後不用管它。
這個外掛是防止網站 REST / JSON API 被濫用的快速方法。
這是怎麼運作的?這個取決於你使用的 WordPress 版本。
WordPress v4.7 及之後的版本
對於 WordPress 4.7 和更高版本,此外掛完全禁用 WP REST API,除非使用者已登入 WordPress。
對於已登入的使用者,WP REST API 將正常運作
對於未登入者,WP REST API 會被禁用
如果未登入的訪客發送 JSON / REST 請求會發生什麼?他們就只會看到一個簡單的訊息:
“rest_login_required: REST API restricted to authenticated users.”
可以透過過濾器鉤子 disable_wp_rest_api_error 自定義此訊息。參考這裡的例子。
較舊的 WordPress 版本
對於版本低於 4.7 的 WordPress,此外掛只會禁用所有使用者的 REST API 功能。
詳細資料可參見 FAQ 部分的說明。
隱私
這個外掛不會收集或儲存任何使用者資料,不會設置任何 cookies,也不會連接到任何第三方位置。因此,這個外掛不會以任何方式影響使用者隱私,如果說有的話,它也會保護潛在敏感資訊不被顯示或經由 REST API 使用。
Disable WP REST API 是由 15 年 WordPress 開發者和書籍作者 Jeff Starr 開發和維護。
支援這個外掛的開發
我用心開發和維護這個免費的外掛,為 WordPress 社群做貢獻。如果你想表達支援,可以捐款或購買我的書:
WordPress 的道
挖掘 WordPress
.htaccess製作指南
深入解析WordPress主題
巫師的 WordPress SQL 食譜
或購買我的高階 WordPress 外掛:
BBQ Pro – 超快的 WordPress 防火牆
Blackhole Pro – 自動攔截壞的機器人
Banhammer Pro – 監控流量並封鎖壞人
GA Google Analytics Pro – 把 WordPress 與 Google Analytics 連接起來
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Does one thing: Completely disables the WordPress REST API for visitors who are not logged into WordPress. No configuration required.
Important: This plugin completely disables the WP REST API for visitors who are NOT logged in to WordPress. So not recommended if your site needs the WP REST API for any non-logged users.
👉 The fast, simple way to prevent abuse of your site’s REST/JSON API
👉 Protects your site’s REST data from all non-logged users and bots
👉 Uses only 4KB of code, so super lightweight, fast, and effective
Features
Disable REST/JSON for visitors (not logged in)
Disables REST header in HTTP response for all users
Disables REST links in HTML head for all users
100% plug-and-play, set-it-and-forget solution
How does it work?
This plugin completely disables the WP REST API unless the user is logged into WordPress.
For logged-in users, WP REST API works normally
For logged-out users, WP REST API is disabled
What happens if logged-out visitor makes a JSON/REST request? They will get only a simple message:
rest_login_required: REST API restricted to authenticated users.
This message may customized via the filter hook, disable_wp_rest_api_error. Check out this post for an example of how to do it.
Privacy
This plugin does not collect or store any user data. It does not set any cookies, and it does not connect to any third-party locations. Thus, this plugin does not affect user privacy in any way. If anything it improves user privacy, as it protects potentially sensitive information from being displayed/accessed via REST API.
Disable WP REST API is developed and maintained by Jeff Starr, 15-year WordPress developer and book author.
Support development of this plugin
I develop and maintain this free plugin with love for the WordPress community. To show support, you can make a donation or purchase one of my books:
The Tao of WordPress
Digging into WordPress
.htaccess made easy
WordPress Themes In Depth
Wizard’s SQL Recipes for WordPress
And/or purchase one of my premium WordPress plugins:
BBQ Pro – Blazing fast WordPress firewall
Blackhole Pro – Automatically block bad bots
Banhammer Pro – Monitor traffic and ban the bad guys
GA Google Analytics Pro – Connect WordPress to Google Analytics
Head Meta Pro – Ultimate Meta Tags for WordPress
Simple Ajax Chat Pro – Unlimited chat rooms
USP Pro – Unlimited front-end forms
Links, tweets and likes also appreciated. Thank you! 🙂
