前言介紹
- 這款 WordPress 外掛「Only REST API」是 2015-09-24 上架。
- 目前有 30 個安裝啟用數。
- 上一次更新是 2015-12-07,距離現在已有 3435 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.0 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
braad |
外掛標籤
內容簡介
是否有一個 WordPress 安裝只作為您的網頁應用程式的資料層和/或管理介面?
此外掛將有效地關閉所有預設的前端輸出,重定向所有前端 URL 到主站 URL,並可選擇顯示您選擇的訊息。該訊息可以是一個簡單明了的純文字訊息,或者您可以使用包含的過濾器完全控制 HTML 輸出。
此外掛不會影響 wp-admin 中的所有活動和所有請求資源,例如圖像、腳本、檔案等。只有透過 template_redirect 動作的請求將受到影響。
訊息輸出
為了不汙染您可能在應用程式中使用的資料結構(例如文章和頁面),此外掛包含了一個設定頁面,其包含一個簡單的文字區塊,您可以在其中儲存任何您想要顯示的基本訊息。該訊息內容存儲於選項表格中,並且該文字區塊支援您可以在文章內容中使用的所有 HTML。
您可以使用 only_rest_api_page_content 過濾器在
標籤內包含任何自訂 HTML 輸出,或者您可以使用 only_rest_api_page_html 過濾器完全替換所有訊息頁面的 HTML 輸出,包括 和 標籤。此外還有一個 only_rest_api_page_css 過濾器,允許您覆蓋此外掛包含的 5 行 CSS,以將訊息置中於頁面中。
如果您想要添加 hook 或有功能請求,請讓我知道。在 Github 上,我們歡迎 pull requests Github.
過濾器範例
在
標籤內使用自訂 HTML:add_filter( 'only_rest_api_page_content', 'xxx_page_content' );
function xxx_page_content( $content ) {
$content = '
return $content;
}
將自訂 CSS 添加到預設輸出:
add_filter( 'only_rest_api_page_css', 'xxx_page_css' );
function xxx_page_css( $css ) {
$css .= '.page-content { color: red; font-size: 72px; }';
return $css;
}
替換訊息頁面的整個 HTML 輸出:
add_filter( 'only_rest_api_page_html', 'xxx_page_html' );
function xxx_page_html( $html ) {
ob_start();
?>
Ain't nobody got time for non-REST API requests. Please try again at a proper endpoint. 🙂
$html = ob_get_clean();
return $html;
}
原文外掛簡介
Got a WordPress install that serves only as the data layer and/or admin UI of your web application?
This plugin will effectively turn off all default front end output, redirect all front end urls to the main site url, and optionally display a message of your choice. The message can be a simple plain text message or you can use the included filters to completely control the HTML output.
All activity in the wp-admin and all requests for assets like images, scripts, files, etc. will be unaffected by this plugin. Only requests that go through the template_redirect action will be affected.
Message Output
Rather than contaminate the data structures you might be using for your application (like posts and pages) this plugin includes a settings page with a simple textarea box where you can save any basic message you want to show. The message content is stored in the options table, and the textarea supports all the same HTML that you can use in post content.
You can use the only_rest_api_page_content filter to include any custom HTML output you want inside the
There is also an only_rest_api_page_css filter that allows you to override the 5 lines of CSS this plugin includes to center the message on the page.
If you want a hook added or have a feature request let me know. Pull requests are welcome on Github.
Filter Examples
Use custom HTML inside the tags:
add_filter( 'only_rest_api_page_content', 'xxx_page_content' );
function xxx_page_content( $content ) {
$content = '
';
return $content;
}
Add custom CSS to the default output:
add_filter( 'only_rest_api_page_css', 'xxx_page_css' );
function xxx_page_css( $css ) {
$css .= '.page-content { color: red; font-size: 72px; }';
return $css;
}
Replace the entire HTML output for the page:
add_filter( 'only_rest_api_page_html', 'xxx_page_html' );
function xxx_page_html( $html ) {
ob_start();
?>
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Only REST API」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Disable REST API 》這是最全面的 WordPress REST API 存取控制外掛!, 輕鬆安裝,安裝後不需要額外設定即可使用。只需上傳並啟用,整個 REST API 將無法被一般訪客存取。, 但如...。
Markup (JSON-LD) structured in schema.org 》讓您可以在網站上包含 schema.org JSON-LD 語法標記, 基礎知識是 “https://schema.org/” 和 “https://developers.google.com/structured-d...。
Disable WP REST API 》這個外掛只有一個功能:禁用沒有登入 WordPress 的訪客使用 WP REST API。不需要任何設定。, 這個外掛只有 22 行短小的程式碼(少於 2KB)。因此它非常輕量、...。
WPGet API – Connect to any external REST API 》簡單地連接WordPress至外部API的最簡單方式。, , WPGetAPI 可輕鬆地從無限量的第三方 REST API 發送和接收資料,然後使用「Shortcode」或「Template Tag」格...。
WordPress REST API (Version 2) 》WordPress 正轉變成一個完整的應用程式框架,因此需要新的 API。這個專案的目的是創建一個易於使用、易於理解且經過良好測試的框架,用於創建這些 API,以及...。
WP REST API – OAuth 1.0a Server 》使用這個外掛,您可以將應用程式連接至您的 WordPress 網站,而不必透露您的密碼。, 此外掛使用 OAuth 1.0a 協議,允許委派授權,即允許應用程式使用一組次要...。
Get Use APIs – JSON Content Importer 》在你的 WordPress 網站上展示 JSON-Feed/API 的即時資料!, 從網址上抓取 JSON 資料並在 WordPress 頁面上轉換為 HTML。, JSON Content Importer-API-和 Web...。
REST API Log 》這是一款針對 WordPress REST API v2 的外掛程式,可記錄 REST API 的請求和回應紀錄。, 功能包括:, , WordPress 管理頁面,用於查看和搜尋日誌條目, API 端...。
WP-REST-API V2 Menus 》此外掛會擴展WordPress REST API (版本 2),提供新的路由讓 WordPress 註冊過的選單可以被呼叫。, 以下是新增的路徑:, , /menus/v1/menus:列出所有註冊過的...。
WP API Menus 》此外掛擴充了 WordPress JSON REST API,並提供 WordPress 註冊選單的新路徑。, 現在提供的新路徑如下:, , /menus 所有已註冊選單的清單。, /menus/
JSON Feed (jsonfeed.org) 》透過在任何網址後面加上 /feed/json,可以在您的 WordPress 網站中新增一個 JSON Feed。, JSON Feed 格式是一個務實的聚合格式,就像是 RSS 和 Atom,但有一...。
Import XML and RSS Feeds 》從任何 XML 或 RSS 檔案或網址匯入內容。, 您可以將內容匯入 WordPress 安裝中的任何文章類型中。您也可以匯入分類。, 我們的外掛尤其適用於從 Wix 網站匯入...。
GoodBarber 》GoodBarber 外掛是由 dphiffer 所製作的 JSON API 分支。, GoodBarber 外掛能夠建立 WordPress 與 GoodBarber 帳號之間的溝通介面,, 透過這個介面可以擷取 W...。
Schema Default Image 》喜歡Schema預設圖片外掛程式嗎?請考慮留下五顆星評論。, Schema預設圖片是Schema外掛程式的擴充,它增加了一個設定預設圖片的功能,如果文章沒有特色圖片,...。
REST XML-RPC Data Checker 》JSON REST API 和 XML-RPC API 是與 WordPress 遠程交互的強大方式。, 如果您沒有需要使用 JSON REST API 或 XML-RPC API 與外部應用程序通信的需求,您應禁...。