Opened 7 years ago
Closed 7 years ago
#43629 closed enhancement (duplicate)
Sanitize callback for setting should be passed the original value
Reported by: | seanleavey | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.1 |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | administration | Cc: |
Description
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 );
(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'] );
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.
I'm going to close this as a duplicate of #15335, which deals with the arguments passed to the
add_filter()
call.