-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Run registerBlockType hook over deprecated settings #16348
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
Conversation
|
Not sure this is the right thing to do as it might have undesired consequences for other implementors of this filter (e.g. for plugins). |
| ], | ||
| }; | ||
|
|
||
| addFilter( 'blocks.registerBlockType', 'core/blocks/without-title', ( settings ) => { |
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.
Should we remove the filter after the test to ensure it doesn't mess with other tests?
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.
It's already handled in an afterEach on line 317.
Might be worth doing a look over keyword matches from the plugin repository using wpdirectory.net. Example: https://wpdirectory.net/search/01DESKYX62AMYKSZE8KJ5FBQKF |
Thanks for the link @aduth. It mostly looks ok, there's quite a bit of minified code, though. There were a couple of plugins that use the filter to completely replace/enhance a block. For example, Jetpack: This change would result in a bunch of properties being added to the deprecated settings that would go unused ( Will also add an issue for Jetpack on how they're setting that deprecated value. If the video block is deprecated in core, that could cause some issues! |
|
Let's ship this. The plugin releases will allow us to detect any potential issue with it we might have missed. |
|
👍 |
Description
Alternative attempt to fix #16328. Unfinished and unlikely to be the right fix, but this PR should hopefully generate some discussion about the right way to fix the issue.
Background
After some digging into the above issue, I discovered that the
supportssettings for blocks relies on theregisterBlockTypefilter. This filter adds an extraanchorattribute to blocks that support anchors.Unfortunately the
registerBlockTypefilter only runs on the main block settings, not deprecated block settings. When falling back to an older deprecation the attribute is not present and is never sourced from the HTML. In the case reported in the related issue, this caused a validation issue.Other
supportssettings (e.g. align) also don't work with deprecations, but don't cause validation issues sincedata-attributes are ignored by the validator.The fix here is to also run the
registerBlockTypefilter over each object in the deprecation array.How has this been tested?
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: