Перейти до основного вмісту

Abilities Reference

Abilities are the atomic actions that Gratis AI Agent can invoke on your WordPress installation. Each ability is a registered PHP class that exposes a JSON schema — the agent reads this schema at runtime to understand what parameters are required and what the ability returns.

This page documents all abilities shipping with Gratis AI Agent v1.9.0.


Custom Post Types

These abilities manage custom post types (CPTs) registered through the agent. Registrations are persisted to the WordPress options table so they survive plugin deactivation and reactivation.

register_post_type

Registers a new custom post type.

Parameters

ParameterTypeRequiredDescription
slugstringYesThe post type key (max 20 characters, no uppercase, no spaces)
singular_labelstringYesHuman-readable singular name, e.g. Portfolio Item
plural_labelstringYesHuman-readable plural name, e.g. Portfolio Items
publicbooleanNoWhether the post type is publicly accessible. Default true
supportsarrayNoFeatures to support: title, editor, thumbnail, excerpt, comments, revisions, custom-fields. Default ["title","editor"]
has_archivebooleanNoWhether a post type archive page is enabled. Default false
menu_iconstringNoDashicons class or URL for the admin menu icon. Default "dashicons-admin-post"
rewrite_slugstringNoURL slug for the post type. Defaults to slug

Example

{
"slug": "portfolio",
"singular_label": "Portfolio Item",
"plural_label": "Portfolio Items",
"public": true,
"supports": ["title", "editor", "thumbnail"],
"has_archive": true,
"menu_icon": "dashicons-portfolio"
}

Returns { "success": true, "slug": "portfolio" }


list_post_types

Returns all custom post types registered by the agent.

Parameters — none

Returns

{
"post_types": [
{
"slug": "portfolio",
"singular_label": "Portfolio Item",
"plural_label": "Portfolio Items",
"public": true
}
]
}

delete_post_type

Unregisters a custom post type previously registered by the agent. Existing posts of that type remain in the database but are no longer accessible via the post type.

Parameters

ParameterTypeRequiredDescription
slugstringYesThe post type key to remove

Returns { "success": true, "slug": "portfolio" }


Custom Taxonomies

These abilities manage custom taxonomies. Like CPTs, taxonomy registrations are persisted.

register_taxonomy

Registers a new custom taxonomy.

Parameters

ParameterTypeRequiredDescription
slugstringYesThe taxonomy key (max 32 characters)
singular_labelstringYesHuman-readable singular name, e.g. Project Category
plural_labelstringYesHuman-readable plural name, e.g. Project Categories
post_typesarrayYesPost type slugs this taxonomy should be attached to
hierarchicalbooleanNotrue for category-style, false for tag-style. Default true
publicbooleanNoWhether terms are publicly accessible. Default true
rewrite_slugstringNoURL slug for the taxonomy. Defaults to slug

Example

{
"slug": "project-category",
"singular_label": "Project Category",
"plural_label": "Project Categories",
"post_types": ["portfolio"],
"hierarchical": true
}

Returns { "success": true, "slug": "project-category" }


list_taxonomies

Returns all custom taxonomies registered by the agent.

Parameters — none

Returns

{
"taxonomies": [
{
"slug": "project-category",
"singular_label": "Project Category",
"post_types": ["portfolio"],
"hierarchical": true
}
]
}

delete_taxonomy

Unregisters a custom taxonomy previously registered by the agent.

Parameters

ParameterTypeRequiredDescription
slugstringYesThe taxonomy key to remove

Returns { "success": true, "slug": "project-category" }


Design System

Design system abilities modify the visual presentation of the WordPress site — from custom CSS to block patterns and the site logo.

inject_custom_css

Appends CSS to the site's <head> via wp_add_inline_style. CSS is stored in the gratis_ai_agent_custom_css option and dequeued cleanly when the ability is reset.

Parameters

ParameterTypeRequiredDescription
cssstringYesValid CSS to inject
labelstringNoHuman-readable label for this CSS block, used in debug logs. Default "agent-injected"
replacebooleanNoIf true, replaces all previously injected CSS. Default false (appends)

