If there's no external update to display, remove any cached update info WordPress might have about the plugin.

This is a significant change from previous behaviour where the library would leave the value of the "update_transients" unmodified if there were no updates available. That worked fine at the time because WP wouldn't re-save the injected update to the DB. So when no updates were available, old cached updates wouldn't show up either. However, this appears to have changed - in some cases, the injected update sticks around even if the plugin is no longer injecting it. This patch counters that.

Drawback: If you use this library in a plugin that's hosted on wordpress.org, it will overwrite any update data from wordpress.org with its own and effectively disable wordpress.org updates for your plugin (doesn't affect other plugins).
This commit is contained in:
Yahnis Elsts 2012-10-23 16:35:35 +00:00
parent 850a0f18be
commit 76019713e8
1 changed files with 2 additions and 0 deletions

View File

@ -360,6 +360,8 @@ class PluginUpdateChecker {
//Let plugins filter the update info before it's passed on to WordPress.
$update = apply_filters('puc_pre_inject_update-' . $this->slug, $update);
$updates->response[$this->pluginFile] = $update->toWpFormat();
} else {
unset($updates->response[$this->pluginFile]);
}
return $updates;