Skip to content

Instantly share code, notes, and snippets.

@nawawi
Last active December 8, 2024 02:11
Show Gist options
  • Save nawawi/96a96ae658cf5f5cce2e449b516c50ab to your computer and use it in GitHub Desktop.
Save nawawi/96a96ae658cf5f5cce2e449b516c50ab to your computer and use it in GitHub Desktop.
Prevent docket-cache from being activated
<?php
// Disable wp-content/object-cache.php
if (!defined('DOCKET_CACHE_DISABLED')) {
define('DOCKET_CACHE_DISABLED', true);
}
// Deactivate docket-cache
add_action('docketcache/init', function ($docket_cache_instance) {
try {
(new Nawawi\DocketCache\Event($docket_cache_instance))->unregister();
if (!function_exists('deactivate_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
deactivate_plugins('docket-cache/docket-cache.php', true);
if (file_exists(WP_CONTENT_DIR . '/.object-cache-delay.txt')) {
unlink(WP_CONTENT_DIR . '/.object-cache-delay.txt');
}
if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
unlink(WP_CONTENT_DIR . '/object-cache.php');
}
} catch (\Throwable $e) {
}
}, PHP_INT_MAX);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment