I managed to add delete button this way, it also may be used to add any extra submit button.
Create a submit button with name and array attribute:
function mw_options_wc_order_attachement_1()
{
?>
<input type="file" name="mw_options_wc_order_attachement_1" id="mw_options_wc_order_attachement_1" value="<?php echo get_option('mw_options_wc_order_attachement_1'); ?>" />
<?php echo get_option("mw_options_wc_order_attachement_1"); ?>
<input type="submit" name="submit[delete_attachment_1]" class="button button-primary" value="Delete" />
<?php
}
Register setting with callback function, mw_options_wc_order_attachement_1_handle
is the name of the function in my case.
register_setting("mw_options", "mw_options_wc_order_attachement_1", "mw_options_wc_order_attachement_1_handle");
Make the callback function something like this:
function mw_options_wc_order_attachement_1_handle($options)
{
if (isset($_POST["submit"]))
{
$submit_button = $_POST["submit"];
if (isset($submit_button["delete_attachment_1"]))
{
// delete file
wp_delete_file('YOUR-FILE-SERVER-PATH');
return ''; // returns empty option value to settings
}
}
}