Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access block context for conditional rendering at pre_render_block filter #68665

Open
helgatheviking opened this issue Jan 14, 2025 · 0 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.

Comments

@helgatheviking
Copy link
Contributor

What problem does this address?

pre_render_block happens before you have access to render_block_context context or any modifications to the block via render_block_data. This makes it really difficult to conditionally modify the pre_render_block... for example if a certain context exists, return a pre_render_block and if not, allow for default rendering.

As far as I can tell, pre_render_block output also does not go through the render_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 after render_block_context and render_block_data... perhaps even as late as the beginning of WP_Blocks render() 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?

@helgatheviking helgatheviking added the [Type] Enhancement A suggestion for improvement. label Jan 14, 2025
@Mamaduka Mamaduka added the [Feature] Block API API that allows to express the block paradigm. label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants