Abilities Explorer: support custom providers in the filter dropdown and statistics - #884
Conversation
Ability_Handler::detect_provider() already supports custom providers via an ability's meta['provider'], and get_provider_label() passes unknown provider names through — but the provider select was hardcoded to all/Core/Plugins/Theme, so custom providers could never be selected. Build the options from the fetched ability list, mirroring the dynamic category filter (get_unique_categories): known origins first in canonical order, custom providers appended alphabetically. Sites without custom providers see the same dropdown (option labels now come from get_provider_label(), matching the Provider column).
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #884 +/- ##
=============================================
+ Coverage 78.44% 79.83% +1.38%
- Complexity 2454 2475 +21
=============================================
Files 104 104
Lines 9925 10006 +81
=============================================
+ Hits 7786 7988 +202
+ Misses 2139 2018 -121
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dkotter
left a comment
There was a problem hiding this comment.
This PR works as described though there are a few pre-existing issues that we should look to fix here I think:
- We don't properly sanitize the provider name when we use it as a class. So if I set a custom provider as
WordPress AI, the class we add ends up beingability-provider-wordpress aiwhen it should instead beability-provider-wordpress-ai - We don't properly style the custom provider pill:
And just as a personal opinion, not sure what the benefit is of this custom provider meta. I know that's a pre-existing thing but could be worth a discussion on maybe just removing that.
Seems odd to me to have that show in the Providers dropdown and show as a Provider pill but doesn't actually show in the top statistics. And then it's weird to have custom providers bucketed in the Plugins section of the statistics but if I filter by Plugin, it doesn't show. Just various inconsistencies like those that may be worth fixing or just removing the support all together.
…lls, make known-origin filters match by origin
|
Thanks for the review @dkotter — all three points are addressed in 40d0a75:
On keeping vs. removing the support: this PR now cleanly splits the two concepts that were previously conflated in one field — origin (Core/Plugin/Theme, derived from the ability name) drives the stat buckets and the known filters, while the The value I see in the label is attribution — on a busy site the Explorer can list 100+ abilities, and "which plugin exposed this capability to the AI" is a real trust/debugging question that a wall of identical "Plugin" pills can't answer. |
What?
Closes #883
Makes the Abilities Explorer treat custom providers (set via an ability's
meta['provider']) as first-class citizens:Why?
Ability_Handler::detect_provider()already supports custom providers viameta['provider'], andget_provider_label()deliberately passes unknown provider names through — the Provider column shows them and the?provider=query arg filters correctly. But the provider<select>inAbility_Table::extra_tablenav()was hardcoded to all/Core/Plugins/Theme, so custom providers could never be selected in the UI. See #883.The stat cards had the mirrored problem:
get_statistics()only counted the three hardcoded buckets, so any ability with a custom provider label silently vanished from every card (only Total stayed correct). Rendering a card per custom provider would not scale — a site with ten such plugins would get ten extra cards — so the cards stay Core/Plugins/Theme and the counting becomes origin-based instead.How?
Follows the same approach as the dynamic category filter added in #355 (
get_unique_categories()):Ability_Table::get_unique_providers()— known origins (Core, Plugin, Theme) first in canonical order, custom providers appended alphabetically.<option>tags become a loop, labelled via the existingAbility_Handler::get_provider_label(). This also makes the dropdown label ("Plugin") consistent with the Provider column, which used the singular while the old dropdown said "Plugins".Ability_Handler::detect_origin()holds the prefix-based Core/Plugin/Theme detection;detect_provider()returnsmeta['provider']when set and falls back to the origin. Formatted abilities expose a neworiginfield andget_statistics()counts by it — theby_providerarray keys are unchanged, soAdmin_Pageneeds no changes.Ability_TableTestcoversget_unique_providers()with and without a custom provider (this also covers the line the Codecov report flagged), and a newAbility_HandlerTestcase asserts a custom-provider ability still increments its origin bucket in the statistics.Sites without custom providers see no change anywhere (same four dropdown options, same counts). The accessible label added in #642 is preserved.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5
Used for: drafting the implementation and this PR description under my direction; I reviewed the code and tested it on a live site before submitting.
Testing Instructions
'provider' => 'My Plugin'(e.g. viawp_register_ability()).Tested on WordPress 7.1-beta1 with 112 registered abilities, 82 of them carrying a custom provider: the dropdown gains the custom option and filters to exactly those 82, and the stat cards read Core 6 / Plugins 106 / Theme 0 — identical to the counts before the custom labels were applied.
Changelog Entry