-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear-cache.php
More file actions
30 lines (25 loc) · 959 Bytes
/
clear-cache.php
File metadata and controls
30 lines (25 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* Cache Clearing Script for Development
* Place this file in your theme directory and visit it once to clear caches
* Remove this file after use for security
*/
// Prevent direct access in production
if (!defined('ABSPATH')) {
// For development only - remove this check in production
define('ABSPATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/');
}
// Clear WordPress object cache
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
}
// Clear any theme-specific caches
if (function_exists('delete_transient')) {
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_%'");
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient_%'");
}
// Force browser cache refresh by updating theme version
touch(get_template_directory() . '/style.css');
echo "Cache cleared! Please refresh your browser with Ctrl+F5 (PC) or Cmd+Shift+R (Mac)";
?>