Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#43629 closed enhancement (duplicate)

Sanitize callback for setting should be passed the original value

Reported by: seanleavey's profile seanleavey Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Options, Meta APIs Keywords:
Focuses: administration Cc:


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 );


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.

Change History (1)

#1 @peterwilsoncc
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I'm going to close this as a duplicate of #15335, which deals with the arguments passed to the add_filter() call.

Note: See TracTickets for help on using tickets.