[wp-trac] [WordPress Trac] #43629: Sanitize callback for setting should be passed the original value
WordPress Trac
noreply at wordpress.org
Sun Mar 25 09:31:12 UTC 2018
#43629: Sanitize callback for setting should be passed the original value
--------------------------------+-----------------------------
Reporter: seanleavey | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: trunk
Severity: normal | Keywords:
Focuses: administration |
--------------------------------+-----------------------------
The `sanitize_option` function in `wp-includes/formatting.php` passes the
option name and original value to the `sanitize_callback` specified in
`register_setting` in addition to the new value:
`return apply_filters( "sanitize_option_{$option}", $value, $option,
$original_value );`
([https://github.com/WordPress/WordPress/blob/4848a09b3593b639bd9c3ccfcd6038e90adf5866
/wp-includes/formatting.php#L4651 Source])
However, in the definition of the setting in `register_setting` (`wp-
includes/option.php`), the hook is added without specifying the number of
arguments the `sanitize_callback` callable takes:
`add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback']
);`
[https://github.com/WordPress/WordPress/blob/4848a09b3593b639bd9c3ccfcd6038e90adf5866
/wp-includes/option.php#L2114 Source]
Ideally, `register_setting` would take an argument in addition to
`sanitize_callback` that specifies the number of arguments supported by
the callable, and, I guess, also the priority, like any other filter that
gets added.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43629>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list