Skip to content

Instantly share code, notes, and snippets.

@nawawi
Created October 14, 2025 12:42
Show Gist options
  • Save nawawi/23c4ce425530cdb70f5e467742e68bf7 to your computer and use it in GitHub Desktop.
Save nawawi/23c4ce425530cdb70f5e467742e68bf7 to your computer and use it in GitHub Desktop.
docketcache_flush_when_plugin_update.php
<?php
// Place this code in wp-content/mu-plugins/docketcache_flush_when_plugin_update.php
add_action('docketcache/init', function($docket_cache_instance) {
$docket_cache = $docket_cache_instance;
add_action( 'upgrader_process_complete', function($wp_upgrader, $options) use($docket_cache) {
if ('update' !== $options['action']) {
return;
}
$result = $docket_cache->flush_cache(true);
$docket_cache->co()->lookup_set('occacheflushed', $result);
do_action('docketcache/action/flush/objectcache', $result);
}, 10, 3);
}, \PHP_INT_MAX, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment