hope everyone is doing good! How can I have a single sanitization callback for multiple fields?
Here is my code
add_action('admin_init','settings');
function settings(){
add_settings_section('menu_first_section',null,null,'plugin-menu');
add_settings_field('field_1','Field 1','field_1_html','plugin-menu','menu_first_section');
register_setting('option_group_1','field_1',array('sanitize_callback' => 'sanitize_one','default'=> ''));
add_settings_field('field_2','Field 2','field_2_html','plugin-menu','menu_first_section');
register_setting('option_group_2','field_2',array('sanitize_callback' => 'sanitize_two','default'=> ''));
}
function sanitize_one($input) {
// validation
}
function sanitize_two($input) {
// validation
}
How can I have a single sanitization callback for multiple fields and then access the values of it ($input)?