PHPackages                             automattic/jetpack-wp-abilities - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. automattic/jetpack-wp-abilities

ActiveJetpack-library[Utility &amp; Helpers](/categories/utility)

automattic/jetpack-wp-abilities
===============================

Shared utilities for registering abilities with the WordPress Abilities API from Jetpack packages and plugins.

v0.1.2(1w ago)03065GPL-2.0-or-laterPHPPHP &gt;=7.2CI failing

Since May 4Pushed 1w agoCompare

[ Source](https://github.com/Automattic/jetpack-wp-abilities)[ Packagist](https://packagist.org/packages/automattic/jetpack-wp-abilities)[ RSS](/packages/automattic-jetpack-wp-abilities/feed)WikiDiscussions trunk Synced 1w ago

READMEChangelogDependencies (6)Versions (5)Used By (5)

Jetpack WP Abilities
====================

[](#jetpack-wp-abilities)

Shared utilities for registering a category and its abilities with the [WordPress Abilities API](https://make.wordpress.org/core/) from Jetpack packages and plugins.

The `Registrar` base class owns the boilerplate every consumer would otherwise hand-roll: hooking into `wp_abilities_api_categories_init` / `wp_abilities_api_init` (or dispatching immediately when those actions have already fired), and guarding the Abilities API function calls so the class is safe on WordPress versions older than 6.9.

Usage
-----

[](#usage)

Extend `Registrar`, override the three static getters, and call `init()` from the consumer's bootstrap.

```
use Automattic\Jetpack\WP_Abilities\Registrar;

class My_Plugin_Abilities extends Registrar {

	public static function get_category_slug(): string {
		return 'my-plugin';
	}

	public static function get_category_definition(): array {
		return array(
			'label'       => 'My Plugin',
			'description' => __( 'Abilities for My Plugin.', 'my-plugin' ),
		);
	}

	public static function get_abilities(): array {
		return array(
			'my-plugin/get-things' => array(
				'label'               => __( 'List things', 'my-plugin' ),
				'description'         => __( 'Return the list of things the user can access.', 'my-plugin' ),
				'input_schema'        => array(
					'type'                 => 'object',
					'default'              => array(),
					'properties'           => array(),
					'additionalProperties' => false,
				),
				'execute_callback'    => array( __CLASS__, 'get_things' ),
				'permission_callback' => array( __CLASS__, 'can_read_things' ),
				'meta'                => array(
					'annotations'  => array(
						'readonly'    => true,
						'destructive' => false,
						'idempotent'  => true,
					),
					'show_in_rest' => true,
				),
			),
		);
	}

	public static function can_read_things(): bool {
		return current_user_can( 'read' );
	}

	public static function get_things( $input = null ) {
		return array( 'things' => array() );
	}
}

My_Plugin_Abilities::init();
```

If an ability spec omits `category`, the registrar auto-injects `get_category_slug()`. If the spec sets `category` explicitly (for cross-registrar shared abilities), the explicit value is preserved.

Gating registration for gradual rollout
---------------------------------------

[](#gating-registration-for-gradual-rollout)

Registration is **opt-in**. `init()` checks the `jetpack_wp_abilities_enabled` filter, which defaults to `false`. Return `true` to turn registration on for this request, typically gated on a site option, user capability, or feature flag.

```
// Enable Jetpack abilities registration on sites that have opted in.
add_filter(
	'jetpack_wp_abilities_enabled',
	static function ( bool $enabled ): bool {
		return (bool) get_option( 'my_abilities_rollout_enabled', false );
	}
);
```

Because the default is `false`, a plugin that extends `Registrar` and calls `MyRegistrar::init()` registers nothing until a site explicitly flips the flag.

### Per-registration gate

[](#per-registration-gate)

For finer-grained control, every category and every ability also passes through the `jetpack_wp_abilities_should_register` filter (only reached when `jetpack_wp_abilities_enabled` has already returned `true`). Returning `false` skips a single registration.

```
// Globally enabled, but hold back a single ability until it's GA.
add_filter(
	'jetpack_wp_abilities_should_register',
	static function ( bool $enabled, string $type, string $slug ): bool {
		if ( 'ability' === $type && 'my-plugin/experimental-write' === $slug ) {
			return current_user_can( 'manage_options' );
		}
		return $enabled;
	},
	10,
	3
);
```

The filter fires once per category and once per individual ability, so callbacks can switch on `$type` (`'category'` or `'ability'`) and/or `$slug` for granular control.

Using this package in your WordPress plugin
-------------------------------------------

[](#using-this-package-in-your-wordpress-plugin)

If you plan on using this package in your WordPress plugin, we recommend using [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader for maximum interoperability with other plugins that use this package.

Security
--------

[](#security)

Need to report a security vulnerability? Go to  or directly to our security bug bounty site .

License
-------

[](#license)

Jetpack WP Abilities is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance98

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~13 days

Total

3

Last Release

8d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c5869ecbb8e0eac7e8b8e0f3cf7bdd8d5fcdc4abc10a72281872c53f8639d44?d=identicon)[automattic](/maintainers/automattic)

![](https://www.gravatar.com/avatar/4219631a4c265c99eeb168b16dda429b30e418fa05c6d16fcd9a58d72a5cf894?d=identicon)[enejb](/maintainers/enejb)

---

Top Contributors

[![tbradsha](https://avatars.githubusercontent.com/u/32492176?v=4)](https://github.com/tbradsha "tbradsha (4 commits)")[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (3 commits)")[![enejb](https://avatars.githubusercontent.com/u/115071?v=4)](https://github.com/enejb "enejb (1 commits)")[![manzoorwanijk](https://avatars.githubusercontent.com/u/18226415?v=4)](https://github.com/manzoorwanijk "manzoorwanijk (1 commits)")

### Embed Badge

![Health badge](/badges/automattic-jetpack-wp-abilities/health.svg)

```
[![Health](https://phpackages.com/badges/automattic-jetpack-wp-abilities/health.svg)](https://phpackages.com/packages/automattic-jetpack-wp-abilities)
```

PHPackages © 2026

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