First of all I'm still relatively new to programming and wordpress development.
I'm building a plugin that takes custom data from database and a list of saved drafts and then modifies draft chosen by user, using that data. Right now it works like this:
- I added admin menu under Posts category using add_submenu_page(),
- On that page I created a dropdown menu using html select form that fetches list of drafts from database and displays it to user,
- I have a button next to dropdown menu that when you click it supposedly publishes post and modifies it using custom data from database.
My problem is that to accomplish this I would have to use POST and send all this stuff to another php page. I'd like to avoid this if possible because I want to keep this plugin simple and I'm not that comfortable with wordpress development.
What I want to know is if there's any other way to do this? Some sort of built-in wordpress action or hook that I can use to achieve this? Or is there any other simpler approach in general.
I've been considering also moving all of this to options and using Settings API and POSTing to options.php.
I appreciate any input.
Edit: Here's relevant code:
<div class="wrap">
<p>Select post:</p>
<form name="autogenerator">
<select id='drafts' name="drafts">
<?php foreach($keywords as $keyword) {
$post = get_post($keyword);
$title = $post->post_title;
echo "<option value=$keyword>$title</option>";
}?>
<input type="button" onClick="" value="Generate!">
</select>
</form>
</div>
$keywords is a list of posts id. I'd like to be able to pass this id to my button so that when it's clicked it runs another function that publishes selected post and modifies it using data from database.