內容簡介
這個外掛的基本使用情境是對內容區塊進行延遲載入或是跨部落格操作。
它包含一個簡單的延遲載入小工具範例,但主要是針對開發人員,希望在此功能上進行擴充。
功能:
網址格式的表現形式為 http://<blogname>/<server_entry_key>/<request_string>/<server_format_key>/<format>,以允許伺服器端儲存未設置大量重寫規則的要求快取。請求字串包含了所有要求的參數。
不同的響應格式。在 response.php 中捆綁了 XML 和 JSON,可以擴展為所需的格式。
整個類別中都使用自訂例外處理器的異常,以允許在要求的回應格式中提供錯誤回饋。
請查閱從 remote-api.php 開始的內部文件說明,以了解使用情境,也可以參考範例。
延遲載入小工具範例
延遲載入小工具範例是此程式的基本使用情境。它的 UI 還不是很完善,但應該能夠讓你對這個遠端 API 可以做什麼有個印象。
當你到 /wp-admin/widgets.php 中訪問小工具管理頁面時,你會注意到一個名為 "Remote_API_Lazy_Widget" 的小工具。把它拖到你希望有一些以異步方式載入的小工具出現的其中一個側邊欄中,並給它一個標題。然後重新載入 widgets.php 頁面。
一個新的側邊欄應該會出現,你可以在其中放置其他小工具。你下放到這個側邊欄的小工具將會通過 AJAX 請求以立即載入的方式出現在佔位小工具的位置上。
外掛標籤
開發者團隊
原文外掛簡介
A basic use case for this plugin would be lazy loading content segments or performing cross-blog actions.
It includes a simple example for lazy loading widgets, but is mainly aimed for developers who like to built on top of this functionality.
Features:
Url Format in form of http://
Variable response formats. Comes with xml and json bundled in response.php but can be extended to your needs
Exceptions with custom exception handler are used throughout the classes to allow error feedback in the requested response format.
Please have a look at the inline documentation starting from remote-api.php. To get a sense of the usage have a look at the examples
Lazy Loading Widget Example
The Lazy Loading Widget example is a basic use case for this script. It’s UI is still not very tuned, but should give an impression on what can be done with this remote-api.
When you visit your widget administration at /wp-admin/widgets.php you’ll notice a widget called “Remote_API_Lazy_Widget”. Drag it to one of your sidebars where you would like to have some asynchronously loaded widget appear and give it a Title. Then reload the widgets.php page.
A new sidebar should appear in which you can drop other widgets. The widgets you’ll drop in this sidebar will be loaded asynchronously via a ajax request in place of the placeholder widget.
