How can I find out what section each input is in when viewing the $input
array passed to the sanitize_callback function defined in register_setting()
?
I suppose one option is to include the section as part of the field name and can then extract it. E.g. name="section^field"
and then in the sanitize_callback:
foreach($input as $name => $val) {
$parts = explode('^', $name);
$section = $parts[0];
$field = $parts[1];
// do more stuff here
}
But this feels a little hacky. Is there a better way?