[wp-trac] [WordPress Trac] #64118: `WP_Block_Type::render` doesn’t pass block instance argument to render_callback
WordPress Trac
noreply at wordpress.org
Mon Oct 20 13:25:06 UTC 2025
#64118: `WP_Block_Type::render` doesn’t pass block instance argument to
render_callback
-----------------------------+------------------------------
Reporter: Bernhard Reiter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by Bernhard Reiter):
Blocks with render callbacks that require the `WP_Block` instance argument
fortunately seem to be the exception rather than the rule. However, we
should probably try to make `WP_Block_Type::render()` work for them
regardless.
One way to do so would be to create a `WP_Block` instance on the fly. This
would however also require parsing the block `$content`. If done
unconditionally -- i.e. even when a `WP_Block` instance isn't needed --
this could impact performance rather negatively.
To remediate that, we could probably use PHP's introspection features to
check how many arguments the `render_callback` expects. Although that's
also not exactly elegant...
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64118#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list