Closed elzadj closed 4 years ago
The current release should already support that feature. If you're using the latest version (4.10), you should see an "enable auto-updates" link next to your plugin.
Naturally, this will only work while your plugin/theme is active - the update checker needs to be running to provide updates.
@YahnisElsts In the version 4.10, the plugin using this library is showing the link "enable auto-updates" and the message - "Automatic update scheduled in 6 hours.". But it's not auto-updating the plugin even though next version is available. Is there anything else we need to do to make it work?
No, I don't think you need to do anything more. I tested it on one of my live sites just a few days ago and WordPress successfully updated the plugin and sent me a "Some plugins were automatically updated" notification.
Are you doing anything special with your updates, like requiring a license key, or only initialising the update checker when is_admin()
is true, or anything like that? If so, make sure that PUC is also initialised and a download link is available in the context of an unattended update.
Yes, there is a condition if ( is_admin() && isset( $options['license_key'] ) && $options['license_key'] != '' )
which needs to be true to call Puc_v4_Factory::buildUpdateChecker
. Even if this condition is met, add-on is not being auto-updated.
Can you guide me in the right direction how am I supposed to use the auto-update feature of WordPress in this case?
I can't answer that with confidence as I'm not very familiar with the internal workings of automatic updates. However, one simple thing that I would recommend is to try removing the is_admin()
condition. My guess would be that automatic updates happen inside a cron request and is_admin()
may be false
in that case.
Yahnis is absolutely right; is_admin()
will return false
when the WP auto-updates cron job is running.
Thanks. Removing the is_admin()
condition made it work.
Hello Yahnis!
Are you planning to add support for the new 'enable auto-updates' WordPress feature? https://make.wordpress.org/core/2020/07/15/controlling-plugin-and-theme-auto-updates-ui-in-wordpress-5-5/
Thanks.