[wp-trac] [WordPress Trac] #54684: Add ability to filter blocks in WP_Block_List

WordPress Trac noreply at wordpress.org
Mon Jan 3 17:44:17 UTC 2022

#54684: Add ability to filter blocks in WP_Block_List
 Reporter:  afragen      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  5.9
Component:  Menus        |     Version:  5.5
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  administration
Changes (by hellofromTonya):

 * type:  defect (bug) => enhancement


 Replying to [comment:6 afragen]:
 > There doesn't seem to be a equivalent filter in the navigation block as

 Looking at the code in `render_block_core_navigation()` within
 /block-library/src/navigation/index.php#L360 here in Gutenberg] and
 includes/blocks/navigation.php#L360 here in Core]), `WP_Block_List()` is
 invoked 3 times.

 @afragen if the goal is to gain access to the nav menu blocks, then
 wouldn't that goal be better served at the end of the
 `render_block_core_navigation()` function. Why? To get access to all of
 the nav blocks after processing and just before rendering?

 Else, the filter in `WP_Block_List::__construct()` will run each time its
 instantiated, whether it's a nav block or not. That adds time and memory,
 i.e. additional performance hits.

Ticket URL: <https://core.trac.wordpress.org/ticket/54684#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list