function export_to_text_download()
 {
     //$core = $_POST['download'].'wp-load.php';
     //include( $core );
     $sitename = sanitize_key(get_bloginfo('name'));
     if (!empty($sitename)) {
         $sitename .= '.';
     }
     $filename = $sitename . 'wordpress.' . date('Y-m-d') . '.txt';
     header('Content-Description: File Transfer');
     header('Content-Disposition: attachment; filename=' . $filename);
     header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true);
     sre2t_ajax();
     die;
 }
<?php

$core = $_POST['download'] . 'wp-load.php';
include $core;
header('Content-disposition: attachment; filename=export-to-text.txt');
header('Content-type: text/plain');
sre2t_ajax();