Not 100% sure if this one classes as a php question or is specifically Wordpress...
I'm implementing the Wordpress Settings API with a tabbed settings page. I've added a 'reset tab' button, but since the validation is done on a separate page (options.php) I can't seem to figure out which tab I'm on - without adding the tab as a hidden field, which I want to avoid.
I've found the wp_get_referer() function, but that gives me the full URL - I'm not sure how to pull the tab=tab1 out as a variable.
Update - Answer:
$url = parse_url(wp_get_referer());
parse_str($url['query'], $path);
$tab = $path['tab'];
As said in the answers, some validation is then required.
wordpress/wp-admin/options-general.php?page=967slug_settings_page&tab=tab3(notice the tab parameter) The settings_API then submits the form tooptions.php(Wordpress core) which then calls a validation function (written by me). I'm trying to get the value of the tab parameter within the validation function. The wordpress functionwp_get_referer()gives me the full URL (URI?) - exactly as above - but I'm not sure how to extract the value of 'tab' from that. – Jamie Wright Feb 4 at 16:41