WIP: Start work on integrating the new WordPress Abilities API#1003
Open
WIP: Start work on integrating the new WordPress Abilities API#1003
Conversation
…ss. This will only register an ability if the feature is enabled and configured and only if the feature has the register_ability method
…_Error's. Fix an issue with the user check failing when run under the abilities API
…tion over to the new abilities endpoint
…e new abilities endpoint
dkotter
commented
Sep 10, 2025
| */ | ||
| public function abilities_api_init() { | ||
| if ( function_exists( 'wp_register_ability' ) ) { | ||
| $this->register_ability(); |
Collaborator
Author
There was a problem hiding this comment.
I've set this up to match what we already do in this class but wondering if it would be better to have a method_exists check here and remove the empty method below?
4 tasks
…herwise MCP won't work
dkotter
commented
Sep 16, 2025
| ], | ||
| ], | ||
| 'output_schema' => [ | ||
| 'type' => 'object', |
Collaborator
Author
There was a problem hiding this comment.
In my testing, seems we need to return an object in order to support any WP_Error's that may return. This does mean we have to change the structure of what we return to be more than just a simple array unfortunately
…ity to add their own schema, the same as we modify the REST endpoint
…we import the images into the media library and return the URL from there. This brings better support for MCP, as the base64 data is often so large it causes agents to crash on the context
|
@dkotter thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
Note
Similar to #994, this is an early test of the new WordPress Abilities API and things will likely change as that matures. Opening this PR both for discussion and as an example of how we may want to implement this.
This PR brings in the WordPress Abilities API as a new composer dependency and integrates that into the Title Generation and Image Generation Features. Within the existing base Feature class, if a Feature is enabled and configured, we hook into the new
abilities_api_inithook to register any needed abilities. The thought is that each individual Feature will have their ownregister_abilitymethod that will be called here.I set this up in the Title Generation and Image Generation Features, registering the ability, adding a custom permission callback and adding a custom execution callback. All of this is structured very similarly to our existing custom REST endpoint that this Feature uses. I've then updated the front-end handling to use the new Abilities API endpoint instead of our custom endpoints, which required some slight changes to how the data is structured.
Points open to discussion:
Next steps:
How to test the Change
composer installandnpm run buildChangelog Entry
Credits
Props @dkotter
Checklist: