So I have a made a small manager plugin myself to modify some core elements from WordPress and I also hide it from my clients so they can't disable it as it also hides WPManage which is the management tool I use to control most of the websites I manage.

I've looked through the WordPress Codex and found the following: https://codex.wordpress.org/Configuring_Automatic_Background_Updates

Which then provided me with the following code:

function auto_update_specific_plugins ($update, $item){
    $plugins = array('worker');
    if (in_array($item->slug, $plugins)){return true;}else{return $update;}

I added this however into my own manager plugin lets call it SHS Manager, which is also hidden, but of course WP Manager does gets updates but as I've hidden it from within the SHS Manager plugin (which is also hidden so it can't be disabled easily) I therefore can't easily update it and am therefor looking for a way to automatically update WP Manager Worker plugin when there's an update available.

While I thought the above code worked which I did put in my SHS Manager tool, it for some reason never actually updated to WP Manager Worker Plugin at all, what am I missing here?

I made sure that the slug is the correct one being that the plugin is called 'worker' and that obviously the plugin was out of date to see if it would auto update, couple refreshes later and a period of time but it was still on the old version.

Am I missing something, are some crons required or are set in place that it only does this check once an hour or something or what am I exactly missing here that would cause this piece of code that is put in the WordPress Codex to not function correctly?

I've already searched through a lot of stack overflow similar questions but most were outdated or provided the same code that could be found on the WordPress Codex.

So any suggestions are welcomed.

Thanks in advance.

  • 1
    Maybe the callback is never called? You can try error_log( 'auto_update_specific_plugins() called' ); in the callback and check the PHP error logs. You can also inspect the $item, to check if worker is actually being passed to the callback. – Sally CJ May 15 '19 at 3:36
  • It does seem to be called: [16-May-2019 14:39:54 UTC] auto_update_specific_plugins() called Inspect the $item and slug and it indeed is all in order as far as I can see. So I'm not sure what I am missing. – Rafaël De Jongh May 16 '19 at 14:55
  • 1
    Try var_dump( get_site_transient( 'update_plugins' ) ); and see if your plugin (worker) is somewhere in the data (either the response or no_update item). If so, in which item is it (response / no_update) and do you see a valid package (URL to the plugin's ZIP file) for your plugin? – Sally CJ May 16 '19 at 18:32
  • Did a the var_dump on a fresh install with an older version of the worker plugin to make sure that it will have an "update now" label and this was the output: pastebin.com/yYykciin So it has a response, it as a proper package, it shows which is the latest version, so I am really not sure to why this isn't working. – Rafaël De Jongh May 18 '19 at 0:05
  • So I installed version 4.1.0 of the plugin and waited for 3 hours (but you may have to wait longer), and the plugin was automatically updated to version 4.8.0. And the auto-update does rely on cron - WordPress performs auto-update twice daily via wp_maybe_auto_update() which is triggered through wp_version_check(), but only if doing cron jobs. So how did you trigger the auto-update? – Sally CJ May 20 '19 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.