Every project in this course, the SEO optimizer, the blog post generator, the moderation tool, all ten of them, is built from the same two pieces wired together the same way. Once you see the pattern once, you’ll recognize it in every lesson that follows, so this lesson exists to make it explicit before you build anything.
Course 1 (WordPress AI Foundations) for wp_register_ability() and the Abilities API in
general, and Course 5 (The PHP AI Client SDK for WordPress) for wp_ai_client_prompt()
and provider fallback. This lesson assumes both, it doesn’t re-teach them.
Step 1: Two directions, one plugin
Everything you’ve learned across Courses 1 through 5 splits cleanly into two directions, and every project ahead uses both at once:
That’s the whole pattern. An ability without an internal AI call is just a regular WordPress action wrapped in extra schema. An AI Client SDK call without an ability around it is just a script only you can run. Putting both in the same function is what turns “a WordPress feature” into “a tool an autonomous agent can operate.”
Step 2: The skeleton every project starts from
Every project lesson in this course is a variation on this shape:
// File: my-plugin.php
add_action( 'wp_abilities_api_init', function () {
wp_register_ability(
'my-plugin/do-the-thing',
array(
'label' => __( 'Do the thing', 'my-plugin' ),
'description' => __( 'Describes exactly what this does and when to use it.', 'my-plugin' ),
'category' => 'content',
'input_schema' => array(
'type' => 'object',
'properties' => array( 'post_id' => array( 'type' => 'integer' ) ),
'required' => array( 'post_id' ),
),
'output_schema' => array(
'type' => 'object',
'properties' => array( 'result' => array( 'type' => 'string' ) ),
),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
'execute_callback' => function ( $input ) {
$post = get_post( $input['post_id'] );
if ( ! $post ) {
return new WP_Error( 'not_found', 'Post not found.' );
}
// The agents-out half: your site calling a model.
$response = wp_ai_client_prompt(
"Summarize this post in one sentence:\n\n" . $post->post_content
)->generate_text();
return array( 'result' => $response );
},
'meta' => array(
'annotations' => array( 'readonly' => true ),
'mcp' => array( 'public' => true ),
),
)
);
} );
Nothing here is new, wp_register_ability() from Course 1, wp_ai_client_prompt()
from Course 5. What’s new is the habit of reading every project ahead by asking two
questions: what makes this ability safe to call (the permission_callback and
meta.annotations), and what the AI call inside it is actually doing with the model’s
answer before it goes back to the caller.
Step 3: What “self-contained” actually means
Each of the ten project lessons ahead registers its own ability, with its own name, its own schema, and its own internal AI Client SDK call. None of them depend on code from another project lesson in this course. You can build the Meta Description Generator (Lesson 5) without ever touching the Bulk-Editing Assistant (Lesson 6), and the order they’re presented in (grouped into Content Projects, Editorial Automation, and Scale & Reach) is a suggestion for browsing, not a build sequence.
What they do share is everything covered in this lesson: the same registration
pattern, the same emphasis on permission_callback, and a running theme you’ll see
called out repeatedly, AI output goes somewhere reviewable (a draft, a suggestion, a
recommendation) rather than straight into a published, public, or destructive state
without a human step in between.
Test it: confirm your baseline still works
Before starting any project ahead, confirm both halves of the pattern are actually live in your environment:
wp-env run cli wp eval 'var_dump( function_exists( "wp_register_ability" ) );'
wp-env run cli wp eval 'var_dump( function_exists( "wp_ai_client_prompt" ) );'
Both should return bool(true). If either returns false, go back to Course 1 (for
the Abilities API) or Course 5 (for the AI Client SDK and a configured provider plugin)
before continuing, every project ahead assumes both are working.
It’s easy to jump straight to a project lesson because the topic is exciting and skip
the environment check above. If no AI provider plugin (Anthropic, OpenAI, or Google) is
configured, wp_ai_client_prompt() calls will fail or silently fall through
using_model_preference() fallbacks with no provider left to fall back to. Confirm a
provider is active before debugging a project’s code for a problem that’s actually
missing configuration.
Recap
Every project in this course is the same two-piece pattern: an ability registered with
wp_register_ability() as the agent-facing surface, and an internal
wp_ai_client_prompt() call inside its execute_callback doing the real AI work.
The ten lessons ahead are independent builds you can take in any order, grouped by
theme rather than by dependency, and each one carries this pattern’s habit of routing
AI output to something reviewable rather than acting on it unattended.
Resources & further reading
- Abilities API reference, developer.wordpress.org
- PHP AI Client SDK repository, GitHub
- MCP Adapter repository, GitHub