在WordPress中将导出按钮和功能添加到自定义帖子类型

I'm trying to build a custom plugin that allows users to edit templates and export as HTML.

I need help with the following:

  1. a button that initiates an export function
  2. a listener that waits for the button to be pressed
  3. a dummy export function that does something simple (e.g. downloads a blank text file)

I've setup the templates as a custom post type and added meta boxes using the Metabox plugin.

I've tried adding an additional meta box which acts as a button, but instead of directing the user to the &submit=true, it updates the post.

Here is the code:

function add_export_meta_box(){

add_meta_box('peg-export', 'Export', 'export_meta_box', 'email-template', 'side', 'low');}

add_action('add_meta_boxes', 'add_export_meta_box'); 

function export_meta_box()
{?>
<form method="post" enctype="application/x-www-form-urlencoded" action="?page=<?php echo $_GET['page']?>&export=true">
    <input type="hidden" name="export" value="1">
    <input type="submit" class="button button-primary button-large" value="Export Template" id="export-template"/>

</form>
<?php }

Once the button is successfully working, I'm unsure how to get the page to download the template inside the browser.

I'm a little out of my depth here, so I'd appreciate any help.

Muchos gracias, :)