[wp-trac] [WordPress Trac] #53233: Editor: Extend `register_block_type` to accept the path file or folder with `block.json`

WordPress Trac noreply at wordpress.org
Thu Jun 10 10:11:09 UTC 2021


#53233: Editor: Extend `register_block_type` to accept the path file or folder with
`block.json`
-----------------------------------------------------+---------------------
 Reporter:  gziolo                                   |       Owner:  gziolo
     Type:  enhancement                              |      Status:  closed
 Priority:  normal                                   |   Milestone:  5.8
Component:  Editor                                   |     Version:  trunk
 Severity:  normal                                   |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-dev-note  |     Focuses:
-----------------------------------------------------+---------------------

Comment (by gziolo):

 @Clorith, let me clarify some decisions made so far and the rationale
 behind them.

 `register_block_type_from_metadata` is here to stay for backward
 compatibility for the time being. It's now used internally by
 `register_block_type` so both approaches work just fine. The latter is
 just shorter and it will simplify documentation efforts. The goal now is
 to promote usage of `register_block_type` together with `block.json` file
 in the WordPress context. I'm working on the dev note that is going to
 highlight the benefits that block following that approach will get now and
 how we see it evolving in the future. We could deprecate
 `register_block_type_from_metadata` but at this stage, it will only create
 friction for existing blocks that already opted for using `block.json` as
 you correctly identified it. I guess we can do it in the future but I
 would rather focus on promoting good practices in the official learning
 materials.

 In the Gutenberg plugin, there is `registerBlockTypeFromMetadata` function
 that is already deprecated but we plan to remove it in a few weeks, and it
 existed temporarily for use cases outside of WordPress core - mostly for
 bridging handling in the native mobile apps.

 I share your sentiment that the process isn't ideal, but it was a long
 process to implement all features necessary for block registration using
 `block.json` file that will open us new ways to optimize the rendering of
 the block in the editor and on the frontend - conditional loading of
 styles for rendered blocks coming in WP 5.8 is one of the best examples so
 far.

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


More information about the wp-trac mailing list