Feature: New Experiment Abilities Toggle - #881
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #881 +/- ##
=============================================
- Coverage 75.95% 75.76% -0.20%
- Complexity 2989 3013 +24
=============================================
Files 124 131 +7
Lines 11850 11915 +65
=============================================
+ Hits 9001 9027 +26
- Misses 2849 2888 +39
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:
|
|
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. |
dkotter
left a comment
There was a problem hiding this comment.
Left some comments that need looked at, in addition to a few other things:
- We should look to add documentation here matching our other experiments
- It doesn't appear we have E2E tests specific to this new experiment, ensuring the experiment can be turned on/off and abilities are available/not available depending on that state
- Technically this is a breaking change for any site that is relying on these Abilities. Once they upgrade, they'll need to enable this new experiment before those Abilities are available. That's likely fine but will need to ensure that is called out when we put together the release (cc @jeffpaul). Could also make this experiment enabled by default though that goes against how everything else is set up right now
|
Thanks for the review @dkotter, I will update the PR to address those. |
Added the documentation in the commit - 6e4af35
Added the E2E tests for the experiment in commit - d37e079
I guess it would be added while we do the release, so have not added anything here. Thanks, |
dkotter
left a comment
There was a problem hiding this comment.
Couple more minor things I've noted.
And I don't know if related to this or just a general bug in our plugin but I'm finding that if you toggle the experiment on and off a few times, we end up losing credentials, which is really weird. May not be related to this PR but figured I'd flag it:
missing-credentials.mov
|
Let's not enable these abilities by default, but instead call out in the changelogs and with an upgrade notice that they'll need to be enabled for anyone making use of abilities previously. |
Quick followup to this bug. I have verified the same behavior on In diving in, seems this is an upstream issue within WordPress Core. Any request to If anything goes wrong in that validation (in my case, seems like occasionally requests to the OpenAI models endpoint is timing out at 5 seconds), Core sets the API key to a blank string. We can look to fix on our end by introducing a custom endpoint to handle saving our settings, bypassing the |
|
Note that E2E and Plugin Check tests aren't running right know due to WordPress 7.0.4 not being properly tagged on GitHub:
I've run those locally and they are all passing so going to merge this in |
Thanks @dkotter, I noticed that too as well in earlier days while I was contributing to AI plugin, but it happen so randomly that I was not able to reproduce with the exact steps again and again, hence have'nt logged the ticket 😅. Will create the ticket on core or either GB and will add the reproduction steps. Thanks for exact reproduction steps. Update: Raised the trac ticket and PR. Cc: @jeffpaul |
What?
Closes #863
Why?
How?
Use of AI Tools
Testing Instructions
Abilities Explorerpage.Changelog Entry
AI Summary
Implements #863 — wraps the plugin's "always-on" custom WordPress Abilities behind a single opt-in experiment. Previously these abilities were registered unconditionally on every request and exposed via the Abilities API / MCP. Now a site owner enables the Custom Abilities experiment and gains access to all of them at once; when it's off, none are registered.
Motivation
Per #863, ability APIs (some of which go beyond read-only operations) shouldn't be automatically exposed — they should require purposeful enablement. This gates the current custom abilities behind an experiment toggle, giving admins explicit control and establishing a scalable pattern for future abilities.
What changed
New:
Custom Abilitiesexperimentcustom-abilities, Admin category) nested under the global Enable AI toggle. When enabled, it registers every gated ability together — no per-ability toggles.Show_In_Abilities(infrastructure, not a user-facing ability) runs once before registration when any enabled ability needs core objects exposed to the Abilities API.New: gated-ability framework (scalable)
Abstract_Gated_Ability— minimal contract:register()+requires_core_object_exposure().Post_Utilities→ai/get-post-details,ai/get-post-termsRead_Settings→core/read-settingsRead_Users→core/read-usersRead_Content→core/read-contentGated_Abilitiesregistry +wpai_gated_abilitiesfilter for third-party extensibility.Removed always-on registration
Main.phpno longer registersPosts,Show_In_Abilities,Settings,Users, andContentabilities directly; they're now owned by the experiment.Decoupling guard (no internal regressions)
Posts::get_post_details()/Posts::get_post_terms()static methods; the abilities'execute_callbacks delegate to them.get_post_context()now calls these static methods directly instead of viawp_get_ability(), so the six generation features that rely on post context (excerpt, title, meta-description, image-prompt, summarization, content-classification) keep working regardless of whether the Posts ability is toggled on. The toggle only controls external (REST/MCP) exposure.Files
Added
includes/Experiments/Custom_Abilities/Custom_Abilities.phpincludes/Abstracts/Abstract_Gated_Ability.phpincludes/Abilities/Gated/Gated_Abilities.phpincludes/Abilities/Gated/Post_Utilities.phpincludes/Abilities/Gated/Read_Settings.phpincludes/Abilities/Gated/Read_Users.phpincludes/Abilities/Gated/Read_Content.phpModified
includes/Main.php— removed always-on ability registration + unused importsincludes/Experiments/Experiments.php— registeredCustom_Abilitiesincludes/helpers.php—get_post_context()uses the new static methodsincludes/Abilities/Utilities/Posts.php— extracted static methods; callbacks delegateBehavior
get_post_context()decoupling.Notes for reviewers
@since x.x.xdocblock tags are placeholders to be stamped at release.wpai_gated_abilitiesfilter.