Why does the Settings API send those parameters when submitting the settings form?
Quite frankly, it doesn’t. As you already mentioned, your form simply POST’s to options.php
, which in turn handles the request, updates the database, and then redirects back to the referer.
How the referer is fetched is down to the function wp_get_referer()
;
function wp_get_referer() {
$ref="";
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
$ref = $_REQUEST['_wp_http_referer'];
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
$ref = $_SERVER['HTTP_REFERER'];
if ( $ref !== $_SERVER['REQUEST_URI'] )
return $ref;
return false;
}
That’s why you’re getting sent back to your options page with the action parameters still there – because they were present in $_SERVER['HTTP_REFERER']
.
But you’ll also see that you can override this behaviour, by placing a hidden input inside your form like so;
<input type="hidden" name="_wp_http_referer" value="<?php echo admin_url( 'options-general.php?page=wordpress-file-monitor-plus' ); ?>" />
Now options.php
will always redirect back to…
http://example.com/wp-admin/options-general.php?page=wordpress-file-monitor-plus
…regardless of whatever was in the query string previously.