Skip to content

Commit

Permalink
Clear scheduled cron events & reset crons_setup on plugin deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Dec 7, 2015
1 parent 0426107 commit 6955807
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/includes/closures/Plugin/InstallUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@
$self->removeWpHtaccess();
$self->removeAdvancedCache();
$self->clearCache();

// Events with a custom schedule will disappear (see http://bit.ly/1lGdr78); lets clean up to avoid any confusion.
if (is_multisite()) { // Main site CRON jobs.
switch_to_blog(get_current_site()->blog_id);
wp_clear_scheduled_hook('_cron_'.GLOBAL_NS.'_auto_cache');
wp_clear_scheduled_hook('_cron_'.GLOBAL_NS.'_cleanup');
restore_current_blog(); // Restore current blog.
} else { // Standard WP installation.
wp_clear_scheduled_hook('_cron_'.GLOBAL_NS.'_auto_cache');
wp_clear_scheduled_hook('_cron_'.GLOBAL_NS.'_cleanup');
}
// This MUST happen upon uninstall; see http://bit.ly/1lGdr78
$self->updateOptions(array('crons_setup' => '0')); // Reset so that crons are rescheduled upon next activation
};

/*
Expand Down

0 comments on commit 6955807

Please sign in to comment.