diff --git a/plugin-update-checker.php b/plugin-update-checker.php index 049a1a3..c5fa6cb 100644 --- a/plugin-update-checker.php +++ b/plugin-update-checker.php @@ -1,6 +1,6 @@ slug; + $this->cronHook = 'check_plugin_updates-' . $this->slug; if ( $this->checkPeriod > 0 ){ //Trigger the check via Cron add_filter('cron_schedules', array(&$this, '_addCustomSchedule')); - if ( !wp_next_scheduled($cronHook) && !defined('WP_INSTALLING') ) { + if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) { $scheduleName = 'every' . $this->checkPeriod . 'hours'; - wp_schedule_event(time(), $scheduleName, $cronHook); + wp_schedule_event(time(), $scheduleName, $this->cronHook); } - add_action($cronHook, array(&$this, 'checkForUpdates')); + add_action($this->cronHook, array(&$this, 'checkForUpdates')); + + register_deactivation_hook($this->pluginFile, array($this, '_removeUpdaterCron')); //In case Cron is disabled or unreliable, we also manually trigger //the periodic checks while the user is browsing the Dashboard. @@ -86,7 +90,7 @@ class PluginUpdateChecker { } else { //Periodic checks are disabled. - wp_clear_scheduled_hook($cronHook); + wp_clear_scheduled_hook($this->cronHook); } } @@ -106,6 +110,15 @@ class PluginUpdateChecker { } return $schedules; } + + /** + * Remove the scheduled cron event that the library uses to check for updates. + * + * @return void + */ + function _removeUpdaterCron(){ + wp_clear_scheduled_hook($this->cronHook); + } /** * Retrieve plugin info from the configured API endpoint.