I have created a download link for my plugin using add_submenu_page. When the link is clicked it gathers some files into a zip, then outputs the contents to the browser like so:

header('Content-Type: application/zip');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="file.zip"');
readfile($file);
unlink($file);

The issue is that wordpress by default wraps everything in it's admin theme. Is there a flag or something I can set to tell wordpress that for this particular page I don't want it to out the admin interface?

Edit: Here is the code I used to generate the submenu page:

  add_action('admin_menu', array($this, 'add_download_page'));

  function add_download_page() {
    add_submenu_page( 
        'options.php?post_type=spn_newsletter'
      , 'Download Newsletter' 
      , 'Download Newsletter'
      , 'manage_options'
      , 'spn_download'
      , array($this, 'do_download')
    );
  }

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top