Registration gating in `register_all()` applies unevenly
Maintainers usually reply within 1 day
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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/abilities
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
WordPress/abilities#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
Better enforce core fidelity for canonical backportsPossibly taken @nikmclaughlin claimed this 3 days ago. Open
WordPress/abilities#47 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in WordPress/abilities
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/blocks-engine#7881 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
iruzen-dono/workless#117 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
magicsunday/webtrees-docker#285 ·
Maintainers usually reply within 1 day
-
area/tests type/bug when/soon
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
WP-CLI 3.0 fixes the cron lock and core download bugs described in the handbookPossibly taken @mayankmajeji claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
WordPress/hosting-handbook#521 ·