Closed keneniah closed 1 year ago
It's possible that WordPress can cache an available update and keep showing it even after PUC has been disabled. The cached update will probably disappear the next time that WP checks for updates.
To fully hide an update, you would need to subclass the plugin update checker class and override a couple of the methods, which may be complicated if you're not already very familiar with the library. However, there is a filter that you could use to remove the download URL from updates, which would prevent the user from installing the update (the notification would still show up). Something like this:
$updateChecker->addFilter('pre_inject_update', function($pluginInfo) {
if ( isset($pluginInfo, $pluginInfo->download_url)) {
$pluginInfo->download_url = null;
}
return $pluginInfo;
});
Hi Yahnis,
it was indeed the WP cache that let the update show. So this problem is fixed.
So I decided to simply not load your plugin if the license is not valid. The downside of this approach is that it can be disabled if someone knows PHP. A better was would be if your plugin could call a URL on the server which either provides the update or refuses to. So validation can be done completely on the server.
Is that something you may plan for a future update?
Best regards
Holger
License management and validation have come up occasionally in the past, but overall it seems that there's not enough demand to warrant building this feature into the update checker or my update server. And if I did something like that, it would probably be a paid product.
A paid product would be absolutely fine. Important is only that all validation is done on the server. So if you ever decide to implement such a product please let me know. Thanks for your great support.
Hi Yahnis, may I ask one more question?
Is it possible to attach a parameter to the URL of the downloaded plugin update file? Then I could add a serial number and check it on the server.
So instead of calling https://my.server.com/plugin.zip I'd like to call https://my.server.com/download.php?sn=123456.
The same code that sets the download URL to null
could be extended to add a new query parameter to the URL if some conditions are met.
Alternatively, you could filter the URL when the update is received, not just before PUC passes it to WordPress:
$updateChecker->addFilter('request_update_result', function($updateInfo) {
if ( isset($updateInfo, $updateInfo->download_url)) {
$updateInfo->download_url = add_query_arg(
array('foo' => 'bar'),
$updateInfo->download_url;
);
}
return $updateInfo;
});
Superb, it works great. Thank you very much. Now I can establish my own license validation :-)
All right, it sounds like the issue is resolved. I'll close it now.
Hi,
how is it possible to disable updates? I commented out buildUpdateChecker but the updates are still shown on the plugins page?
The readme file talks about hooks that can be used for license management but doesn't name them. Can you give me a list of those hooks?
Thank you very much for your help.