Repository navigation
Conversation
Posts saved by Press This before PR WordPress#129 have core/embed blocks missing the wp-block-embed-{provider} class in their figure element. This fails Gutenberg block validation in the standard editor, showing "Block contains unexpected or invalid content" instead of the embed. Adds a WP-CLI command, wp press-this repair-embeds, that scans posts for this exact mismatch and rewrites the content to match what core/embed's save() output expects. Supports --dry-run and --post-type. Fixes WordPress#131
kraftbj
approved these changes
Oct 20, 2026
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.
Summary
Posts saved by Press This before PR #129 have
core/embedblocks whose<figure>className is missingwp-block-embed-{provider}(e.g.wp-block-embed-youtube). Gutenberg'ssave()output for that block always includes this class whentype/providerNameSlugattrs are set, so the mismatch fails block validation and shows "Block contains unexpected or invalid content" in the standard editor.Adds a WP-CLI command that finds and repairs this specific mismatch in stored post content.
Fixes #131
Changes
includes/class-press-this-embed-repair.php (new)
Before:
// no repair mechanism existedAfter:
Why: Isolated, pure content-rewrite logic that's easy to unit test without a live WP-CLI environment. Validates
providerNameSlugagainstsanitize_html_class()before it touches HTML, since that value comes from stored post content, not a trusted source.includes/class-press-this-cli-commands.php (new)
Before:
// no CLI commands existed in the pluginAfter:
Why: Explicit, auditable repair path with dry-run support, rather than silently rewriting content on every page load.
press-this-plugin.php
Before:
After:
Why: Registers the command only in a WP-CLI context, no overhead on regular requests.
Testing
Test 1: Legacy embed fails validation before repair
<figure class="wp-block-embed is-type-video is-provider-youtube">(missing the 4th class)Result: "Block contains unexpected or invalid content" shown, as reported in the issue
Test 2: Repair fixes it
wp press-this repair-embeds --dry-run, confirm it lists the postwp press-this repair-embedsResult: embed renders normally, no validation warning. Re-running the command reports 0 posts repaired (idempotent).
Test 3: Unaffected content is left alone
type/providerNameSlugattrs (the PHPget_suggested_content()path)Result: not touched, since neither is broken
Also ran full PHP unit suite (283 tests, all passing) and
composer php:lint/composer php:compatibilityclean.