SEO: fix FAQPage schema to read the question from saved <summary> markup#50093
Draft
Conversation
The core/details block stores its summary as a source:"rich-text" attribute, which lives in the saved <summary>…</summary> markup, not in the <!-- wp:details … --> comment. parse_blocks() does not resolve source-based attributes, so $block['attrs']['summary'] is always empty for real, editor-saved blocks — the question came back blank, every item was skipped, and build_faq() returned null. FAQPage JSON-LD has therefore never emitted from real editor content since it shipped (JETPACK-1680). Read the summary from the block's inner HTML instead, reduced to decoded plain text (shared with the answer extraction). Replace the unit-test fixtures that baked the summary into the block comment — which Gutenberg never does — with realistic editor-saved markup, so the regression is actually covered. JETPACK-1793 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
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.
Fixes JETPACK-1793 (Linear).
Note
Stacked on #50080 (
jetpack-1779-…, the@graphrefactor that relocated the builder toclass-post-schema-node.php). The base branch is set to that PR; please merge #50080 first, after which this will retarget totrunk. The diff here is the single FAQ-fix commit on top.Proposed changes
FAQ schema (
FAQPage) has never emitted from real, editor-saved content since it shipped (JETPACK-1680). Thecore/detailsblock stores itssummaryas asource: "rich-text"attribute that lives in the saved<summary>…</summary>markup, not in the<!-- wp:details … -->comment.parse_blocks()doesn't resolve source-based attributes, so$block['attrs']['summary']is always empty → the question is blank → every item is skipped →build_faq()returnsnull→ no JSON-LD. This affects pages and posts equally.<summary>) instead of the empty comment attribute.to_plain_text()helper (tags stripped, HTML entities decoded, trimmed) — this also fixes latent entity double-encoding in the answer.<summary>.Related product discussion/links
@graphrefactor: SEO: convert schema output to an @graph and add a site-level Organization node #50080Does this pull request change what data or activity we track or use?
No. This only fixes the server-side JSON-LD output for content the author has already opted into (Schema type = FAQ).
Testing instructions
cd projects/packages/seo && composer dump-autoload).composer phpunitinprojects/packages/seo— all green (52 tests). The FAQ tests now use realistic markup; reverting just thesrcfix makes them fail, confirming they're real regression tests.On a live site (with the new SEO experience + SEO Tools active):
FAQPagenode now appears in the@graph, withmainEntity[].name= the<summary>text andacceptedAnswer.text= the answer.FAQPageat all.