Download the PHP package automattic/jetpack-wp-abilities without Composer
On this page you can find all versions of the php package automattic/jetpack-wp-abilities. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download automattic/jetpack-wp-abilities
More information about automattic/jetpack-wp-abilities
Files in automattic/jetpack-wp-abilities
Package jetpack-wp-abilities
Short Description Shared utilities for registering abilities with the WordPress Abilities API from Jetpack packages and plugins.
License GPL-2.0-or-later
Informations about the package jetpack-wp-abilities
Jetpack WP Abilities
Shared utilities for registering a category and its abilities with the WordPress Abilities API 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
Extend Registrar, override the three static getters, and call init() from the consumer's bootstrap.
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
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.
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
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.
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
If you plan on using this package in your WordPress plugin, we recommend using Jetpack Autoloader as your autoloader for maximum interoperability with other plugins that use this package.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
Jetpack WP Abilities is licensed under GNU General Public License v2 (or later).