Skip to content
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

Provide context when blocks.registerBlockType is applied to deprecations #36628

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/filters/block-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ register_block_type( __DIR__ );

### `blocks.registerBlockType`

Used to filter the block settings when registering the block on the client with JavaScript. It receives the block settings and the name of the registered block as arguments. This filter is also applied to each of a block's deprecated settings.
Used to filter the block settings when registering the block on the client with JavaScript. It receives the block settings, the name of the registered block, and either null or the deprecated block settings (when applied to a registered deprecation) as arguments. This filter is also applied to each of a block's deprecated settings.

_Example:_

Expand Down
6 changes: 4 additions & 2 deletions packages/blocks/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const processBlockType = ( blockType, { select } ) => {
const settings = applyFilters(
'blocks.registerBlockType',
{ ...blockType },
name
name,
null
);

if ( settings.deprecated ) {
Expand All @@ -64,7 +65,8 @@ const processBlockType = ( blockType, { select } ) => {
...omit( blockType, DEPRECATED_ENTRY_KEYS ),
...deprecation,
},
name
name,
deprecation
),
DEPRECATED_ENTRY_KEYS
)
Expand Down