upskill-event-manager/wordpress-dev/wordpress/wp-content/mu-plugins/hvac-nocache.php
bengizmo 669f5d5650 feat: Add MU plugins from staging server
- 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 <noreply@anthropic.com>
2025-05-30 15:19:39 -06:00

54 lines
No EOL
1.5 KiB
PHP

<?php
/**
* Plugin Name: HVAC No-Cache for Login
* Description: Prevents caching on login and dashboard pages
* Version: 1.0
*/
function hvac_disable_cache() {
// Check if we are on a login-related page
$uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : "";
$disable_cache = false;
// Pages that should never be cached
$no_cache_pages = array(
"community-login",
"wp-login.php",
"hvac-dashboard",
"certificate-reports",
"generate-certificates",
"event-summary"
);
foreach ($no_cache_pages as $page) {
if (strpos($uri, $page) !== false) {
$disable_cache = true;
break;
}
}
// Also disable cache for logged-in users or authentication attempts
if (is_user_logged_in() || isset($_POST["log"]) || isset($_GET["login"])) {
$disable_cache = true;
}
if ($disable_cache) {
// Define WordPress constant
if (!defined("DONOTCACHEPAGE")) {
define("DONOTCACHEPAGE", true);
}
// Set no-cache headers
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Pragma: no-cache");
}
}
add_action("init", "hvac_disable_cache", 0);
// Disable Breeze caching for logged-in users
function hvac_disable_breeze_cache() {
if (is_user_logged_in()) {
add_filter("breeze_skip_cache", "__return_true");
}
}
add_action("init", "hvac_disable_breeze_cache");