前言介紹
- 這款 WordPress 外掛「JS Widgets」是 2016-08-24 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2017-11-12,距離現在已有 2730 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.7.0 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.3 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
xwp | sirbrillig | westonruter |
外掛標籤
widgets | rest-api | customizer |
內容簡介
重要提示:此項目是在 Gutenberg 功能外掛之前開始的。因此,現在應將 JS Widgets 外掛視為原型,它可能影響 widget blocks 在 Gutenberg 中的實現方式。此外,此外掛將不再進行主動開發。
也可稱為 Widget Customizer 2.0,Widgets 3.0 或 Widgets Next Generation。
警告:此外掛提供的 API 仍在變動中。如果創建延伸 WP_JS_Widget 類的新小工具,請查看變更日誌,並確保與延伸小工具兼容,再部署。
此外掛實現了以下功能:
WP-CORE#33507:允許小工具控制以 JS 驅動。
WP-CORE#35574:將 REST API JSON schema 資訊添加到 WP_Widget。
WP-API#19:在 WP REST API 中添加 widget 儲存和檢索端點。
功能:
與 Shortcake(Shortcode UI)結合,使所有 JS widgets 可作為編輯器中的文章元素使用。
在 PHP 中,自定義器中的小工具實例設定已導出為常規 JSON,而沒有任何 PHP 序列化的 base64 編碼的 encoded_serialized_instance。
在自定義器中預覽小工具變更更快,因為可以消除 update-widget Ajax 請求,因為 JS 控件可以直接操作小工具實例資料。
小工具的控制表單使用 JS 內容模板而不是 PHP 來渲染每個控制的標記,降低自定義器負載的重量,特別是在使用大量小工具時。
將擴展 WP_JS_Widget 的小工具在自定義器和小工具管理頁面上都可以進行編輯,使用相同的表格 JS 介面。此表單還可嵌入其他內容,例如在前端以及 Shortcake(Shortcode UI)表單上。請參閱#11。
小工具使用 REST API 中的 JSON Schema 定義包含實例屬性驗證和清潔的實例,除了還提供在對整個實例數組進行驗證和清潔的方法以外。
小工具實例可以因其 validate 或 sanitize 方法返回 WP_Error 而被阻止保存。例如,如果所提供的 RSS 小工具的 RSS 首頁 URL 無效,則會顯示錯誤訊息且該小工具將阻止保存,直到 URL 正確。
小工具在 js-widgets/v1 命名空間下公開,例如通過 /js-widgets/v1/widgets/recent-posts 列出所有最新文章小工具,或通過 /js-widgets/v1/widgets/text/6 獲取 ID(數字)為 6 的 Text 小工具。
自定義器對小工具實例的設定(widget_{id_base} [{number}])通過 JavaScript 直接變異,而不需要進行 update-widget 管理 Ajax 往返。這大大加速了預覽。
小工具控制表單可擴展以使用任何用於管理 UI 的 JS 框架,允許使用 Backbone、React 或任何其他前端技術。
兼容存儲在選項而不是自定義文章類型中的小工具,通過 Customize Widgets Plus 外掛中的 Widget Posts 模組。
兼容 WooCommerce 小工具、BBPress 小工具等常見 WordPress 外掛。
原文外掛簡介
Important note: This project was first started before the Gutenberg feature plugin was started. As such, the JS Widgets plugin should now be considered a prototype which may inform the way that widget blocks get implemented in Gutenberg. This plugin will no longer be actively developed.
Also could be known as Widget Customizer 2.0, Widgets 3.0, or Widgets Next Generation.
Warning: The APIs provided by this plugin are still in flux. If creating new widgets that extend the WP_JS_Widget class, please look at the changelog and ensure compatibility with your extended widgets before deploying.
This plugin implements:
WP-CORE#33507: Allow widget controls to be JS-driven.
WP-CORE#35574: Add REST API JSON schema information to WP_Widget.
WP-API#19: Add widget endpoints to the WP REST API.
Features:
Integrates with Shortcake (Shortcode UI) to allow all JS widgets to be made available as Post Elements in the editor.
Widget instance settings in the Customizer are exported from PHP as regular JSON without any PHP-serialized base64-encoded encoded_serialized_instance anywhere to be seen.
Previewing widget changes in the customizer is faster since the update-widget Ajax request can be eliminated since the JS control can directly manipulate the widget instance data.
Widgets control forms use JS content templates instead of PHP to render the markup for each control, reducing the weight of the customizer load, especially when there are a lot of widgets in use.
Widgets that extend WP_JS_Widget will editable from both the customizer and the widgets admin page using the same Form JS interface. This Form is also able to be embedded in other contexts, like on the frontend and as a Shortcake (Shortcode UI) form. See #11.
Widgets employ the JSON Schema from the REST API to define an instance with validation and sanitization of the instance properties, beyond also providing validate and sanitize methods that work on the instance array as a whole.
A widget instance can be blocked from being saved by returning a WP_Error from its validate or sanitize method. For example, the RSS widget will show an error message if the feed URL provided is invalid and the widget will block from saving until the URL is corrected.
Widgets are exposed under the js-widgets/v1 namespace, for example to list all Recent Posts widgets via the /js-widgets/v1/widgets/recent-posts or to get the Text widget with the “ID” (number) of 6, /js-widgets/v1/widgets/text/6.
Customizer settings for widget instances (widget_{id_base}[{number}]) are directly mutated via JavaScript instead of needing to do an update-widget Admin Ajax roundtrip; this greatly speeds up previewing.
Widget control forms can be extended to employ any JS framework for managing the UI, allowing Backbone, React, or any other frontend technology to be used.
Compatible with widgets stored in a custom post type instead of options, via the Widget Posts module in the Customize Widgets Plus plugin.
Compatible with Customize Snapshots, allowing changes made in the Customizer to be applied to requests for widgets via the REST API.
Includes adaptations of all core widgets using the new WP_JS_Widget API.
The adapted core widgets include additional raw data in their REST API item responses so that JS can render them client-side.
The Notifications API is utilized to display warnings when a user attempts to provide markup in a core widget title or illegal HTML in a Text widget’s content.
The Pages widget in Core is enhanced to make use of Customize Object Selector if available to display a Select2 UI for selecting pages to exclude instead of providing page IDs.
An bonus bundled plugin provides a “Post Collection” widget which, if the Customize Object Selector plugin is installed, will provide a UI for curating an arbitrary list of posts to display.
This plugin doesn’t yet implement any widgets that use JS templating for frontend rendering of the widgets. For that, please see the Next Recent Posts Widget plugin.
Limitations/Caveats:
Only widgets that extend WP_JS_Widget will be exposed via the REST API. The plugin includes a WP_JS_Widget adapter class which demonstrates how to adapt existing WP_Widget classes for the new widget functionality.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「JS Widgets」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1.1 | 0.2.0 | 0.3.0 | 0.4.0 | 0.4.1 | 0.4.2 | 0.4.3 | trunk |
延伸相關外掛(你可能也想知道)
WooCommerce Legacy REST API 》總結:, - 在WooCommerce 9.0版本起,Legacy REST API將不再是WooCommerce的一部分。, - 這款外掛程式在WooCommerce 9.0及以後版本中還原了已移除的Legacy RE...。
Disable REST API 》這是最全面的 WordPress REST API 存取控制外掛!, 輕鬆安裝,安裝後不需要額外設定即可使用。只需上傳並啟用,整個 REST API 將無法被一般訪客存取。, 但如...。
Make Connector 》Make 是一個視覺化平台,讓你可以在幾分鐘內設計、建立和自動化任何事情 - 從簡單的任務到複雜的工作流程。使用 Make,你可以在 WordPress 和數千個應用程式...。
WPGraphQL 》WPGraphQL 是一個免費、開源的 WordPress 外掛,為任何 WordPress 網站提供可延伸的 GraphQL schema 和 API。, 以下是一些有助於你開始使用 WPGraphQL 的連結...。
WordPress REST API Authentication 》WordPress REST API 預設是鬆散的端點,駭客可以通過這些端點遠程控制您的網站。 您不希望駭客可以透過 WordPress 登錄和 WordPress 註冊或任何其他端點來獲...。
Disable WP REST API 》這個外掛只有一個功能:禁用沒有登入 WordPress 的訪客使用 WP REST API。不需要任何設定。, 這個外掛只有 22 行短小的程式碼(少於 2KB)。因此它非常輕量、...。
WordPress REST API (Version 2) 》WordPress 正轉變成一個完整的應用程式框架,因此需要新的 API。這個專案的目的是創建一個易於使用、易於理解且經過良好測試的框架,用於創建這些 API,以及...。
Application Passwords 》⚠️ 重要提示:此外掛已合併至 WordPress 5.6 核心,不需要單獨安裝。 查看整合指南→, 使用應用程式密碼進行身份驗證,而不必直接提供用戶的密碼。相反,為每...。
WP REST API – OAuth 1.0a Server 》使用這個外掛,您可以將應用程式連接至您的 WordPress 網站,而不必透露您的密碼。, 此外掛使用 OAuth 1.0a 協議,允許委派授權,即允許應用程式使用一組次要...。
REST API Log 》這是一款針對 WordPress REST API v2 的外掛程式,可記錄 REST API 的請求和回應紀錄。, 功能包括:, , WordPress 管理頁面,用於查看和搜尋日誌條目, API 端...。
SMNTCS Disable REST API User Endpoints 》隨著 WordPress 4.7 的推出,REST API 已經成為核心的一部分。目前,每個人都可以讀取 REST API。因此,潛在的入侵者可以通過 /wp-json/wp/v2/users 檢索所有...。
REST API Toolbox 》此外掛允許調整多個 REST API 設定, , 停用 REST API, 移除 WordPress 核心端點, 需要核心端點驗證, 強制使用 SSL, WP-CLI 命令: wp rest-api-toolbox, , 在 ...。
MultiManager WP – Manage All Your WordPress Sites Easily 》總結:, 這個外掛可以幫助你自動連接你的WordPress網站到ICDSoft WordPress MultiManager工具包,在ICDSoft Account Panel中提供。WordPress MultiManager工...。
WCFM – Multivendor Marketplace REST API for WooCommerce 》WooCommerce 多供應商市場(WCFM Marketplace)- REST API 會提供您的市場網站最強大的多供應商 REST API,您將能夠使用 HTTP Rest API 請求從其他移動應用程...。
WP REST API Meta Endpoints 》, 這是一個針對文章meta資料的 REST API WordPress外掛。。