diff --git a/wordpress-dev/wordpress/wp-content/mu-plugins/hvac-nocache.php b/wordpress-dev/wordpress/wp-content/mu-plugins/hvac-nocache.php new file mode 100644 index 00000000..f9b2fa5c --- /dev/null +++ b/wordpress-dev/wordpress/wp-content/mu-plugins/hvac-nocache.php @@ -0,0 +1,54 @@ + 404)); + } + + // Delete token to prevent reuse + delete_transient('hvac_certificate_token_' . $token); + + // Get file path + $upload_dir = wp_upload_dir(); + $file_path = $upload_dir['basedir'] . '/' . $certificate_data['file_path']; + + if (!file_exists($file_path)) { + status_header(404); + wp_die('Certificate file not found', 'Not Found', array('response' => 404)); + } + + // Serve the file + $file_name = basename($file_path); + $file_size = filesize($file_path); + + // Set headers + nocache_headers(); + header('Content-Type: application/pdf'); + header('Content-Disposition: attachment; filename="certificate.pdf"'); + header('Content-Transfer-Encoding: binary'); + header('Content-Length: ' . $file_size); + + // Clear any output buffers + while (ob_get_level()) { + ob_end_clean(); + } + + // Output file + readfile($file_path); + exit; + }, 1); + } +}, 1); \ No newline at end of file