Example

{
"css": ":root { --primary: #1a1a2e; --accent: #e94560; } body { font-family: 'Inter', sans-serif; }",
"label": "brand-colours",
"replace": false
}

Returns { "success": true, "bytes": 96 }


add_block_pattern

Registers a reusable block pattern in the WordPress pattern library.

Parameters

ParameterTypeRequiredDescription
slugstringYesPattern identifier, e.g. gratis/hero-dark
titlestringYesHuman-readable pattern name shown in the editor
contentstringYesSerialised block markup (HTML) for the pattern
categoriesarrayNoPattern category slugs, e.g. ["featured", "hero"]
descriptionstringNoShort description shown in the pattern picker
keywordsarrayNoSearch keywords

Returns { "success": true, "slug": "gratis/hero-dark" }


list_block_patterns

Lists all block patterns registered by the agent.

Parameters — none

Returns

{
"patterns": [
{
"slug": "gratis/hero-dark",
"title": "Dark Hero",
"categories": ["hero"]
}
]
}

Sets the WordPress site logo to a given attachment ID or a remote image URL. When a URL is provided, the image is downloaded and imported into the Media Library.

Parameters

ParameterTypeRequiredDescription
attachment_idintegerNoID of an existing Media Library attachment
urlstringNoRemote image URL to import and set as the logo

One of attachment_id or url must be provided.

Returns { "success": true, "attachment_id": 42 }


apply_theme_json_preset

Applies a named colour/typography preset to the active theme's theme.json (or global-styles). Presets are curated bundles maintained by the Gratis AI Agent team.

Parameters

ParameterTypeRequiredDescription
presetstringYesPreset name, e.g. minimal-dark, warm-editorial, corporate-blue
mergebooleanNoIf true, merge with existing values rather than replacing. Default false

Available presets

PresetDescription
minimal-darkNear-black background, white text, single accent colour
warm-editorialWarm off-white background, serif headings, earthy accent colours
corporate-blueNavy and white palette with professional typography
vibrant-startupBright gradients, rounded corners, modern sans-serif type
classic-blogNeutral greys, comfortable line-height, traditional layout spacing

Returns { "success": true, "preset": "minimal-dark" }


Global Styles

Global Styles abilities read and write theme.json values through the WordPress Global Styles API, affecting all blocks and templates sitewide.

get_global_styles

Returns the current global styles configuration.

Parameters

ParameterTypeRequiredDescription
pathstringNoJSON pointer to a specific value, e.g. /color/palette or /typography/fontSizes. Returns the entire object if omitted.

Returns the full global styles object or the value at path.


set_global_styles

Updates one or more values in the global styles configuration.

Parameters

ParameterTypeRequiredDescription
pathstringYesJSON pointer to the value to set, e.g. /color/palette
valueanyYesThe new value

Example — add a colour to the palette

{
"path": "/color/palette",
"value": [
{ "slug": "primary", "color": "#1a1a2e", "name": "Primary" },
{ "slug": "accent", "color": "#e94560", "name": "Accent" }
]
}

Returns { "success": true, "path": "/color/palette" }


reset_global_styles

Resets all agent-applied global styles changes, restoring the theme defaults.

Parameters — none

Returns { "success": true }


Navigation Menu abilities create and manage WordPress nav menus and their items.

create_menu

Creates a new WordPress navigation menu.

Parameters

ParameterTypeRequiredDescription
namestringYesMenu name, e.g. Primary Navigation
locationstringNoTheme location to assign this menu to, e.g. primary

Returns { "success": true, "menu_id": 7 }


update_menu

Renames a menu or reassigns it to a theme location.

Parameters

ParameterTypeRequiredDescription
menu_idintegerYesID of the menu to update
namestringNoNew menu name
locationstringNoTheme location to assign or reassign

Returns { "success": true, "menu_id": 7 }


add_menu_item

Adds an item to an existing navigation menu.

Parameters

