feat: convert iframe block to dynamic server-side rendering#17
Merged
Conversation
This refactors the `blockparty-iframe` block to use a server-side `render_callback` via the new `BlockRenderer` class. This approach ensures the iframe HTML is always generated on the server, providing greater control over attributes, sanitization, and future extensibility. Existing blocks will continue to render correctly due to the added `deprecated` save function.
This change excludes the 'composer.lock' file from version control and adds it to '.gitignore'. This is standard practice for libraries and plugins, allowing consuming projects to manage their own dependency versions without conflicts from locked versions within this package.
The codebase now consistently uses short array syntax (`[]`), replacing all instances of `array()`. This change is explicitly enforced by updating PHP_CodeSniffer and WPCS development dependencies to their latest stable versions, along with new rules in `phpcs.xml.dist`. Additionally, the `BlockRenderer::render` method's signature has been streamlined by removing the `$content` and `$block` parameters. This simplification leverages that `get_block_wrapper_attributes()` no longer requires these arguments when rendering dynamic blocks in modern WordPress, making the function's interface cleaner and more focused.
petitphp
approved these changes
Jun 23, 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.
This refactors the
blockparty-iframeblock to use a server-siderender_callbackvia the newBlockRendererclass.This approach ensures the iframe HTML is always generated on the server, providing greater control over attributes, sanitization, and future extensibility. Existing blocks will continue to render correctly due to the added
deprecatedsave function.Note
Medium Risk
Front-end iframe HTML now comes from PHP instead of saved block markup; behavior should match via deprecated save, but embed URL/attribute handling is security-relevant and worth regression-testing on existing content.
Overview
The iframe block no longer serializes markup in the editor save path; front output is produced by a PHP
render_callback(BlockRenderer::render) registered from the main plugin bootstrap, with i18n loading folded into the sameinithook.BlockRendererbuilds the wrapper and<iframe>from block attributes (url,title,lazyload, customiframeAttributes), escapes core fields, skips a fixed denylist for custom keys, and handles boolean iframe attributes. Missing URL or title yields an empty wrapped div.The previous
saveimplementation is kept only under adeprecatedblock definition so existing post content keeps validating while new saves are dynamic. Block registration is simplified to a singleregister_block_typeonbuild/blockparty-iframeinstead of the WordPress 6.7/6.8 blocks-manifest collection helpers.Composer gains PSR-4 autoload for
Blockparty\Iframe\→includes/, pins some dev tools, andcomposer.lockis gitignored. PHPCS now scansincludes/; npm wp-env scripts are renamed toenv:start/env:stop.Reviewed by Cursor Bugbot for commit a8ceb14. Bugbot is set up for automated code reviews on this repo. Configure here.