Unable to access block context for conditional rendering at pre_render_block filter #68665
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
pre_render_block
happens before you have access torender_block_context
context or any modifications to the block viarender_block_data
. This makes it really difficult to conditionally modify thepre_render_block
... for example if a certain context exists, return apre_render_block
and if not, allow for default rendering.As far as I can tell,
pre_render_block
output also does not go through therender_block_${blockname}
filter either... which maybe is off-track here.Is there no way to conditioning alter the pre render based on context without waiting until after it's been entirely rendered (ie:
render_block_${blockname}
filter)?What is your proposed solution?
I think there's benefit in re-ordering these hooks so that
pre_render_block
comes afterrender_block_context
andrender_block_data
... perhaps even as late as the beginning ofWP_Block
srender()
method itself.Sorry to turn this support-ish, but if there's no path forward for the above what would be the recommendation to conditionally alter the
pre_render_block
return value?The text was updated successfully, but these errors were encountered: