Opened 5 months ago
Last modified 3 days ago
#8296 new enhancement
Show registered abilities
| Reported by: | superdav42 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Plugin Directory | Keywords: | |
| Cc: |
Description
It would be very helpful to show any abilities, if any, are registered by plugins on their plugin repository listing. We already do something similar for blocks. If we could show the abilities users would know if a given plugin would work for the their workflow that uses abilities.
Change History (11)
This ticket was mentioned in Slack in #core-ai by superdav42. View the logs.
5 months ago
#3
@
3 months ago
Adding a +5 here. I had several people ask about this after my talk on the Abilities API at WCUS. Key themes in the feedback were developers wanting to showcase their work and users wanting to be able to discover plugins based on registered abilities.
From a platform perspective on the Core AI team, it would also help to have visibility into adoption of the API.
Ability registration is standardized, so should able to detect statically similar to/alongside the code scan for blocks.
This ticket was mentioned in Slack in #meta by nikskyverge. View the logs.
3 months ago
#5
@
3 months ago
To start putting some technical detail around this:
- Ability registration can be detected by scanning for calls to
wp_register_abilitywithin the codebase. - This scanning could be performed alongside detection of other features during import processing ~here: https://github.com/WordPress/wordpress.org/blob/f4f72cfbf36df5cb775e0b5c399d7df9e80a933a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php#L1101
- Ability names could be extracted from registration by extracting the 'label' from the args array with a fallback to the string $name from the first parameter, and stored in a new $abilities array
- [Option to extract additional ability data here: descriptions, categories, metadata?]
- Ability data can be persisted to post meta following prior art e.g. for blocks: https://github.com/WordPress/wordpress.org/blob/f4f72cfbf36df5cb775e0b5c399d7df9e80a933a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php#L498
This ticket was mentioned in Slack in #meta by nikskyverge. View the logs.
3 months ago
@justlevine commented on PR #1168:
9 days ago
#7
- core/* abilities. Should a plugin's own core/* registrations be listed? The AI plugin re-registers core/content-query, core/settings-get and core/users-query.
fwiw, my vote is yes. The fact that "core" is a reserved prefix is organizational, not prescriptive for wordpress-develops codebase. Can think of a bunch of hypotheticals in e.g. the importer plugins, two-fctor, MCP Adapter, or other in our growing catalog of Canonical Plugins etc that could make a good argument for prefixing some abilities with core/. We can turn it into a PCP sniff if we wanna enforce it, but why programmatically limit the PRT?
(Independent of this, I'm sharing again that I think our _experimental_ Core Abilities in the ai plugin/MCP adapter/shared package/wtvr should use something like core-experimental/* or some other prefix that isn't core, so we have a non-breaking migration path)
nikmclaughlin commented on PR #1168:
9 days ago
#8
Agreed w/ @justlevine on 1 above, and I'd add that if we _did_ want to manage conflicts, dedupe abilities, or encourage different behavior from plugins, those solutions would better live elsewhere (PCP, Core Abilities API, etc.). Simply listing a plugin's registered abilities makes an clearer decision, IMO, that we should list ALL registered abilities, even if we decide that some of them are "doing it wrong".
- WooCommerce. Abilities that WooCommerce registers on a plugin's behalf, through woocommerce_ability_definition_classes, aren't detected.
Curious if we could get feedback from @nerrad & team on that. Short of direction from Woo, I think it makes sense from a .org perspective to only show abilities that are registered via Core registration patterns (i.e. hooked in to wp_abilities_api_init & calling wp_register_ability). The existing PR already accounts for indirect implementations that have been found across plugins generally (as mentioned: "Popular plugins rarely pass literals to wp_register_ability()"), but Woo's ability extension is more of a plugin-specific sub-ecosystem for abilities, rather than a pattern plugin devs are using to register abilities with Core. Put another way, it's my understanding that extensions using woocommerce_ability_definition_classes are looking to expose abilities in a WooCommerce-specific context, which .org doesn't need to cater toward.
@dpknauss commented on PR #1168:
3 days ago
#9
This will be a terrific addition to .org — I've wanted neutral technical facts about plugins to be included there for a long time.
This might be out of scope, but here are two small additions that would make the stored data useful for security review, not just discovery:
- Exposure flags. Record
meta.public,meta.show_in_rest, andmeta.mcp.publicwhen they resolve, andnullwhen they don’t. They sit in the same args array the scanner already resolves forlabelanddescription. They control which channels expose an ability: REST usesshow_in_restand falls back topublic, and MCP Adapter 0.7.x usesmcp.publicand also falls back topublic, ignoringshow_in_rest. - Authorization filter hooks. Record whether the plugin’s own code hooks
wp_ability_permission_resultorwp_pre_execute_ability, with file and line, plusbundled. Either filter can override an ability’s permission check. On a live site, a callback such as__return_truecan’t be traced back to the plugin that added it, but the importer sees each plugin’s source on its own, so it can.
Neither field says whether an ability is safe, so they shouldn't be displayed as any kind of judgment like that. They'd tell reviewers, site owners, and agents where to look deeper.
@dpknauss commented on PR #1168:
3 days ago
#10
Two refinements to my comment above:
- Exposure flags: for each value, it would help to record whether it was set explicitly, left out (so the documented fallback applies), or couldn't be resolved. A nullable boolean collapses the last two, which mean different things.
- Authorization hooks: the two filters don't do the same thing.
wp_ability_permission_resultchanges the permission result.wp_pre_execute_abilitycan skip input preparation and the permission check entirely, whether for caching, denial, or a replacement result. So the record should name the hook and callback without inferring their effect. Also, the earlyregister_ability/abilities_registrytext check would skip a plugin that only hooks these filters without registering abilities, so hook detection would need its own relevance check.
@dpknauss commented on PR #1168:
3 days ago
#11
Two refinements to my comment above:
- Exposure flags: for each value, it would help to record whether it was set explicitly, left out (so the documented fallback applies), or couldn't be resolved. A nullable boolean collapses the last two, which mean different things.
- Authorization hooks: the two filters don't do the same thing.
wp_ability_permission_resultchanges the permission result.wp_pre_execute_abilitycan skip input preparation and the permission check entirely, whether for caching, denial, or a replacement result. So the record should name the hook and callback without inferring their effect. Also, the earlyregister_ability/abilities_registrytext check would skip a plugin that only hooks these filters without registering abilities, so hook detection would need its own relevance check.
Plus one to this. It would not only help us decide which plugins to use for their abilities, but it would let more people know about the existence of abilities in general.