Registration gating in `register_all()` applies unevenly

Open
#54 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@nikmclaughlin is already working on this.

Since Dec 4, 2026.

  • #55 by @nikmclaughlin — open

Assessment

This issue has not been assessed yet.

Description

Discussed in AI/#1333: https://github.com/WordPress/ai/pull/1333#issuecomment-7398410246

The package's current gating mechanism takes place per-call during ability registration with $args passed to register() and register_all(). The intent here is to allow each consumer to decide their own rules for which abilities get registered, but doing this per-call causes problems because the ability registry is a globally shared list. This means that arbitration is inherently timing-dependent and no consumer's attempt at filtering can ever be guaranteed authoritative.

Proposal

Add a global filter that applies for each ability during try_register. This would run after the core stand-down so core's names stay non-vetoable, but otherwise any returned false would veto so filter attempts are always honored. The filter would also resolve all add_filter calls once during registration, so the outcome is identical regardless of who calls the registration method first.

Example

Consumers could veto registration at the global level with something like:

// "Block media-delete" — regardless of which plugin triggers registration:
add_filter( 'wordpress_abilities_select', function ( $keep, $name, $entry ) {
    if ( 'core/media-delete' === $name ) {
        return false;
    }
    
    return $keep;
}, 10, 3 );

Otherwise, if they aren't worried about the existence of the ability per se, they could handle exposure in their own transport layer (e.g. when deciding which abilities get bridged as MCP tools).

This would be a breaking API change, so would require a v0.3.0 release where we add the filter, drop public_only from the registration API, and drop the $args parameter from the registration methods.

Dominant language
PHP
Stars
4
Forks
4
Avg merge
1d 23h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/abilities

All issues in WordPress/abilities

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.