Fix AI features rendered twice on user profile page#23218
Merged
Conversation
The AI module was duplicated into src/ai-* (legacy) and src/ai/* (new onion structure) so older Premium versions can keep referencing the legacy namespaces. Both trees registered identical hooks at the same priority, which rendered the "AI features" section twice on the user profile page in 27.6-RC2. Add two version-aware conditionals that key off the Premium 27.5 AI restructure: - Old_Premium_AI_Conditional: true when Premium is active and predates 27.5-RC0; gates every src/ai-* integration and route. - New_Premium_Or_Free_AI_Conditional: true when Premium is absent or at least 27.5-RC0; gates every src/ai/* integration and route. The conditionals are runtime-evaluated in Loader::conditionals_are_met, so the DI container does not need to know which Premium is installed at compile time. Free users and Premium >=27.5 see the new tree; Premium <27.5 keeps using the legacy tree; only one tree is ever active at a time. Also drops a redundant No_Conditionals trait usage in both Get_Suggestions_Route classes; the explicit get_conditionals() already overrides it. Refs #2972. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Coverage Report for CI Build 8Coverage decreased (-0.6%) to 52.936%Details
Uncovered ChangesCoverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
…972-trivial-ai-features-displayed-two-times-at-user-settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
src/ai-*) and a new onion-architecture tree (src/ai/*) so that older Premium versions can keep referencing the legacy namespaces. Both trees register identical hooks at the same priority, so both fire on every profile page load.Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
The DI container is compiled at build time and cannot know which Premium version (if any) is installed, so the gating happens at the runtime conditional layer instead —
Loader::conditionals_are_met()evaluates conditionals oninit, where Premium'sWPSEO_PREMIUM_VERSIONconstant is reachable viaProduct_Helper.Resulting matrix — exactly one tree active per environment:
src/ai-*src/ai/*< 27.5-RC0>= 27.5-RC0When Premium
< 27.5support is eventually dropped, the entiresrc/ai-*tree andOld_Premium_AI_Conditionalcan be deleted in one go without affecting Free or new-Premium users.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
< 27.5(e.g. 27.4), and (c) Free + Premium>= 27.5./wp-admin/profile.php.Relevant test scenarios
Test instructions for QA when the code is in the RC
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
/yoast/v1/ai_generator/*and/yoast/v1/ai/free_sparks(consent, suggestions, usage, subscription-cache busting, free sparks, OAuth callbacks).Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.