[wp-trac] [WordPress Trac] #46004: Allow actions based on blocks in the current content

WordPress Trac noreply at wordpress.org
Sun Jan 20 23:50:19 UTC 2019


#46004: Allow actions based on blocks in the current content
------------------------------------+------------------------------
 Reporter:  joostdevalk             |       Owner:  (none)
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Bootstrap/Load          |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------

Comment (by birgire):

 That sounds interesting.

 Few things come to mind:

 This would mean doing the block parsing twice on the singular post
 content, on each page load, since the other {{{parse_blocks()}}} is in
 {{{do_blocks()}}}. I've not profiled {{{parse_blocks()}}} but I wonder how
 it scales with the size of the post content?

 Blocks can be removed dynamically from the post content, e.g. via the
 {{{render_block}}} filter, so in that case there might be some mismatch
 regarding what blocks are actually displayed on the page and what blocks
 are seen within the {{{parsed_blocks}}} action.

 I also wonder if {{{has_blocks()}}} would be useful as a pre condition or
 e.g. as a second input argument available for {{{parsed_blocks}}} action
 callbacks. I can imagine in some cases it would be helpful to know if
 there are no blocks at all.

 If {{{get_post_content()}}} is used, then one would need to handle cases
 like when:
 - the post content is password protected
 - the post content is split up into sub-pages e.g. with {{{<!--
 nextpage-->}}}
 - ...

 I would also think having use cases would help to better understand the
 need for such an action and what's needed to implement it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46004#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list