ParameterTypeRequiredDescription
menu_idintegerYesID of the target menu
typestringYesItem type: custom, post_type, or taxonomy
titlestringNoLabel for the menu item (required for custom type)
urlstringNoURL for custom items
object_idintegerNoPost ID or term ID for post_type/taxonomy items
parent_idintegerNoMenu item ID to nest this item under
positionintegerNoZero-based position in the menu

Returns { "success": true, "item_id": 12 }


remove_menu_item

Removes an item from a navigation menu.

Parameters

ParameterTypeRequiredDescription
item_idintegerYesMenu item ID to remove

Returns { "success": true, "item_id": 12 }


list_menus

Lists all WordPress navigation menus, including their assigned theme locations.

Parameters — none

Returns

{
"menus": [
{
"menu_id": 7,
"name": "Primary Navigation",
"location": "primary",
"item_count": 5
}
]
}

Options Management

Options abilities read and write WordPress options via get_option / update_option. A built-in safety blocklist prevents accidental modification of critical settings.

get_option

Reads a WordPress option.

Parameters

ParameterTypeRequiredDescription
option_namestringYesThe option key, e.g. blogname

Returns { "option_name": "blogname", "value": "My Site" }

Returns an error if option_name is on the safety blocklist.


set_option

Writes a WordPress option.

Parameters

ParameterTypeRequiredDescription
option_namestringYesThe option key
valueanyYesThe new value (serialised automatically for arrays/objects)
autoloadstringNo"yes" or "no". Default preserves the existing autoload setting

Returns an error if option_name is on the safety blocklist.

Returns { "success": true, "option_name": "blogname" }


delete_option

Deletes a WordPress option.

Parameters

ParameterTypeRequiredDescription
option_namestringYesThe option key to delete

Returns an error if option_name is on the safety blocklist.

Returns { "success": true, "option_name": "my_custom_option" }


list_options

Lists WordPress options matching a pattern.

Parameters

ParameterTypeRequiredDescription
patternstringNoSQL LIKE pattern to filter option names, e.g. gratis_%. Returns all options if omitted (use with caution on large databases).
limitintegerNoMaximum number of results. Default 50, max 500

Returns

{
"options": [
{ "option_name": "gratis_ai_agent_version", "autoload": "yes" }
],
"total": 1
}

Content Management

Content Management abilities create and edit WordPress posts and pages. Post IDs are returned so subsequent steps in multi-ability plans can reference the created content.

create_post

Creates a new WordPress post, page, or custom post type entry.

Parameters

ParameterTypeRequiredDescription
titlestringYesPost title
contentstringNoPost body — accepts plain text, HTML, or serialised block markup
statusstringNodraft, publish, pending, private. Default draft
post_typestringNoPost type slug, e.g. post, page, or any registered CPT. Default post
excerptstringNoShort summary shown in archives and search results
categoriesarrayNoArray of category names or IDs to assign
tagsarrayNoArray of tag names or IDs to assign
authorintegerNoWordPress user ID to set as the post author. Defaults to the current user
datestringNoPublish date in ISO 8601 format, e.g. 2026-05-01T09:00:00
page_templatestringNoTemplate file to assign to this post or page, e.g. page-full-width.php. Only meaningful when post_type is page or a CPT that supports page templates.

Example

{
"title": "Welcome to Our New Site",
"content": "<!-- wp:paragraph --><p>Hello world!</p><!-- /wp:paragraph -->",
"status": "publish",
"post_type": "page",
"page_template": "page-full-width.php"
}

Returns { "success": true, "post_id": 42, "permalink": "https://example.com/welcome/" }


update_post

Updates an existing WordPress post or page.

Parameters

ParameterTypeRequiredDescription
post_idintegerYesID of the post to update
titlestringNoNew post title
contentstringNoNew post body
statusstringNoNew status: draft, publish, pending, private
excerptstringNoNew excerpt
categoriesarrayNoReplace the full category list with this array of names or IDs
tagsarrayNoReplace the full tag list with this array of names or IDs
page_templatestringNoNew template file to assign to this post or page, e.g. page-full-width.php. Pass an empty string to remove the template assignment and revert to the theme default.

