Skip to content

chore: fix hook registration type mismatches#11204

Closed
apermo wants to merge 3 commits intoWordPress:trunkfrom
apermo:fix/hook-registration-mismatches
Closed

chore: fix hook registration type mismatches#11204
apermo wants to merge 3 commits intoWordPress:trunkfrom
apermo:fix/hook-registration-mismatches

Conversation

@apermo
Copy link
Copy Markdown

@apermo apermo commented Mar 8, 2026

Summary

Fixes 3 cases where hooks are registered with the wrong function — add_action() used on a filter or add_filter() used on an action. Functionally equivalent (since add_action() calls add_filter() internally), but semantically incorrect.

add_filter()add_action() (hook is fired via do_action()):

  • admin_print_styles in wp-admin/includes/admin-filters.php
  • login_head in wp-includes/default-filters.php

add_action()add_filter() (hook is fired via apply_filters()):

  • use_block_editor_for_post_type in wp-admin/includes/admin-filters.php

A 4th mismatch (get_block_type_variations using add_action() on a filter) originates in the Gutenberg repo and is tracked separately: WordPress/gutenberg#76296

For detailed investigation notes, see: https://github.com/apermo/wordpress-develop/milestone/4

Trac ticket: https://core.trac.wordpress.org/ticket/64828

Use of AI Tools

Research (systematic cross-referencing of all add_action/add_filter registrations against their do_action/apply_filters call sites) and code were produced by Claude Code (claude-sonnet-4-6). The contributor reviewed the findings, verified each fix, and approved the final implementation.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props apermo.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

apermo added 3 commits March 8, 2026 16:51
Change add_filter() to add_action() for the
admin_print_styles hook which is fired via do_action().

Related to https://core.trac.wordpress.org/ticket/64828
Change add_filter() to add_action() for the
login_head hook which is fired via do_action().

Related to https://core.trac.wordpress.org/ticket/64828
Change add_action() to add_filter() for the
use_block_editor_for_post_type hook which is fired
via apply_filters().

Related to https://core.trac.wordpress.org/ticket/64828
@apermo apermo force-pushed the fix/hook-registration-mismatches branch from 26fec3b to d89ccf8 Compare March 8, 2026 15:51
@apermo apermo changed the title Docs: fix hook registration type mismatches chore: fix hook registration type mismatches Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61866
GitHub commit: 56a6768

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant