Abilities REST Adapter
Defines Abilities API abilities by reusing existing REST API routes (schema, validation, permission, handler) via rest_do_request().
by Ovidiu Galatan · github.com/galatanovidiu/abilities-rest-adapter · website
★ 0stars
2release downloads
41composer installs
0forks
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/galatanovidiu/abilities-rest-adapter/releases/download/v0.1.2/abilities-rest-adapter.zipAlso on Packagist as galatanovidiu/abilities-rest-adapter:
composer require galatanovidiu/abilities-rest-adapterFrom the readme
Abilities REST Adapter
Define a WordPress Abilities API ability by reusing an existing REST API route — its schema, validation, permission check, and handler — instead of re-implementing them. The adapter dispatches the real route via restdorequest(), so the ability stays behaviorally equivalent to the endpoint.
The signature mirrors core's wpregisterability( $name, $args ). route, method, label, description, and category are required.
See docs/usage.md for the full guide: the five seams (inputcallback / outputcallback / inputschema / outputschema / requirepermission), collections, the write-safety rule, the permission-error limitation, and the wp ability describe-route command.
- Reuse, don't re-implement. Permission is the route's real check; output is the route's real body. A collection synthesizes { items, total, totalpages } from the X-WP-Total headers.
- Facilitate, don't force. The adapter gives the developer seams instead of baking in opinions:
- inputcallback( array $params ): array|WPError — transform the request before dispatch (set fields, pin context, inject fixed params, reshape, or reject).
- outputcallback( $data, array $input, WPRESTResponse $response ): mi
Read the full README on GitHub →