Example — change template after creation

{
"post_id": 42,
"page_template": "page-full-width.php"
}

Returns { "success": true, "post_id": 42 }


batch_create_posts

Creates multiple posts in a single ability call, reducing round-trips during site builds or bulk content import. Posts are created in sequence; if one fails the others continue and the failure is reported in the results array.

Parameters

ParameterTypeRequiredDescription
postsarrayYesArray of post objects, each accepting the same parameters as create_post
stop_on_errorbooleanNoIf true, stop processing after the first failure. Default false

Example

{
"posts": [
{
"title": "About Us",
"post_type": "page",
"status": "publish",
"page_template": "page-full-width.php"
},
{
"title": "Services",
"post_type": "page",
"status": "publish"
},
{
"title": "Contact",
"post_type": "page",
"status": "publish"
}
]
}

Returns

{
"created": 3,
"failed": 0,
"results": [
{ "success": true, "post_id": 42, "title": "About Us" },
{ "success": true, "post_id": 43, "title": "Services" },
{ "success": true, "post_id": 44, "title": "Contact" }
]
}

Assigns a featured image (post thumbnail) to an existing post or page. Accepts an existing Media Library attachment ID or a remote image URL; when a URL is supplied, the image is downloaded and imported automatically.

Parameters

ParameterTypeRequiredDescription
post_idintegerYesID of the post or page to update
attachment_idintegerNoID of an existing Media Library attachment
urlstringNoRemote image URL to import and set as the featured image
alt_textstringNoAlt text to apply to the attachment if it is imported from a URL

One of attachment_id or url must be provided.

Returns { "success": true, "post_id": 42, "attachment_id": 17 }


create_contact_form

Creates a contact form using the active form plugin (Contact Form 7, WPForms, Fluent Forms, or Gravity Forms, depending on which is installed). Returns a shortcode that can be embedded in any post or page.

Parameters

ParameterTypeRequiredDescription
titlestringYesForm name shown in the form plugin admin
fieldsarrayYesOrdered list of form fields (see Field object below)
recipientstringNoEmail address to receive submissions. Defaults to the WordPress admin email
subjectstringNoEmail subject line. Supports [your-name] and [your-subject] placeholders when using Contact Form 7
confirmation_messagestringNoMessage displayed after a successful submission. Default: "Thank you for your message. We'll be in touch soon."

Field object

KeyTypeRequiredDescription
namestringYesInternal field name / machine key
labelstringYesHuman-readable label shown on the form
typestringYestext, email, tel, textarea, select, checkbox, radio, file, date
requiredbooleanNoWhether the field must be filled before submission. Default false
optionsarrayNoOptions for select, checkbox, and radio fields
placeholderstringNoPlaceholder text for text-type inputs

Example

{
"title": "Restaurant Booking Enquiry",
"fields": [
{ "name": "your-name", "label": "Name", "type": "text", "required": true },
{ "name": "your-email", "label": "Email", "type": "email", "required": true },
{ "name": "party-size", "label": "Party size", "type": "select", "options": ["1–2", "3–5", "6–10", "10+"] },
{ "name": "your-message", "label": "Special requests", "type": "textarea", "required": false }
],
"recipient": "[email protected]",
"subject": "New booking enquiry from [your-name]"
}

Returns

{
"success": true,
"form_id": 3,
"shortcode": "[contact-form-7 id=\"3\" title=\"Restaurant Booking Enquiry\"]"
}

Visual Review

Visual Review abilities let the agent capture screenshots of live pages and analyse them, enabling autonomous design review, before/after comparisons, and visual regression checks without requiring any browser extension.

capture_screenshot

Captures a screenshot of a WordPress page at a given URL using a server-side headless browser. The image is saved to the Media Library and a CDN URL is returned.

Parameters

