Skip to content

Hooks: add_action() used for get_block_type_variations filter #33

Closed

Description

@apermo

Problem

In wp-includes/blocks/navigation-link.php at line 488, add_action() is used to register a callback on the get_block_type_variations hook, but this hook is fired with apply_filters() — making it a filter, not an action.

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

Where the hook fires

  • src/wp-includes/class-wp-block-type.php:616 — apply_filters( 'get_block_type_variations', ... )

The PHPDoc at line 613 documents this as a filter with @param tags for return value filtering.

Fix

Change add_action() to add_filter().

Related to https://core.trac.wordpress.org/ticket/64224

Activity

  1. apermo commented on Mar 8, 2026

    @apermo
    OwnerAuthor

    Upstream origin

    This originates in the Gutenberg repo at packages/block-library/src/navigation-link/index.php:488. The same add_action() call is synced to core during Gutenberg merges.

    Interestingly, Gutenberg's own documentation (docs/reference-guides/block-api/block-variations.md:90) correctly shows add_filter():

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

    The fix should go through WordPress/gutenberg first, then sync to core.

  2. apermo commented on Mar 8, 2026

    @apermo
    OwnerAuthor

    WordPress/gutenberg#76296 fix happens there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions