[wp-trac] [WordPress Trac] #49615: Editor: Support filtering arguments in block type registration

WordPress Trac noreply at wordpress.org
Thu Mar 12 08:48:23 UTC 2020


#49615: Editor: Support filtering arguments in block type registration
-------------------------+------------------------------
 Reporter:  aduth        |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Editor       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by gziolo):

 The nice side-effect of using `register_post_type_args` is the use case
 where you could set `render_callback` using this filter and automate the
 block registration using some sort of `block.json` detection from one
 central place. If you combine it with the new utility function
 `register_block_type_from_metadata` I propose in
 https://github.com/WordPress/gutenberg/pull/20794, you could simplify the
 block registration to running a loop over the list of locations with
 `block.json` file or even provide another filter that stores the list of
 such locations. This way, we could avoid the whole logic in Gutenberg that
 plays with action priorities to ensure that core blocks are successfully
 overridden in the plugin:
 https://github.com/WordPress/gutenberg/blob/e8c7e9768c5f4eed7d5dcc92c5592424f0a52f83/webpack.config.js#L139-L180

 Instead, it could be simplified to two things:
 - Gutenberg replaces the list of locations for core blocks
 - Gutenberg register filters that override `render_callback` for core
 blocks (well, here the priority might be still an issue as it's the same
 code)

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


More information about the wp-trac mailing list