PHPackages                             galatanovidiu/abilities-rest-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. galatanovidiu/abilities-rest-adapter

ActiveWordpress-plugin[API Development](/categories/api)

galatanovidiu/abilities-rest-adapter
====================================

Defines Abilities API abilities by reusing existing REST API routes (schema, validation, permission, handler) via rest\_do\_request().

v0.1.2(1mo ago)027MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 9Pushed 1mo agoCompare

[ Source](https://github.com/galatanovidiu/abilities-rest-adapter)[ Packagist](https://packagist.org/packages/galatanovidiu/abilities-rest-adapter)[ Docs](https://github.com/galatanovidiu/abilities-rest-adapter)[ RSS](/packages/galatanovidiu-abilities-rest-adapter/feed)WikiDiscussions trunk Synced 1w ago

READMEChangelog (3)Dependencies (11)Versions (5)Used By (0)

Abilities REST Adapter
======================

[](#abilities-rest-adapter)

[![Packagist Version](https://camo.githubusercontent.com/0b0ace003d7403e09bef891fb2fd3eddbe63a2e3a61f432b71bed4dc27e73b68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67616c6174616e6f76696469752f6162696c69746965732d726573742d61646170746572)](https://packagist.org/packages/galatanovidiu/abilities-rest-adapter)[![Packagist Downloads](https://camo.githubusercontent.com/f4040efc1616a5b9100e86877f24b153aa54ef5e59d35d5ce9f8e59bdf56299d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67616c6174616e6f76696469752f6162696c69746965732d726573742d61646170746572)](https://packagist.org/packages/galatanovidiu/abilities-rest-adapter)

Define a WordPress [Abilities API](https://github.com/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 `rest_do_request()`, so the ability stays behaviorally equivalent to the endpoint.

```
wp_register_ability_from_rest_route( 'my-plugin/list-posts', array(
	'route'       => '/wp/v2/posts',
	'method'      => 'GET',
	'label'       => 'List Posts',
	'description' => 'List published posts.',
	'category'    => 'content', // must already be registered
) );
```

The signature mirrors core's `wp_register_ability( $name, $args )`. `route`, `method`, `label`, `description`, and `category` are required.

**See [`docs/usage.md`](docs/usage.md)** for the full guide: the five seams (`input_callback` / `output_callback` / `input_schema` / `output_schema` / `require_permission`), 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, total_pages }` from the `X-WP-Total` headers.
- **Facilitate, don't force.** The adapter gives the developer seams instead of baking in opinions:
    - `input_callback( array $params ): array|WP_Error` — transform the request before dispatch (set `_fields`, pin `context`, inject fixed params, reshape, or reject).
    - `output_callback( $data, array $input, WP_REST_Response $response ): mixed|WP_Error` — reshape a successful response (or reject it).
    - `input_schema` / `output_schema` — replace the schemas the adapter derives from the route.
    - `require_permission( mixed $input ): bool|WP_Error` — an opt-in floor checked before the route's own permission; it can only tighten access, never widen it.
- **Safety annotations.** Every non-readonly operation must declare boolean `destructive` and `idempotent` values under `meta.annotations`; invalid or incomplete safety metadata fails registration. Readonly GETs receive the coherent read tuple automatically.
- **Standalone now, core later.** Built as a feature plugin; designed so it can move into core.
- **Status:** behavioral-equivalence + regression suite green on PHP 7.4–8.5.

Requirements
------------

[](#requirements)

- WordPress 6.9+ (the Abilities API ships in core 6.9). Faithful permission-error surfacing uses the 7.1 `wp_ability_permission_result` filter.
- PHP 7.4+ (matches WordPress core's supported floor). CI tests every major version through PHP 8.5.

The dev environment (`.wp-env.json`) tracks current WordPress trunk (7.1-alpha) so the 7.1 filter is available.

Installation
------------

[](#installation)

### As a Composer dependency (plugin developers)

[](#as-a-composer-dependency-plugin-developers)

Plugin developers can install the adapter as a Composer dependency and use `wp_register_ability_from_rest_route()` from their own plugin. The package is published on [Packagist](https://packagist.org/packages/galatanovidiu/abilities-rest-adapter):

```
composer require galatanovidiu/abilities-rest-adapter
```

#### Using Jetpack Autoloader (recommended)

[](#using-jetpack-autoloader-recommended)

When multiple plugins bundle this adapter, use the [Jetpack Autoloader](https://github.com/Automattic/jetpack-autoloader) so only the latest shared version loads:

```
composer require automattic/jetpack-autoloader
```

Load it in your main plugin file instead of the standard Composer autoloader:

```
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload_packages.php';
```

#### Using the adapter in your plugin

[](#using-the-adapter-in-your-plugin)

Check availability and register abilities on `wp_abilities_api_init`:

```
add_action( 'plugins_loaded', function () {
	if ( ! function_exists( 'wp_register_ability_from_rest_route' ) ) {
		return;
	}

	add_action( 'wp_abilities_api_init', function () {
		wp_register_ability_from_rest_route( 'my-plugin/get-post', array(
			'route'       => '/wp/v2/posts/(?P[\d]+)',
			'method'      => 'GET',
			'label'       => 'Get a post',
			'description' => 'Fetch a single published post by ID.',
			'category'    => 'content',
		) );
	} );
} );
```

See [`docs/usage.md`](docs/usage.md) for the full registration guide.

### As a WordPress plugin (recommended for site-wide use)

[](#as-a-wordpress-plugin-recommended-for-site-wide-use)

Install and activate the adapter once; any plugin on the site can call `wp_register_ability_from_rest_route()`.

Download the latest stable release from the [GitHub Releases page](https://github.com/galatanovidiu/abilities-rest-adapter/releases/latest)and install it like any other WordPress plugin. Release ZIPs include the bundled `vendor/` directory.

#### With WP-CLI

[](#with-wp-cli)

```
wp plugin install https://github.com/galatanovidiu/abilities-rest-adapter/releases/latest/download/abilities-rest-adapter.zip --activate
```

#### From a git checkout

[](#from-a-git-checkout)

```
composer install --no-dev
wp plugin activate abilities-rest-adapter
```

Development
-----------

[](#development)

```
npm install
composer install
npm run wp-env          # start the dev environment
npm run lint:php        # PHPCS
npm run lint:php:stan   # PHPStan (level 8)
npm run test:php:setup  # install deps in the test env (first run)
npm run test:php        # PHPUnit
```

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

47d ago

PHP version history (2 changes)v0.1.0PHP ^7.4

v0.1.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c846c9fda3782cd0858c604ec0d7f189988a2585af8afda99069d7aeb10bee08?d=identicon)[galatanovidiu](/maintainers/galatanovidiu)

---

Top Contributors

[![galatanovidiu](https://avatars.githubusercontent.com/u/2674748?v=4)](https://github.com/galatanovidiu "galatanovidiu (47 commits)")

---

Tags

wordpressaiREST APIabilities-api

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/galatanovidiu-abilities-rest-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/galatanovidiu-abilities-rest-adapter/health.svg)](https://phpackages.com/packages/galatanovidiu-abilities-rest-adapter)
```

###  Alternatives

[wordpress/mcp-adapter

Adapter for Abilities API, letting WordPress abilities to be used as MCP tools, resources or prompts

887273.6k12](/packages/wordpress-mcp-adapter)[airesvsg/acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API

1.4k78.8k](/packages/airesvsg-acf-to-rest-api)[wordpress/wp-ai-client

An AI client and API for WordPress to communicate with any generative AI models of various capabilities using a uniform API.

12625.3k3](/packages/wordpress-wp-ai-client)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

642.3k](/packages/rubix-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
