[wp-trac] [WordPress Trac] #56865: $args taking effect too late in register_block_type_from_metadata

WordPress Trac noreply at wordpress.org
Thu Oct 20 07:00:20 UTC 2022


#56865: $args taking effect too late in register_block_type_from_metadata
--------------------------+-----------------------------
 Reporter:  aristath      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The `register_block_type_from_metadata` function accepts 2 arguments:
 * `$file_or_folder`
 * `$args`

 The `$file_or_folder` is a path the the `block.json` file, or the folder
 containing it. `$args` is an array of arguments that can be passed to the
 function in order to provide complimentary data.
 The problem right now is that `$args` are parsed too late: They get parsed
 after the scripts/styles have been registered, after all other
 calculations have been completed, right before we call
 `WP_Block_Type_Registry::get_instance()->register();`.
 The problem with the current approach is that `$args` are unable to
 register script/styles, or even be used to take part in all the processing
 that the `register_block_type_from_metadata` function does.
 As a side-effect, it's impossible to register a block by passing an array
 of arguments, without the presence of a `block.json` file.

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


More information about the wp-trac mailing list