Register Yoast SEO abilities about analysis scores#23062
Conversation
Pull Request Test Coverage Report for Build 4d046a7cb4cccf440b890379cf797088736bd3f5Details
💛 - Coveralls |
9dfe841 to
83ef1fc
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a Yoast SEO integration for WordPress 6.9’s Abilities API, exposing abilities that let authorized users retrieve recent post analysis scores (SEO, readability, inclusive language) for agentic/MCP use.
Changes:
- Add an
Abilities_API_Conditionalto only load the integration when the Abilities API is available (WP 6.9+). - Introduce an
Abilities_Integrationthat registers a Yoast category plus score-retrieval abilities (gated by enabled analysis features). - Add supporting services (
Score_Retriever,Enabled_Analysis_Features_Checker,Score_Result) and unit tests for the new behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/conditionals/abilities-api-conditional.php |
Adds a WP-version conditional for enabling the integration. |
src/abilities/user-interface/abilities-integration.php |
Registers the Yoast ability category and score abilities (SEO/readability/inclusive language). |
src/abilities/infrastructure/enabled-analysis-features-checker.php |
Determines which analyses are enabled (incl. language support check for inclusive language). |
src/abilities/application/score-retriever.php |
Fetches recent post indexables and maps them to ability output payloads. |
src/abilities/domain/score-result.php |
Value object for serializing score output. |
tests/Unit/Conditionals/Abilities_API_Conditional_Test.php |
Unit tests for the version conditional. |
tests/Unit/Abilities/User_Interface/Abilities_Integration_Test.php |
Unit tests for ability/category registration and permission callback wiring. |
tests/Unit/Abilities/Infrastructure/Enabled_Analysis_Features_Checker_Test.php |
Unit tests for enabled-feature detection behavior. |
tests/Unit/Abilities/Application/Score_Retriever_Test.php |
Unit tests for score retrieval/mapping output (SEO/readability/inclusive). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * | ||
| * @return void | ||
| */ | ||
| private function register_seo_scores_ability(): void { |
There was a problem hiding this comment.
This might be a bit overkill so feel free to ignore. but if you make each ability its own integration you can have the enabled feature check be the conditional to just ignore the integration instead of having an early return. I think that would be a bit more clean but also a bit more code 🤷
There was a problem hiding this comment.
I want to play it safe and avoid having these calculations in the conditionals because it's much earlier in the call stack that way and I dont think we have so complex calculations in there before. (the one that worries me more is the inclusive language check because it implicates languages/locales and stuff like that.)
So I think it's ok to not do that now, if that's alright.
Allows for a simpler implementation and also removed doing the same checks for the inclusive language feature twice
One for the abilities categories and one for the abilities themselves
35c9250 to
2d3d0b2
Compare
Context
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
http://example.com/wp-json/wp-abilities/v1/abilitiesendpoint and confirm that you see theyoast-seo/get-seo-scoresability we added and that it looks like this:yoast-seo/get-readability-scoresyoast-seo/get-inclusive-language-scoresActually run the abilities
For the SEO score one
http://dev.local/wp-json/wp-abilities/v1/abilities/yoast-seo/get-seo-scores/run?input[number_of_posts]=4and you should get 4 arrays, one for each post of the above. The results should be sorted as, the most recently modified post first.For the readability score one
http://dev.local/wp-json/wp-abilities/v1/abilities/yoast-seo/get-readability-scores/run?input[number_of_posts]=4and you should get 4 arrays, one for each post of the aboveFor the inclusivity score one
/wp-json/wp-abilities/v1/abilities/yoast-seo/get-inclusive-language-scores/run?input[number_of_posts]=4Edge cases
Ability not found.messageAbility not found.messageAuthorSorry, you are not allowed to execute this ability.messageDisable the abilities via hooks
Ability not foundresponse.Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
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 commited the results, if my PR introduces new images or SVGs.Innovation
innovationlabel.Fixes #