Skip to content

Move blocks to block API version 3 - #366

Merged
matiasqueroceballos merged 9 commits into
trunkfrom
feature/blocks-api-version-3
Dec 1, 2026
Merged

matiasqueroceballos merged 9 commits into
trunkfrom
feature/blocks-api-version-3

Conversation

@Castellon-ACM

@Castellon-ACM Castellon-ACM commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Moves every block FrontBlocks registers itself to block API version 3 (api_version => 3 in PHP / block.json and apiVersion: 3 in JS), one commit per block. Before this PR none of them declared a version (so they were v1), except Google Login, whose PHP/block.json already said 3 while its JS did not.

Block Change besides the version
before-after Editor CSS moved from enqueue_block_editor_assets to enqueue_block_assets (admin only), so it reaches the editor iframe
stacked-images same CSS move
reading-time version only
table-of-contents version only
user-text getComputedStyle(document.documentElement) now goes through the block root's ownerDocument (ref on useBlockProps)
insert-post version only (its jQuery UI autocomplete lives in the sidebar)
text-animation Preview mode had no useBlockProps root and lost its wrapper/selection, now wrapped; 6 document.createElement calls use el.ownerDocument; saved markup is identical to v1
product-categories Editor CSS move; registration args extracted into get_block_args() because registration is gated on WooCommerce and unit tests could not load it
google-login edit() output now has a useBlockProps root; the pre-5.5 fallback registration gets api_version 3; also fixes a 'signup' vs 'register' typo in the fallback preview

Extensions of core blocks (register_block_type_args, addFilter) are untouched.

Tests

  • A PHP test per block asserting api_version is 3, plus a CSS-hook test where the hook changed (new GoogleSignInTest).
  • Each block was run in a real editor (WordPress Playground + Playwright): getBlockType().apiVersion === 3, block root inside iframe[name="editor-canvas"], no page or console errors, publish and frontend render. Product Categories was run with WooCommerce and 3 categories; Google Login unconfigured and with a fake client id; Text Animation preview mode also checked.
  • phpcs and phpstan clean, JS tests pass.
  • Full PHP suite: 706 tests, 1 failure, CookieNoticeDeprecationNoticeTest (an action=install-plugin assertion). It fails the same way on trunk, so it is not caused by this PR.

Not verified / to check by hand

  • Classic themes and WordPress below 6.3.
  • The Playground WordPress iframes the editor even for older block versions, so the iframe check shows the v3 blocks work there, not that v1 would have failed.
  • User Text only renders on the frontend when FrontBlocks Pro instantiates it, so its frontend was checked through a test mu-plugin.
  • Compiled JS was rebuilt with the local Babel; frontblocks-toc-option.js has slightly different but equivalent helper functions for the props spread.
  • No changelog line: readme.txt has no Unreleased section (the top entry is the released 1.5.6).
Open WordPress Playground Preview

Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already used useBlockProps and ownerDocument, so no
editor JS change was needed beyond the version.

The editor stylesheet was enqueued on enqueue_block_editor_assets, which
does not reach the iframed canvas that API version 3 uses. It is now
enqueued on enqueue_block_assets (admin only), which WordPress mirrors
into the iframe.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already used useBlockProps and does not touch the
global document or window, so no editor JS change was needed beyond the
version.

The editor stylesheet was enqueued on enqueue_block_editor_assets, which
does not reach the iframed canvas that API version 3 uses. It is now
enqueued on enqueue_block_assets (admin only), which WordPress mirrors
into the iframe.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already used useBlockProps and does not touch the
global document or window, and the stylesheet is already enqueued on
enqueue_block_assets, so nothing else had to change.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already puts useBlockProps on its root nav, does not
touch the global document or window, and the stylesheet is already
enqueued on enqueue_block_assets, so nothing else had to change.

The compiled editor script was rebuilt with the local babel, which emits
different (equivalent) helper functions for the props spread.
Declare apiVersion 3 in the PHP registration and in registerBlockType.

The theme typography hints in the sidebar resolved CSS custom properties
with getComputedStyle( document.documentElement ), which is the wp-admin
document. The theme presets live inside the iframed canvas, so the
lookup now goes through the block root (a ref passed to useBlockProps)
and its ownerDocument.

The block's editor_style handle already reaches the iframe; a test now
covers it. The block is only instantiated by FrontBlocks Pro, so the
free plugin does not register it by itself.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already puts useBlockProps on its root. The jQuery UI
autocomplete is bound to the search field rendered in the inspector
sidebar (the wp-admin document, not the iframed canvas), so its script
and stylesheet on enqueue_block_editor_assets are still the right place
and nothing else had to change.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The saved markup is unchanged (the save function already uses
useBlockProps.save); a block serialized with API version 1 parses as
valid and re-serializes identically.

Editor fixes for the iframed canvas:
- While an animation preview is shown the edit output had no root
  carrying the block props (API version 1 added the wrapper by itself),
  so the block lost its wrapper, selection and toolbar. The preview is
  now wrapped in an element that gets the useBlockProps props.
- The terminal, block, random reveal and shuffle previews created their
  nodes with the global document.createElement; they now use the
  ownerDocument of the element they populate.

The stylesheet already reaches the iframe through the block editor_style.
Declare apiVersion 3 in the PHP registration and in registerBlockType.
The edit component already puts useBlockProps on its root and does not
touch the global document or window.

The editor stylesheet was enqueued on enqueue_block_editor_assets, which
does not reach the iframed canvas that API version 3 uses. It is now
enqueued on enqueue_block_assets (admin only), which WordPress mirrors
into the iframe.

The registration arguments moved into get_block_args() so they can be
asserted without WooCommerce, which the registration is gated on and the
unit tests do not load.
block.json already declared apiVersion 3, but the editor script, which is
hand-written (no build step), did not: it registered the block without a
version and its edit output had no root carrying useBlockProps, which
API version 3 requires. The edit output is now wrapped in an element that
gets the block props, and registerBlockType declares apiVersion 3.

The pre-5.5 fallback registration in PHP also declares api_version 3 so
both registration paths agree. The fallback preview checked for a "signup"
mode that does not exist (the attribute value is "register"); fixed while
touching it.

Adds a unit test for the registration, which had none.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T08:34:12.920660Z
We couldn’t complete this review. Comment @codex review to try again.
1c303b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@matiasqueroceballos
matiasqueroceballos merged commit cc4825a into trunk Dec 1, 2026
9 of 10 checks passed
@matiasqueroceballos
matiasqueroceballos deleted the feature/blocks-api-version-3 branch December 1, 2026 09:30
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