Skip to content

feat: convert iframe block to dynamic server-side rendering#17

Merged
firestar300 merged 4 commits into
developfrom
feature/dynamic-block
Jun 23, 2026
Merged

feat: convert iframe block to dynamic server-side rendering#17
firestar300 merged 4 commits into
developfrom
feature/dynamic-block

Conversation

@firestar300

@firestar300 firestar300 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

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.


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 same init hook.

BlockRenderer builds the wrapper and <iframe> from block attributes (url, title, lazyload, custom iframeAttributes), 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 save implementation is kept only under a deprecated block definition so existing post content keeps validating while new saves are dynamic. Block registration is simplified to a single register_block_type on build/blockparty-iframe instead of the WordPress 6.7/6.8 blocks-manifest collection helpers.

Composer gains PSR-4 autoload for Blockparty\Iframe\includes/, pins some dev tools, and composer.lock is gitignored. PHPCS now scans includes/; npm wp-env scripts are renamed to env:start / env:stop.

Reviewed by Cursor Bugbot for commit a8ceb14. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@firestar300 firestar300 requested a review from petitphp June 23, 2026 11:35
@firestar300 firestar300 merged commit 0f7901c into develop Jun 23, 2026
3 checks passed
@firestar300 firestar300 deleted the feature/dynamic-block branch June 23, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants