/** * Send content back */ public function sendResponse() { if ($this->response instanceof SymfonyResponse) { $this->response->sendContent(); } if ($this->templatefile !== false) { echo $this->template->render($this->templatefile, $this->templatefileParameters); } }
/** * Generate download file * @param string $file * @param int $status * @param array $headers */ public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH . "wp-admin/includes/file.php"; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader["Content-Description"] = "File Transfer"; $downloadHeader["Content-Type"] = "application/octet-stream"; $downloadHeader["Content-Disposition"] = "attachment; filename=" . basename($file); $downloadHeader["Content-Transfer-Encoding"] = "binary"; $downloadHeader["Expires"] = "0"; $downloadHeader["Cache-Control"] = "must-revalidate"; $downloadHeader["Pragma"] = "public"; $downloadHeader["Content-Length"] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }
/** * Generate download file. * * @param string $file * @param int $status * @param array $headers */ public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH . 'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader['Content-Description'] = 'File Transfer'; $downloadHeader['Content-Type'] = 'application/octet-stream'; $downloadHeader['Content-Disposition'] = 'attachment; filename=' . basename($file); $downloadHeader['Content-Transfer-Encoding'] = 'binary'; $downloadHeader['Expires'] = '0'; $downloadHeader['Cache-Control'] = 'must-revalidate'; $downloadHeader['Pragma'] = 'public'; $downloadHeader['Content-Length'] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }