I'm trying to pass a nonce at the links created from my plugin using add_menu_page
and add_submenu_page
.
Of course this is invalid:
add_submenu_page(
'my_dashboard',
'Dashboard',
'Dashboard',
'manage_options',
'my_dashboard&nonce-field=' . wp_create_nonce('my_action'),
'show_dashboard'
);
as per the Codex, the slug should only include lowercase alphanumeric, dashes, and underscores characters.
So my question is, how could we pass nonce in the URL of the menu links a plugin creates?
check_admin_referer()
or withwp_verify_nonce()
, at the body of theshow_dashboard
function, but to do that, I must pass a nonce field at the initial URL.$_GET
variable inside theshow_dashboard
function, so if I don't have nonce verification, it would produce an error of the WordPress Code Standards.$_GET
? After submitting a form? In that case you're supposed to use a nonce field in the form so that it gets added to the URL when you submit.$_GET
parameters inside the function to be called to output the content for this page, because this specific page is used for many stages at the plugin, so I have to check the$_GET
parameters to check at what stage I'm currently at.