[wp-hackers] auto_update_plugin trouble with self-hosted plugin

Janis Elsts whiteshadow at w-shadow.com
Thu Oct 23 08:08:15 UTC 2014


I'm not sure that this list is the right place to discuss third-party  
libraries, but I'll answer anyway. It looks like you're using an older  
version of my update checker:
https://github.com/YahnisElsts/plugin-update-checker

> By manually running the cron, I've proved that all wordpress.org-hosted
> plugins *do* update automatically... so I guess my question is, what's
> different? What do i need to DO differently in order to get my  
> self-hosted plugins to behave in the same fashion as plugins hosted in  
> the official
> repo?

Like WordPress itself, this library defaults to checking for updates every  
12 hours. However, it uses a custom cron hook, so maybe it didn't get  
triggered by whatever you did to run cron manually.

You can change how often it checks for updates by passing the check period  
(in hours) to the constructor:

require_once 'classes/plugin-updates/plugin-update-checker.php';
$myPluginUpdateChecker = new PluginUpdateChecker_1_4(
	'http://example.com/myplugin.json',
	__FILE__,
	'myplugin',
	42  //Check every 42 hours.
);

If you want your plugin to have full control over when exactly it checks  
for updates, you can turn off automatic checks by setting this argument to  
0. Then call $myPluginUpdateChecker->checkForUpdates() directly.

You can use the Debug Bar plugin to see the last update check time, when  
the next automatic check will happen, and other useful information. It'll  
show up in the "PUC (your-plugin-slug)" panel.
https://wordpress.org/plugins/debug-bar/

Most of the above described in the documentation:
http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/

---
Jānis Elsts

On Wed, 22 Oct 2014 17:48:58 +0300, Dave McHale <dmchale at gmail.com> wrote:

> I'm having trouble configuring WP's auto updates to work with a plugin  
> that
> I have hosted on my own server. After troubleshooting within the plugin
> without luck, I finally stripped everything out to a simple plugin that
> ONLY tries to update itself, with no other functionality.
>
> //
> require_once 'classes/plugin-updates/plugin-update-checker.php';
> $myPluginUpdateChecker = new PluginUpdateChecker_1_4(
>     'http://example.com/myplugin.json',
>     __FILE__,
>     'myplugin'
> );
>
> add_filter( 'auto_update_plugin', '__return_true' );
> //
>
> The Plugins dashboard shows that an update is available for the plugin,  
> and
> clicking "Update Now" functions properly, but ideally I would like this
> plugin to automatically update when WordPress goes to run its 12-hour  
> cron
> to update plugins.
>
> By manually running the cron, I've proved that all wordpress.org-hosted
> plugins *do* update automatically... so I guess my question is, what's
> different? What do i need to DO differently in order to get my  
> self-hosted
> plugins to behave in the same fashion as plugins hosted in the official
> repo?
>
> In the end of this, I'd ideally like for ONLY my plugin to automatically
> update (by using code similar to what's found here, only reversed  
> logic...
> http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated
> ) but for now I'm trying to just use the __return_true value to prove  
> that
> it works at ALL.
>
> Thanks in advance! I've spent countless hours trying to get this to work,
> and I'm just at my wit's end with it. I've about run out of ideas to try,
> so I'm hoping someone can point me in the right direction.
>
> Dave
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list