[wp-trac] [WordPress Trac] #53149: Plugins: Consider using `block.json` file as an entry point for blocks from Block Directory
WordPress Trac
noreply at wordpress.org
Tue May 4 11:57:42 UTC 2021
#53149: Plugins: Consider using `block.json` file as an entry point for blocks from
Block Directory
-----------------------------+------------------------------
Reporter: gziolo | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Description changed by gziolo:
Old description:
> The original discussion sparked by a comment from @jipmoors on GitHub in
> https://github.com/WordPress/gutenberg/pull/13693#issuecomment-477904539:
>
> > WordPress automatically discovers all the block.json files in the
> plugin/core blocks folder and registers the corresponding block types.
> These block types are made available through the block registry
> (https://developer.wordpress.org/reference/classes/wp_block_type_registry/)
> PHP class, and the blocks scripts and styles are added as dependencies to
> the wp-block-library script and style handles.
>
> At the moment, it's mandatory to create the PHP file for the plugin that
> contains only a single block type registration code when developing for
> Block Directory. Those plugins rarely have PHP code, so we could simplify
> the flow for developers by making it possible to use `block.json` to
> source all required metadata. If the current metadata schema doesn't
> contain some fields that can be declared only in the PHP comment (some
> are duplicated in `readme.txt`, we can always include it in `block.json`.
>
> In the case when developers would like to use the `render_callback`, they
> could use the concept proposed in #53148 - the `renderCallback` file
> reference in `block.json`. This way, the process of validation of block
> types submitted to Block Directory would get further simplified.
New description:
The original discussion sparked by a comment from @jipmoors on GitHub in
https://github.com/WordPress/gutenberg/pull/13693#issuecomment-477904539:
> WordPress automatically discovers all the block.json files in the
plugin/core blocks folder and registers the corresponding block types.
These block types are made available through the block registry
(https://developer.wordpress.org/reference/classes/wp_block_type_registry/)
PHP class, and the blocks scripts and styles are added as dependencies to
the wp-block-library script and style handles.
At the moment, it's mandatory to create the PHP file for the plugin that
contains only a single block type registration code when developing for
Block Directory. Those plugins rarely have PHP code, so we could simplify
the flow for developers by making it possible to use `block.json` to
source all required metadata. If the current metadata schema doesn't
contain some fields that can be declared only in the PHP comment (some are
duplicated in `readme.txt`, we can always include it in `block.json`.
In the case when developers would like to use the `render_callback`, they
could use the concept proposed in #53148 - the `renderTemplate` file
reference in `block.json`. This way, the process of validation of block
types submitted to Block Directory would get further simplified.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53149#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list