[wp-trac] [WordPress Trac] #61631: sanitize_option_{$option} inconsistencies

WordPress Trac noreply at wordpress.org
Thu Jul 11 10:39:37 UTC 2024


#61631: sanitize_option_{$option} inconsistencies
--------------------------------+-----------------------------
 Reporter:  liedekef            |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  6.5.5
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 There are several inconsistencies with the sanitize_option_{$option} doc
 and code:

 1) in the doc at
 https://developer.wordpress.org/reference/hooks/sanitize_option_option/
 ==> the example
 {{{
 add_filter('sanitize_option_contact_email', 'sanitize_email');
 }}}
 should be
 {{{
 add_filter('sanitize_option_contact_email', 'sanitize_email', 10, 2);
 }}}

 2) in the code wp-includes/option.php, the filter is created in the
 function "register_setting" but the option name is not passed, leaving
 people to jump through holes to create the correct filter.
 {{{
 add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback']
 );
 }}}
 should become
 {{{
 add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'],
 10, 2 );
 }}}
 (or even "10,3" since the the call to apply the filter always uses 3
 arguments). This doesn't affect any current usage of the filter (php
 ignores it if too many arguments are passed to a function) but would make
 the life of developers easier :-)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61631>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list