[wp-trac] [WordPress Trac] #50263: Editor: Introduce new API method that register block from `block.json` metadata file

WordPress Trac noreply at wordpress.org
Wed May 27 09:52:31 UTC 2020


#50263: Editor: Introduce new API method that register block from `block.json`
metadata file
-------------------------+--------------------
 Reporter:  gziolo       |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  5.5
Component:  Editor       |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+--------------------
 Now that we are close to be able to expose all block with the new REST API
 endpoint as proposed in https://github.com/WordPress/gutenberg/pull/21065
 (#47620), the next step is to make it easier to register blocks on the
 server.

 The initial implementation was proposed in
 https://github.com/WordPress/gutenberg/pull/20794.

 It's still being worked on in
 https://github.com/WordPress/gutenberg/pull/22519 where Extend
 `register_block_type_from_metadata` to handle assets.

 There is also a related task #49615 that proposes
 `register_block_type_args` filter and might help improve the general
 experience when registering a block.

 This is how the current interface looks like:

 {{{#!php
 <?php
 /**
  * Registers a block type from metadata stored in the `block.json` file.
  *
  * @since 5.5.0
  *
  * @param string $file_or_folder Path to the JSON file with metadata
 definition for
  *     the block or path to the folder where the `block.json` file is
 located.
  * @param array  $args {
  *     Optional. Array of block type arguments. Any arguments may be
 defined, however the
  *     ones described below are supported by default. Default empty array.
  *
  *     @type callable $render_callback Callback used to render blocks of
 this block type.
  * }
  * @return WP_Block_Type|false The registered block type on success, or
 false on failure.
  */
 function register_block_type_from_metadata( $file_or_folder, $args =
 array() )
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50263>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list