I have an options page for my plugin. I want the user to be able to click a button to execute a member function of my plugin's class. I found this page:
But I'm not sure if I am interpreting the instructions correctly. I found that creating a form with an action="options-general.php?page=MY_OPTIONS_PAGE_SLUG" will work. Like this:
<form method="post" action="options-general.php?page=my_options_page_slug">
<input type="hidden" name="banana" value="yellow">
<input type="submit" class="button-primary" value="<?php _e('Go') ?>" />
</form>
Is this what the stackoverflow article is recommending? Is this a decent way to do this? I am not ready to step into (the WP) AJAX just yet. I'm ok with a form and a page refresh.
Thanks for reading.
if( $_POST['banana'] == 'yellow' ){ $this->do_something(); }
. Will adding a nonce make this method reliable? I am still not sure if the link I provided in the OP meant something like this with the language, "POST that form to your plugin."