ParameterTypeRequiredDescription
urlstringYesFull URL of the page to screenshot, e.g. https://example.com/about/
widthintegerNoViewport width in pixels. Default 1280
heightintegerNoViewport height in pixels. Default 800
full_pagebooleanNoCapture the full scrollable page instead of just the viewport. Default false
delay_msintegerNoMilliseconds to wait after page load before capturing, useful for animated content. Default 500
labelstringNoHuman-readable label stored with the attachment in the Media Library

Returns

{
"success": true,
"attachment_id": 88,
"url": "https://example.com/wp-content/uploads/2026/04/screenshot-about.png",
"width": 1280,
"height": 800
}

compare_screenshots

Takes two screenshots and returns a visual diff score plus a diff image highlighting changed regions. Useful for confirming that a design change produced the expected result or for detecting unintended regressions.

Parameters

ParameterTypeRequiredDescription
before_urlstringYesURL of the page to capture as the "before" state
after_urlstringYesURL of the page to capture as the "after" state. May be the same URL if comparing across time
widthintegerNoViewport width for both captures. Default 1280
thresholdfloatNoPixel-difference threshold (0.0–1.0). Pixels within this tolerance are considered unchanged. Default 0.1

Returns

{
"success": true,
"diff_score": 0.04,
"changed_pixels": 2340,
"total_pixels": 1024000,
"diff_attachment_id": 91,
"diff_url": "https://example.com/wp-content/uploads/2026/04/diff-about.png"
}

A diff_score of 0.0 means no visible change; 1.0 means every pixel changed.


review_page_design

Captures a screenshot of a page and sends it to the language model for visual analysis. Returns a structured assessment covering layout, typography, colour usage, and accessibility concerns.

Parameters

ParameterTypeRequiredDescription
urlstringYesFull URL of the page to review
focusstringNoComma-separated list of review areas to emphasise: layout, typography, colour, accessibility, mobile. Default: all areas
widthintegerNoViewport width. Default 1280

Returns

{
"success": true,
"screenshot_url": "https://example.com/wp-content/uploads/2026/04/review-about.png",
"assessment": {
"overall": "The page structure is clean and readable. Two accessibility issues detected.",
"layout": "Good visual hierarchy. Hero section is prominent.",
"typography": "Body text is 15px — consider increasing to 16px for readability.",
"colour": "Contrast ratio on the CTA button (#fff on #4a90e2) is 3.1:1 — below the WCAG AA threshold of 4.5:1.",
"accessibility": ["Low contrast on CTA button", "Missing alt text on hero image"],
"suggestions": ["Darken the CTA button to #1a5cb0 to pass WCAG AA", "Add descriptive alt text to the hero image"]
}
}

Installable Abilities

The Installable Abilities Registry lets you extend the agent with additional ability packs distributed as WordPress plugins. Each pack registers one or more abilities using the standard ability API.

list_available_abilities

Returns the catalogue of ability packs available for installation from the registry.

Parameters

ParameterTypeRequiredDescription
categorystringNoFilter by category: ecommerce, seo, media, social, developer

Returns

{
"packs": [
{
"slug": "gratis-ai-agent-woocommerce",
"name": "WooCommerce Abilities",
"category": "ecommerce",
"version": "1.0.0",
"abilities": ["create_product", "update_pricing", "manage_inventory"],
"installed": false
}
]
}

install_ability

Downloads and activates an ability pack from the registry.

Parameters

ParameterTypeRequiredDescription
slugstringYesAbility pack plugin slug

Returns { "success": true, "slug": "gratis-ai-agent-woocommerce", "abilities_added": 3 }


recommend_plugin

Queries the ability registry to find the best plugin for a described use case and, optionally, installs it.

Parameters

ParameterTypeRequiredDescription
descriptionstringYesNatural language description of the desired functionality
installbooleanNoIf true, installs the recommended plugin immediately. Default false

Example

{
"description": "I need a contact form with file upload support and spam protection",
"install": false
}

Returns

{
"recommendation": {
"slug": "contact-form-7",
"name": "Contact Form 7",
"reason": "Widely adopted, supports file uploads, and integrates with Akismet for spam filtering.",
"alternatives": ["wpforms-lite", "fluent-forms"]
}
}