-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block API: Extend register_block_type_from_metadata
to handle assets
#22519
Conversation
Size Change: 0 B Total Size: 1.12 MB ℹ️ View Unchanged
|
register_block_type_from_metadata
to handle assetsregister_block_type_from_metadata
to handle assets
6e7e665
to
b86a456
Compare
1c5e7c5
to
9f70451
Compare
7a1b936
to
551a4bc
Compare
I think I added enough tests to ensure it works as expected. Let me know if there are any blockers that would prevent moving forward with this proposal. |
I don't see any more feedback, then let's proceed. We can iterate further later if there are some things discovered. We still need to add functionality that covers i18n handling for the metadata stored in |
@gziolo I think this broke the post content block. Before this commit there is no issue, but after this commit, the post title and post content blocks do not work. It appears to be related to block context not being set properly 🤔 (Trying to see what would have changed that!) |
see #23179 |
$settings = array(); | ||
$property_mappings = array( | ||
'title' => 'title', | ||
'category' => 'category', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix was just to add a property for context
here. see #23180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add providesContext
there.
…` metadata file Backports changes added to Gutenberg in: - WordPress/gutenberg#20794 - WordPress/gutenberg#22519 `register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files. Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen. Fixes #50263. git-svn-id: https://develop.svn.wordpress.org/trunk@48141 602fd350-edb4-49c9-b593-d223f7449a82
…` metadata file Backports changes added to Gutenberg in: - WordPress/gutenberg#20794 - WordPress/gutenberg#22519 `register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files. Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen. Fixes #50263. git-svn-id: https://develop.svn.wordpress.org/trunk@48141 602fd350-edb4-49c9-b593-d223f7449a82
…` metadata file Backports changes added to Gutenberg in: - WordPress/gutenberg#20794 - WordPress/gutenberg#22519 `register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files. Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen. Fixes #50263. Built from https://develop.svn.wordpress.org/trunk@48141 git-svn-id: http://core.svn.wordpress.org/trunk@47910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…` metadata file Backports changes added to Gutenberg in: - WordPress/gutenberg#20794 - WordPress/gutenberg#22519 `register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files. Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen. Fixes #50263. Built from https://develop.svn.wordpress.org/trunk@48141 git-svn-id: https://core.svn.wordpress.org/trunk@47910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…` metadata file Backports changes added to Gutenberg in: - WordPress/gutenberg#20794 - WordPress/gutenberg#22519 `register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files. Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen. Fixes #50263. git-svn-id: https://develop.svn.wordpress.org/trunk@48141 602fd350-edb4-49c9-b593-d223f7449a82
Description
The changes in this PR follow the solution proposed in Block Registration RFC:
https://github.com/WordPress/gutenberg/blob/master/docs/rfc/block-registration.md#assets
Motivation
npm init @wordpress/block
creates a lot of boilerplate code in PHP file to load a single block. This is a way to simplify it to a single function call in the init hook:In the future, it should make it possible to use
block.json
as an entry point for blocks crafted to be included in Block Directory!Testing
I personally did the following steps to test this PR. I executed Create Block to have a block to play with all the defaults:
I moved then this folder to
lib
folder to make it simple to include.I added the following
block.json
file insidelib/esnext-example
I replaced
lib/esnext-example/esnext-example.php
with:And I made sure it's required in
lib/load.php
.I made sure that I can insert this block and inspected source code to confirm it properly generates in the codebase the HTML tags for assets like:
Follow up tasks
register_block_type_from_metadata
to handle assets #22519 (comment)Checklist: