Make WordPress Core

Opened 14 months ago

Last modified 5 weeks ago

#62791 new enhancement

Could `pre_render_block` come later

Reported by: helgatheviking's profile helgatheviking Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch
Focuses: Cc:

Description (last modified by sabernhardt)

In the course of some investigations, I noticed that `pre_render_block` comes before `render_block_data` and `render_block_context`

This means I am not able to conditionally use pre_render_block with conditions based on either block context or programmatically added attributes. This seems limiting. (or at least it is in my current project, where I am trying to modify an existing block when it's part of my block - using my block's context)

Could pre_render_block come before actual rendering, but after these other filters? Or could we add another filter at the beginning of `render()`?

Change History (2)

#1 @sabernhardt
14 months ago

  • Component changed from General to Editor
  • Description modified (diff)

This ticket was mentioned in PR #10845 on WordPress/wordpress-develop by @niravsherasiya7707.


5 weeks ago
#2

  • Keywords has-patch added

Core Trac Ticket: https://core.trac.wordpress.org/ticket/62791


Adds a new pre_render_block_output filter that allows short-circuiting block rendering after context and data processing has been completed.

  • Adds pre_render_block_output filter after render_block_context and WP_Block instantiation
  • Receives the complete WP_Block instance with processed context and attributes
  • Allows returning custom markup to bypass default rendering
  • Maintains backward compatibility with existing filters
Note: See TracTickets for help on using tickets.