前言介紹
- 這款 WordPress 外掛「Arha Routes」是 2019-10-04 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2020-05-15,距離現在已有 1815 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 5.0 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.1 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
attlii |
外掛標籤
rest | endpoint | language | bilingual | multilingual |
內容簡介
WordPress 外掛描述:
這是一個 WordPress 外掛,它可以幫助開發者透過 REST 路由提供內容並提供自訂選項。
可用路由
/wp-json/arha/v1/post
/wp-json/arha/v1/page
/wp-json/arha/v1/options
/wp-json/arha/v1/archive
查詢範例
/wp-json/arha/v1/post?post_type=POST_TYPE&slug=SLUG
/wp-json/arha/v1/page?path=PATH
/wp-json/arha/v1/options
/wp-json/arha/v1/archive?post_type=POST_TYPE&posts_per_page=POSTS_PER_PAGE&paged=PAGED&orderby=ORDERBY&order=ORDER
存檔路由中的 tax_query 和 meta_query
支援 tax_query 和 meta_query,用法類似 new WP_Query() 中的查詢條件。
兩者的值皆需要以字串化的 JSON 格式傳遞。
存檔路由中的多個文章型別
為了在存檔路由中傳遞多個文章型別,可使用可讓 PHP 將 GET 參數讀取為陣列的語法。參考:https://stackoverflow.com/a/9547490
過濾器
若要在 post 和 archive 路由中排除特定的文章型別,可以使用以下過濾器:
`
add_filter(‘arha_routes/archive_excluded_post_types’, ‘exclude_post_types’);
add_filter(‘arha_routes/post_excluded_post_types’, ‘exclude_post_types’);
function exclude_post_types($excluded_post_types) {
$excluded_post_types = [‘post’];
return $excluded_post_types;
}
`
若要在傳送給客戶端之前格式化 post 路由的文章,可以使用 arha_routes/format_post 過濾器:
`
add_filter(‘arha_routes/format_post’, ‘format_post’);
function format_post($post) {
return $post;
}
`
若要在傳送給客戶端之前格式化 page 路由的文章,可以使用 arha_routes/format_page 過濾器:
`
add_filter(‘arha_routes/format_page’, ‘format_page’);
function format_page($page) {
return $page;
}
`
若要在傳送給客戶端之前格式化 archive 路由中的文章,可以使用 arha_routes/format_archive_post 過濾器:
add_filter('arha_routes/format_archive_post', 'format_archive_post');
function format_archive_post($post) {
return $post;
}
options 路由預設會回傳空白結果。若要加入內容,可以使用 arha_routes/format_options 過濾器:
`
add_filter(‘arha_routes/format_options’, ‘format_options’);
function format_options($options) {
return $options;
}
`
預設情況下,Arha Routes 在發送 post、page 和 archive 路由的資料時只會回傳已公開的內容。若要更改這個設定,可以使用以下過濾器:
`
// for archive route
add_filter(‘arha_routes/allowed_post_statuses_archive’, ‘allowed_post_statuses’);
// for post route
add_filter(‘arha_routes/allowed_post_statuses_post’, ‘allowed
原文外掛簡介
WordPress plugin that helps to serve content through REST routes and gives
customizability to developers through filters.
Available Routes
/wp-json/arha/v1/post
/wp-json/arha/v1/page
/wp-json/arha/v1/options
/wp-json/arha/v1/archive
Example queries
/wp-json/arha/v1/post?post_type=POST_TYPE&slug=SLUG
/wp-json/arha/v1/page?path=PATH
/wp-json/arha/v1/options
/wp-json/arha/v1/archive?post_type=POST_TYPE&posts_per_page=POSTS_PER_PAGE&paged=PAGED&orderby=ORDERBY&order=ORDER
tax_query and meta_query in archive-route
tax_query and meta_query are supported and they work how the query is built for it in new WP_Query()
both needs their values to bes passed in as stringified json
Multiple post_types in archive-route
To pass multiple post_types in archive-route, use syntax that lets PHP read GET-param as an array. https://stackoverflow.com/a/9547490
Filters
To exclude querying specific post types from post– and archive-routes, you
can use following filters:
`
add_filter(‘arha_routes/archive_excluded_post_types’, ‘exclude_post_types’);
add_filter(‘arha_routes/post_excluded_post_types’, ‘exclude_post_types’);
function exclude_post_types($excluded_post_types) {
$excluded_post_types = [‘post’];
return $excluded_post_types;
}
`
To format post-route’s post before it’s served to client, use arha_routes/format_post-filter
`
add_filter(‘arha_routes/format_post’, ‘format_post’);
function format_post($post) {
return $post;
}
`
To format page-route’s post before it’s served to client, use arha_routes/format_page-filter
`
add_filter(‘arha_routes/format_page’, ‘format_page’);
function format_page($page) {
return $page;
}
`
To format archive-route’s posts before they are served to client, use arha_routes/format_archive_post-filter
add_filter('arha_routes/format_archive_post', 'format_archive_post');
function format_archive_post($post) {
return $post;
}
options-route returns empty result by default. To add content to it, use arha_routes/format_options-filter
`
add_filter(‘arha_routes/format_options’, ‘format_options’);
function format_options($options) {
return $options;
}
`
By default Arha Routes returns only published content with post-, page- and archive-route, this can be modified by adding following filters.
`
// for archive route
add_filter(‘arha_routes/allowed_post_statuses_archive’, ‘allowed_post_statuses’);
// for post route
add_filter(‘arha_routes/allowed_post_statuses_post’, ‘allowed_post_statuses’);
// for page route
add_filter(‘arha_routes/allowed_post_statuses_page’, ‘allowed_post_statuses’);
function allowed_post_statuses($post_statuses) {
// … change post_statuses array
return $post_statuses;
}
`
After adding setting up these filters, request can include “post_status” parameter and it will be compared to $post_statuses array.
SearchWP
Arha Routes supports SearchWP-plugin, which lets WP users to make keyword search engine for their content.
Activating SearchWP-plugin adds optional keyword-search functionality to archive-route. This is done by adding s=KEYWORD to the route
– Example: /wp-json/arha/v1/archive?post_type=products&posts_per_page=10&paged=1&orderby=date&order=ASC&s=monitor
Polylang
Arha Routes supports Polylang-plugin, which allows users to create content in multiple languages.
Activating Polylang changes how endpoints work:
All routes require additional lang-param
Example: /wp-json/arha/v1/archive?post_type=products&posts_per_page=10&paged=1&orderby=date&order=ASC&lang=en
page-route doesn’t support language prefix in path
Example: Permalink /zh/info, use like this /wp-json/arha/v1/page?path=/info&lang=zh
Example: Permalink /en/info/test, use like this /wp-json/arha/v1/page?path=/info/test&lang=zh
options-route passes lang-param forward to arha_routes/format_options-filter
add_filter('arha_routes/format_options', 'format_options', 10, 2);
function format_options($options, $lang) {
return $options;
}
Polylang + SearchWP
In order to make these two plugins work together, you need to add extra plugin to WP installation.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Arha Routes」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Loco Translate 》Loco Translate 提供在瀏覽器中編輯 WordPress 翻譯文件和與自動翻譯服務集成的功能。, 它還為開發人員提供 Gettext/本地化工具,例如提取字符串和生成模板。...。
Polylang 》ts, Polylang is developed by the Polylang team with the help of numerous contributors., If you want to contribute or report an issue, please visit ...。
Translate WordPress with GTranslate 》Translate WordPress with GTranslate外掛使用 Google Translate 自動翻譯服務,讓您的 WordPress 網站多語言化,並發揮 Google 的力量。有103種語言可供選擇...。
Translate Multilingual sites – TranslatePress 》透過可視化的翻譯介面,直接從前端翻譯您的WordPress網站並製作多語言網站,體驗更好的翻譯方式。, TranslatePress是一個任何人都可以使用的WordPress翻譯外...。
WooCommerce Multilingual & Multicurrency with WPML 》這個外掛包含您需要開始跨國銷售所需的一切。輕鬆地設定和管理多種貨幣下的產品,不論您的商店大小和負責團隊的規模。或者,您可以升級購買 WPML,將您的整個...。
Connect Polylang for Elementor 》將 Polylang 多語言外掛連結至 Elementor 頁面建構器:翻譯您的 Elementor 模板並以正確語言顯示,並提供原生可自訂的 Language Switcher Elementor widget,...。
Automatic Translate Addon For Loco Translate 》🐦 Loco的自動機器翻譯外掛, Loco Translate的自動翻譯外掛是網站擁有者和開發人員迅速翻譯其WordPress外掛和主題的強大工具。該外掛與Loco Translate外掛集...。
Translate WordPress and go Multilingual – Weglot 》Weglot Translate是領先的WordPress翻譯外掛,全球有超過60,000個使用者信任。您可以在幾分鐘內將WordPress網站翻譯成110多種語言,無需編碼即可實現多語言。...。
WPGlobus – Multilingual WordPress 》WPGlobus 是一系列 WordPress 外掛,協助您翻譯和維護雙語/多語言 WordPress 博客和網站。, 快速入門視頻, , 請同時閱讀快速入門指南。, 重要注意事項:請在...。
WP Multilang – Translation and Multilingual Plugin 》WP Multilang 是 WordPress 的多語言外掛。, 翻譯文章類型、分類法、元字段、選項、多媒體檔案中的文本字段、選單、標題和小工具中的文本字段。, WP Multilan...。
Hyyan WooCommerce Polylang Integration 》由於最近我沒有在使用 WordPress,也沒有使用 WooPoly 了一段時間,因此我正在尋找維護者接手這個項目。, 如果您有興趣,請回覆這個問題或透過電子郵件與我聯...。
WPBakery Visual Composer & qTranslate-X 》這個外掛可以讓 qTranslate-X 多語言工具運作於 WPBakery Visual Composer 外掛程式中。, 需要 qTranslate-X 版本 3.3 或者 alpha 預發行版 以上版本。, 這個...。
Prisna GWT – Google Website Translator 》這個外掛讓 Google 自動翻譯服務的強大功能可翻譯您的網站成 100 多種語言,是 WordPress 的一個簡單而完整的多語言解決方案。, 功能:, , 易於安裝,包括內聯...。
Bogo 》https://ideasilo.wordpress.com/bogo/, Bogo 是一個簡單易用的 WordPress 多語言插件。, WordPress 自身就具備本地化功能,可以讓您在除英語外的另一種語言...。
AI Translation for TranslatePress 》TranslatePress 自動機器翻譯外掛, , 與 TranslatePress 外掛一同安裝此插件,輕鬆節省你的時間。, , , 免費版本支援 Yandex 翻譯小部件。, 專業版 💎 支援 G...。