-
Notifications
You must be signed in to change notification settings - Fork 64
WIP: Start work on integrating the new WordPress Abilities API #1003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
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
| */ | ||
| public function abilities_api_init() { | ||
| if ( function_exists( 'wp_register_ability' ) ) { | ||
| $this->register_ability(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
…herwise MCP won't work
| ], | ||
| ], | ||
| 'output_schema' => [ | ||
| 'type' => 'object', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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: