Skip to content

Proposal: Add a convienient way to filter the list of all registered abilities #38

@gziolo

Description

@gziolo

Figure out how to filter correctly all abilities when fetching them, given the expected high number of registered items by core and plugins.

Currently, it's only possible to find a single item or fetch all of them:

// Retrieving all abilities.
$abilities = wp_get_abilities();

// Retrieving a specific ability.
$ability = wp_get_ability( 'example/add-numbers' );

The same applies to the REST API, which offers WP_REST_Abilities_List_Controller that handles listing abilities and retrieving individual abilities:

  • GET /wp-json/wp/v2/abilities – list all registered abilities.
  • GET /wp-json/wp/v2/abilities/{name} – Get a specific ability by name.

Let's discuss possible approaches. For reference, the WP Feature API prototype offers a special WP_Feature_Query object that offers several filtering options:

https://github.com/Automattic/wp-feature-api/blob/82ff8af75ab607ec39dfbea3c1100807843922a3/includes/wp-feature.php#L51-L60

Metadata

Metadata

Assignees

Projects

Status

In progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions