WordPress.org

Make WordPress Core

#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:
PR Number:

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

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.

Change History (1)

#1 @peterwilsoncc
20 months 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.