Skip to content

Instantly share code, notes, and snippets.

@remkus
Created November 10, 2013 11:12
Show Gist options
  • Save remkus/7396911 to your computer and use it in GitHub Desktop.
Save remkus/7396911 to your computer and use it in GitHub Desktop.
Clear APC cache with a single click
<?php
*/
* Clear APC cache with a single click
* @link http://kaspars.net/blog/wordpress/clear-apc-cache-button-for-wordpress
*/
if (function_exists('apc_clear_cache')) {
// Clear cache if something is edited
if (!empty($_POST) && is_admin())
apc_clear_cache();
// Add Clear APC menu under Tools menu
add_action('admin_menu', 'php_apc_info');
function php_apc_info() {
add_submenu_page('tools.php', 'Clear APC', 'Clear APC', 'activate_plugins', 'clear_php_apc', 'php_apc_options');
}
function php_apc_options() {
if (apc_clear_cache() && apc_clear_cache('user'))
print '<p>All Clear!</p>';
else
print '<p>Clearing Failed!</p>';
print '<pre>'; print_r(apc_cache_info()); print '</pre>';
}
// Add Clear APC in the favorite actions dropdown
add_filter('favorite_actions', 'clear_apc_link');
function clear_apc_link($actions) {
$actions['tools.php?page=clear_php_apc'] = array('Clear APC', 'edit_posts');
return $actions;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment