[wp-trac] [WordPress Trac] #63257: sanitize_term_field missing default $context value

WordPress Trac noreply at wordpress.org
Mon Nov 10 02:24:11 UTC 2025


#63257: sanitize_term_field missing default $context value
--------------------------+-----------------------
 Reporter:  dilipbheda    |       Owner:  audrasjb
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  7.0
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------
Changes (by wildworks):

 * keywords:  has-patch needs-unit-tests => has-patch
 * milestone:  6.9 => 7.0


Comment:

 > Just one quick question: if we add a default value, will it affect
 consumers who are already using the `"term_{$field}"` or
 `"{$taxonomy}_{$field}"` filters?
 >
 > For example, consumers may be using hooks such as the following:
 >
 > {{{
 > add_filter( 'term_name', function( $value, $term_id, $taxonomy, $context
 ) {
 >     if ( empty( $context ) ) {
 >         return 'something';
 >     }
 >     return $value;
 > }, 10, 4 );
 > }}}

 As I understand it, when `sanitize_term_field` is called without a
 context, the `$context` value passed to the above filter changes, which
 affects backward compatibility.

 I'm not sure why the `get_term_field()` and `sanitize_term()` functions
 have default values ​​while the `sanitize_term_field()` function doesn't,
 but further investigation is needed. Alternatively, it might be possible
 to close this as "wontfix".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63257#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list