close
Skip to content

Bug: add_action() used instead of add_filter() for get_block_type_variations #76296

@apermo

Description

@apermo

Description

In packages/block-library/src/navigation-link/index.php at line 488, add_action() is used to register a callback on the get_block_type_variations hook:

add_action( 'get_block_type_variations', 'block_core_navigation_link_filter_variations', 10, 2 );

However, this hook is fired with apply_filters() in wp-includes/class-wp-block-type.php:616, making it a filter — not an action.

Gutenberg's own documentation already shows the correct usage (docs/reference-guides/block-api/block-variations.md:90):

add_filter( 'get_block_type_variations', 'my_custom_image_variation', 10, 2 );

Step-by-step reproduction

N/A — functionally equivalent since add_action() calls add_filter() internally, but semantically incorrect.

Expected behavior

Should use add_filter() to match the hook type.

Current behavior

Uses add_action() for a hook fired via apply_filters().

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions