Make WordPress Core

Opened 6 years ago

Last modified 9 months ago

#45085 new enhancement

different args passed to "term_name" and "term_{$field}" filters

Reported by: pbiron's profile pbiron Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: docs, administration Cc:


In /wp-admin/edit-tags.php, for each row in the WP_Term_List_Table, both term_name and term_{$field} (with $field == 'name') get applied before the term's name is displayed in the table.

As far as I can tell, there is no way to hook into term_name without also hooking into term_{$field} (when $field == 'name').

When term_name is applied, the 2nd argument is a WP_Term object; when term_{$field} (when $field == 'name') is applied, the 2nd argument is an int (term_id).

Given that both of these filters have been around for many years, I don't think it would be a good idea to change either one of them so that their argument lists were the same. However, I think it would be a good idea to add some explanation of this conflict in the DocBlocks of both filters.

Of course, I could add comments to both entries in the Code Reference, but I think it would be much better if that explanation were in the DocBlocks.

Change History (2)

#1 @pbiron
6 years ago

  • Type changed from defect (bug) to enhancement

#2 @w33zy
9 months ago

I ran into this issue today. It will become more prevalent as plugin developers start adding types to the functions and methods, so typing the second argument of the tern_name filter method with WP_Term will throw a type error in PHP 7.4.

Last edited 9 months ago by w33zy (previous) (diff)
Note: See TracTickets for help on using tickets.