Currently I’m developing(well at least trying to;) plugin which will handle custom gallery of images. I stumbled upon one problem though. I’ll try to picture it.
I’ve created custom menu page on which I can edit gallery options as well as I can add/delete/edit elements of gallery. I did add link to every gallery item so after choosing ‘edit’ I could be able to modify element.
function column_rls_name($item) {
$actions = array(
'edit' => sprintf('<a href="?page=%s&action=%s&rls_element=%s">Edit</a>',$_REQUEST['page'],'edit',$item['rls_name']),
);
return sprintf('%1$s %2$s', $item['rls_name'], $this->row_actions($actions) );
}
Problem begins when ‘edit’ on element is clicked. It should redirect to settings page.
Here I have a question. What is the best way to do this. Are there any helper functions/hooks/etc out there which would help in creating such page (and detect redirection).
Of course I could do it in function responsible for displaying main gallery options like:
if($_GET['action']=='edit')
//then do sth
else
//display main gallery options
but I don’t think it’s the best way.
I would like to know which functions I could use, from creating custom link, creating custom page and registering them.
What method should be used when action=edit is triggered. How to spot it was requested on the actual page. How to show then page related to the content.
wp-admin/options-general.php?page=rls_logotypes&action=edit&rls_element=element1
Get the url of a specific admin page (e.g. the settings page (options-general.php)):
Codex admin_url()
Adding query arguments to an url:
Codex add_query_arg()
Put a and b together:
Now we can create links: