Opened 5 days ago
Closed 5 days ago
#64828 closed defect (bug) (fixed)
add_filter() used on actions and add_action() used on filters in core
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description
Three cases in core where hooks are registered with the wrong function:
add_filter( 'admin_print_styles', ... )inwp-admin/includes/admin-filters.php:56— hook fires viado_action()add_filter( 'login_head', ... )inwp-includes/default-filters.php:388— hook fires viado_action()add_action( 'use_block_editor_for_post_type', ... )inwp-admin/includes/admin-filters.php:88— hook fires viaapply_filters()
A 4th case (get_block_type_variations) originates in Gutenberg: https://github.com/WordPress/gutenberg/issues/76296
Functionally equivalent since add_action() calls add_filter() internally, but semantically incorrect.
Found while working on #64224 (docblock improvements). Related to #64238 (PHPStan catchall).
PR: https://github.com/WordPress/wordpress-develop/pull/11204
Change History (3)
This ticket was mentioned in PR #11204 on WordPress/wordpress-develop by @apermo.
5 days ago
#1
Note: See
TracTickets for help on using
tickets.
## Summary
Fixes 3 cases where hooks are registered with the wrong function —
add_action()used on a filter oradd_filter()used on an action. Functionally equivalent (sinceadd_action()callsadd_filter()internally), but semantically incorrect.###
add_filter()→add_action()(hook is fired viado_action()):admin_print_stylesinwp-admin/includes/admin-filters.phplogin_headinwp-includes/default-filters.php###
add_action()→add_filter()(hook is fired viaapply_filters()):use_block_editor_for_post_typeinwp-admin/includes/admin-filters.phpA 4th mismatch (
get_block_type_variationsusingadd_action()on a filter) originates in the Gutenberg repo and is tracked separately: https://github.com/WordPress/gutenberg/issues/76296For detailed investigation notes, see: https://github.com/apermo/wordpress-develop/milestone/4
## Use of AI Tools
Research (systematic cross-referencing of all
add_action/add_filterregistrations against theirdo_action/apply_filterscall 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.