內容簡介
目前版本的 O3 CLI 服務提供兩個 WordPress REST API 端點,以讓開發人員和 QA 工程師能夠查詢 WordPress 文章的 URL 路徑,而這些端點可以進行以下篩選:
文章類型、分類類型和選單。
使用方式
使用 /wp-json/o3-cli-api/url-sources API 端點來取得 URL 路徑的列表,
使用 /wp-json/o3-cli-api/urls API 端點來取得系統中文章的 URL 路徑列表,使用
你的篩選條件作為 URL 查詢參數篩選。
篩選條件如下:
– post_types
– 包含用逗號分隔的文章類型機器名稱的列表。
– categories
– 包含用逗號分隔的分類別名的列表。
– menus
– 包含用逗號分隔的選單別名的列表。
– limit
– 包含一個整數限制,用於控制每個機器名稱中返回的 URL 路徑的最大數量。
以下是一個範例請求:
GET http://example.com/wp-json/o3-cli-api/urls?post_types=post,product&categories=food,travel&menus=main-navigation,footer-menu&limit=50
上述範例請求將會返回機器名稱為「post」和「product」的文章 URL 路徑,
它們的分類別名為「food」和「travel」,選單別名為「main-navigation」和「footer-menu」。
與所有 WordPress REST API 端點一樣,上述請求返回 JSON 陣列。
O3 CLI 會自動產生像上述的請求,並使開發人員和 QA 工程師能夠動態生成視覺回歸測試,
以及其他相關需求。請到 https://www.npmjs.com/package/o3-cli 查看完整文件。
外掛標籤
開發者團隊
原文外掛簡介
In its current version, O3 CLI Services exposes two WordPress REST API endpoints
to empower developers and QA engineers to query URL paths of WordPress posts by
post types, category types, and menus.
Usage
Use the /wp-json/o3-cli-api/url-sources API endpoint to get a list of sources of
URL paths, and use the /wp-json/o3-cli-api/urls API to get a list of URL paths
of posts in the system, using your sources as URL query parameter filters.
Source filters for /wp-json/o3-cli-api/urls:
– post_types
– Include a comma-separated list of post type machine names.
– categories
– Include a comma-separated list of category slugs.
– menus
– Include a comma-separated list of menu slugs.
– limit
– Include an integer limit to control the maximum number of URL paths to
return for each machine name in any source.
An example request:
GET http://example.com/wp-json/o3-cli-api/urls?post_types=post,product&categories=food,travel&menus=main-navigation,footer-menu&limit=50
The above example requests the URL paths of posts of post types with the machine
names of ‘post’ and ‘product’, having categories with ‘food’ and ‘travel’ slugs,
as well as items in menus with ‘main-navigation’ and ‘footer-menu’ slugs. As
with any WordPress REST API endpoints, the above request returns a JSON array.
The O3 CLI automatically generates requests like the above, and it empowers
developers and QA engineers to dynamically generate visual regression tests,
among other needs. See the documentation at
https://www.npmjs.com/package/o3-cli.
