/** * Catches email list export requests and processes them. We catch these requests * in a separate function so that we can do a proper header() call without WP * doing an output first. * * @return void */ function ql_catch_exports() { if (is_admin() && basename($_SERVER['PHP_SELF']) == 'admin.php') { if (isset($_GET['export'])) { $format = $_GET['export']; if ($format == 'csv') { // Write the csv to a temporary file $csv = QL_Email::csv(); $file = fopen(WP_CONTENT_DIR . '/quicklaunch.csv', 'w'); fwrite($file, $csv); fclose($file); // Redirect the user to the temporary file header('Location: ' . WP_CONTENT_URL . '/quicklaunch.csv'); exit; } } } }