I have a plug-in that generates a CSV file. The CSV generator script sends a few php header() commands. It looks like this:
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
echo $data;
?>
The user will be accessing the CSV generator from within wp-admin. The problem is that wordpress automatically outputs its own admin header, nav, footer, etc. This causes the CSV script to fail because the header information has already been sent.
Is it possible to call the csv generator from inside wp-admin without it trying to generate all the WordPress code too?
I think one possible solution would be to put the csv generator file outside of WordPress but I don't want people to be able to access it outside of WordPress. Also, I don't think this would be a good idea because we're using WordPress permissions to control who gets to access the exporter.