Add a resetUpdateState() method for clearing update cache, last check timestamp and last checked version.

This commit is contained in:
Yahnis Elsts 2012-10-20 14:24:04 +00:00
parent 9a9c6c2b53
commit aceb9e62a5
1 changed files with 12 additions and 1 deletions

View File

@ -159,7 +159,7 @@ class PluginUpdateChecker {
$url, $url,
$options $options
); );
//Try to parse the response //Try to parse the response
$pluginInfo = null; $pluginInfo = null;
if ( !is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body']) ){ if ( !is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body']) ){
@ -309,6 +309,16 @@ class PluginUpdateChecker {
} }
update_option($this->optionName, $state); update_option($this->optionName, $state);
} }
/**
* Reset update checker state - i.e. last check time, cached update data and so on.
*
* Call this when your plugin is being uninstalled, or if you want to
* clear the update cache.
*/
public function resetUpdateState() {
delete_option($this->optionName);
}
/** /**
* Intercept plugins_api() calls that request information about our plugin and * Intercept plugins_api() calls that request information about our plugin and
@ -432,6 +442,7 @@ class PluginUpdateChecker {
'<div class="updated"><p>%s</p></div>', '<div class="updated"><p>%s</p></div>',
apply_filters('puc_manual_check_message-' . $this->slug, $message, $update) apply_filters('puc_manual_check_message-' . $this->slug, $message, $update)
); );
//todo: the update doesn't show up right away, why?
} }
} }