From 669f5d56506d2a41843c7f3d1d737c6c79af2922 Mon Sep 17 00:00:00 2001 From: bengizmo Date: Fri, 30 May 2025 15:19:39 -0600 Subject: [PATCH] feat: Add MU plugins from staging server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hvac-nocache.php: Prevents caching on HVAC pages and for logged-in users - mu-certificate-handler.php: Handles certificate URLs at earliest stage to prevent 404 errors These MU plugins are critical for proper functionality of dashboard, login, and certificate features. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../wp-content/mu-plugins/hvac-nocache.php | 54 +++++++++++++ .../mu-plugins/mu-certificate-handler.php | 75 +++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 wordpress-dev/wordpress/wp-content/mu-plugins/hvac-nocache.php create mode 100644 wordpress-dev/wordpress/wp-content/mu-plugins/mu-certificate-handler.php 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