Registration gating in `register_all()` applies unevenly

Aperta
#54 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@nikmclaughlin ci sta già lavorando.

Dal 4/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
PHP
Stelle
4
Fork
4
Merge medio
1g 23h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WordPress/abilities

Tutte le issue di WordPress/abilities

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.