Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20804 closed defect (bug) (duplicate)

sanitize_option_* filter does not specify number of arguments

Reported by: chokladzingo's profile chokladzingo Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.4
Component: Administration Keywords: has-patch
Focuses: Cc:


register_setting() in wp-admin/includes/plugin.php adds a filter for each option registered. When this filter is later run by the sanitize_option() function the variables $value and $option are specified as arguments for the callback function. Since number of arguments ($accepted_args) was not specified when adding the filter in register_setting(), the $option argument is not supplied to the callback function.

This is simply fixed by supplying the $accepted_args argument to add_filter() in register_setting() and remove_filter() in unregister_setting().

Attachments (1)

sanitize_option.patch (785 bytes) - added by chokladzingo 12 years ago.

Download all attachments as: .zip

Change History (4)

#1 @chokladzingo
12 years ago

For some context: supplying the $option value to callback functions is desirable since it will allow plugin developers to use a single sanitize function for all of the settings, instead of a single function for each setting.

#2 @nacin
12 years ago

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

It's a good idea, but we've tried it, and there are some backwards compatibility concerns: #15335.

#3 @chokladzingo
12 years ago

Oh, that's very true. I guess the current_filter() workaround is an acceptable solution. Sorry about the duplicate, tried searching beforehand to no avail.

Note: See TracTickets for help on using tickets.