Make WordPress Core

Opened 3 months ago

Last modified 2 months ago

#48104 new enhancement

Add the gutenberg_provide_render_callback_with_block_object shim to core

Reported by: andraganescu Owned by:
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch needs-testing needs-dev-note needs-docs
Focuses: Cc:
PR Number:

Description (last modified by andraganescu)

Part of making the navigation block dynamic was adding a new filter at pre_render_block which enhances the way blocks are passed to the server render callback by passing render_callback the block object as the argument.

We should to update WP Core with these changes and remove them from the Gutenberg compat lib https://github.com/WordPress/gutenberg/blob/95e769df1f82f6b0ef587d81af65dd2f48cd1c38/lib/compat.php#L33

Attachments (1)

48104.diff (1.5 KB) - added by andraganescu 3 months ago.

Download all attachments as: .zip

Change History (7)

#1 @andraganescu
3 months ago

  • Description modified (diff)

#2 @andraganescu
3 months ago

  • Description modified (diff)

3 months ago

#3 @andraganescu
3 months ago

So the shim in Gutenberg compat.php only sends $block to the render method of WP_Block_Type. 48104.diff adds this to render_block and an argument to the render method of WP_Block_Type.

#4 @andraganescu
3 months ago

  • Keywords has-patch needs-testing needs-dev-note needs-docs added; needs-patch removed

#5 @youknowriad
3 months ago

  • Milestone changed from 5.3 to 5.4

#6 @noisysocks
2 months ago

48104.diff looks good to me. I wonder, though, if we should move away from giving third parties the raw block array and instead create a WP_Block class to encapsulate that data. This would make the API nicer (e.g. $block->attributes instead of $block['attrs']), and would help developers avoid nasty surprises like default block attributes not being set. We could consider updating parse_blocks() to also return WP_Block.

What do you think?

At any rate, since this isn't needed for 5.3, let's punt on this for now and focus on landing it when trunk opens for 5.4.

Note: See TracTickets for help on using tickets.