-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Adds block supports for metadata #43986
Conversation
Just looking at what types of tests are best for this PR. |
Size Change: +1.18 kB (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
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.
Few nits, LGTM
Note this comment from @youknowriad on the parent PR. |
Co-authored-by: Ben Dwyer <ben@scruffian.com>
Is there any way to get metadata value from blocks in other pages, like metaboxes using meta key? |
@bikramchettri The metadata is unrelated to Post Meta. It is an attribute on the block itself. Therefore which ever editor the block ends up in it should still have the metadata associated with it. You can access the metadata roughly as follows: const support = getBlockSupport( blockType, '__experimentalMetadata' ); More detail shown in this PR. Be aware this is currently an experimental feature. |
What?
Spin off from/sub PR of #42605.
Adds block supports for block
metadata
.Why?
A use case for this is supplied in #42605. Essentially the need is to store data which is tied to the block instance. For example a custom name/label for the block.
How?
Registers new attribute.
Testing Instructions
Aim is to check that adding support in block.json will cause the block support to be truthy.
packages/block-library/src/group/block.json
and find thesupports
object.wp.data.select('core/blocks').getBlockSupport('core/group','__experimentalMetadata')
. It should betrue
.wp.data.select('core/blocks').getBlockSupport('core/paragraph','__experimentalMetadata')
. It should beundefined
.Screenshots or screencast