I want to create a small plugin to automatically purge the APC opcode cache after specific actions in the WordPress admin interface. This is necessary if e.g. apc.stat is set to 0, as a change to a file then doesn’t reset its cache value in the opcode cache and so calls will use the old, cached, out-of-date file. Total debug nightmare if you forget to clear the cache manually.
Is there an easy way to find out if an action edited/changed a file?
I could manually check if is_admin and POST and file is e.g. theme-editor.php, but this seems like a not very nice hack that is bound to miss some things.
2 Answers
The system redirects after an update with updated=true
. You could check for that GET
parameter on the load-theme-editor.php
hook, something like:
add_action(
'load-theme-editor.php',
function() {
if (isset($_GET['updated']) && true == $_GET['updated']) {
// clear the cache
}
}
);
I looked for more specific hooks and couldn’t find any, by the way.