Abilities リファレンス
Abilities は、Gratis AI Agent があなたの WordPress インストール上で呼び出せる最小単位の操作です。各 ability は登録済みの PHP クラスで、JSON スキーマを公開します。agent は実行時にこのスキーマを読み取り、必要なパラメーターと ability の戻り値を把握します。
このページでは、Gratis AI Agent v1.9.0 に同梱されるすべての abilities を説明します。
カスタム投稿タイプ
これらの abilities は、agent 経由で登録されたカスタム投稿タイプ(CPT)を管理します。登録内容は WordPress options テーブルに保存されるため、plugin の無効化と再有効化の後も保持されます。
register_post_type
新しいカスタム投稿タイプを登録します。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | 投稿タイプキー(最大 20 文字、大文字不可、空白不可) |
singular_label | string | Yes | 人が読める単数名。例: Portfolio Item |
plural_label | string | Yes | 人が読める複数名。例: Portfolio Items |
public | boolean | No | 投稿タイプを公開アクセス可能にするかどうか。既定値は true |
supports | array | No | サポートする機能: title、editor、thumbnail、excerpt、comments、revisions、custom-fields。既定値は ["title","editor"] |
has_archive | boolean | No | 投稿タイプのアーカイブページを有効にするかどうか。既定値は false |
menu_icon | string | No | 管理メニューアイコン用の Dashicons クラスまたは URL。既定値は "dashicons-admin-post" |
rewrite_slug | string | No | 投稿タイプ用の URL slug。既定では slug |
例
{
"slug": "portfolio",
"singular_label": "Portfolio Item",
"plural_label": "Portfolio Items",
"public": true,
"supports": ["title", "editor", "thumbnail"],
"has_archive": true,
"menu_icon": "dashicons-portfolio"
}
戻り値 { "success": true, "slug": "portfolio" }
list_post_types
agent によって登録されたすべてのカスタム投稿タイプを返します。
パラメーター — なし
戻り値
{
"post_types": [
{
"slug": "portfolio",
"singular_label": "Portfolio Item",
"plural_label": "Portfolio Items",
"public": true
}
]
}
delete_post_type
agent によって以前登録されたカスタム投稿タイプの登録を解除します。そのタイプの既存投稿はデータベースに残りますが、投稿タイプ経由ではアクセスできなくなります。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | 削除する投稿タイプキー |
戻り値 { "success": true, "slug": "portfolio" }
カスタムタクソノミー
これらの abilities はカスタムタクソノミーを管理します。CPT と同様に、タクソノミーの登録内容は保存されます。
register_taxonomy
新しいカスタムタクソノミーを登録します。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | タクソノミーキー(最大 32 文字) |
singular_label | string | Yes | 人が読める単数名。例: Project Category |
plural_label | string | Yes | 人が読める複数名。例: Project Categories |
post_types | array | Yes | このタクソノミーを関連付ける投稿タイプの slugs |
hierarchical | boolean | No | カテゴリー形式の場合は true、タグ形式の場合は false。既定値は true |
public | boolean | No | term を公開アクセス可能にするかどうか。既定値は true |
rewrite_slug | string | No | タクソノミー用の URL slug。既定では slug |
例
{
"slug": "project-category",
"singular_label": "Project Category",
"plural_label": "Project Categories",
"post_types": ["portfolio"],
"hierarchical": true
}
戻り値 { "success": true, "slug": "project-category" }
list_taxonomies
agent によって登録されたすべてのカスタムタクソノミー を返します。
パラメーター — なし
戻り値
{
"taxonomies": [
{
"slug": "project-category",
"singular_label": "Project Category",
"post_types": ["portfolio"],
"hierarchical": true
}
]
}
delete_taxonomy
agent によって以前登録されたカスタムタクソノミーの登録を解除します。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | 削除するタクソノミーキー |
戻り値 { "success": true, "slug": "project-category" }
デザインシステム
デザインシステムの abilities は、カスタム CSS からブロックパターン、site ロゴまで、WordPress site の見た目を変更します。
inject_custom_css
wp_add_inline_style 経由で site の <head> に CSS を追加します。CSS は gratis_ai_agent_custom_css option に保存され、ability がリセットされるときにきれいに dequeued されます。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
css | string | Yes | 注入する有効な CSS |
label | string | No | この CSS ブロック用の人が読めるラベル。デバッグログで使用されます。既定値は "agent-injected" |
replace | boolean | No | true の場合、以前に注入されたすべての CSS を置き換えます。既定値は false(追加) |
例
{
"css": ":root { --primary: #1a1a2e; --accent: #e94560; } body { font-family: 'Inter', sans-serif; }",
"label": "brand-colours",
"replace": false
}
戻り値 { "success": true, "bytes": 96 }
add_block_pattern
WordPress パターンライブラリに再利用可能なブロックパターンを登録します。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | パターン識別子。例: gratis/hero-dark |
title | string | Yes | エディターに表示される人が読めるパターン名 |
content | string | Yes | パターン用のシリアライズ済みブロックマークアップ(HTML) |
categories | array | No | パターンカテゴリー slugs。例: ["featured", "hero"] |
description | string | No | パターン選択画面に表示される短い説明 |
keywords | array | No | 検索キーワード |
戻り値 { "success": true, "slug": "gratis/hero-dark" }
list_block_patterns
agent によって登録されたすべてのブロックパターンを一覧表示します。
パラメーター — なし
戻り値
{
"patterns": [
{
"slug": "gratis/hero-dark",
"title": "Dark Hero",
"categories": ["hero"]
}
]
}
set_site_logo
WordPress site のロゴを指定された添付ファイル ID またはリモート画像 URL に設定します。URL が指定された場合、画像はダウンロードされ、メディアライブラリに取り込まれます。
パラメーター
| Parameter | Type | Required | Description |
|---|---|---|---|
attachment_id | integer | No | 既存のメディアライブラリ添付ファイルの ID |
url | string | No | 取り込んでロゴとして設定するリモート画像 URL |
attachment_id または url のいずれかを指定する必要があります。
戻り値 { "success": true, "attachment_id": 42 }