Fix: Meta Description: Issue with Yoast plugin for Meta Description experiment - #886
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #886 +/- ##
==========================================
Coverage 78.44% 78.44%
Complexity 2454 2454
==========================================
Files 104 104
Lines 9925 9925
==========================================
Hits 7786 7786
Misses 2139 2139
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. |
|
Note we'll want to credit @carlos-widgilabs on this as well, which wasn't captured by prop bot cc / @jeffpaul |
What?
Closes #874
Why?
Yoast AIis disable, still meta description is saved via yoast.How?
seo-adapter.tsfile, which register the adapter and use the required SEO adapters to work with.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Initial code implementation and final implementation and testing was done by me.
Testing Instructions
Screenshots or screencast
Screen.Recording.2026-07-20.at.1.21.22.PM.mov
Changelog Entry
AI Summary
What?
Routes the Meta Description Apply action through the active SEO plugin's own editor store instead of always writing to
core/editorpost meta. Introduces a small, slug-keyed adapter layer and ships a Yoast adapter, so an applied AI meta description updates the SEO plugin UI and persists on all post types (posts, pages, and CPTs).Why?
useMetaDescription.applyDescriptionwrote the suggestion viaeditPost( { meta: { [ metaKey ]: text } } )(thecore/editorstore). That only works when the meta key is REST-registered for the current post type:_yoast_wpseo_metadescto REST only for thepostpost type (register_meta( … 'object_subtype' => 'post' )). On a page or CPT the key isn't REST-registered, soeditPostis dropped on save and the Yoast snippet field (bound to theyoast-seo/editorstore) never reflects it — the applied description is lost. It also only appeared to work on posts when Yoast's own AI feature happened to be enabled, because that feature mounts the hook that mirrorscore/editormeta into the Yoast store.The fix targets the SEO plugin's own store, which is the source of truth for its UI and its all-post-type save path.
How?
src/experiments/meta-description/seo-adapters.ts— aSeoEditorAdapterabstraction (apply/read) selected by the active plugin slug (window.aiMetaDescriptionData.seoPlugin):defaultAdapter— unchanged behaviour:editPoston the meta key; reads fromcore/editormeta. Used for the fallback key and any not-yet-adapted SEO plugin.yoastAdapter—applydispatchesupdateData( { description } )toyoast-seo/editor(drives the UI + Yoast's metabox save on every post type) and callseditPostto mark the editor dirty so the Save button enables (and to persist via REST onpost).readusesgetSnippetEditorDescription()with a fallback to core meta if the Yoast store isn't ready.getAdapter()with anai.metaDescription.seoAdaptersJS filter, mirroring the existing PHPwpai_meta_description_seo_pluginsfilter for extensibility.components/useMetaDescription.ts— selects the adapter by slug, routesapplyDescriptionthroughadapter.apply(), and derivescurrentDescriptionfromadapter.read()(fixing the display / "already set" check on Yoast pages, wherecore/editormeta doesn't carry the key).SEO_Integrationremains the single source of truth for detection and the meta key. Which plugin is active and its key stay server-side; how to write to the editor store is client-side, per-plugin behaviour.Scope: ships the Yoast adapter only. Rank Math / All in One SEO / SEOPress continue to use the default (
editPost) adapter until each is verified — dedicated adapters can be added incrementally (AIOSEO in particular uses a non-@wordpress/datastore).Testing Instructions
Preconditions: an AI connector with a text-generation model configured, and the Meta Description experiment enabled.
<meta name="description" …>with the text.