6

Since WP 5.5 just released and now you can set plugins to auto-update, can this be done via wp-cli? Looking at the documentation, I don't see a sub-command for it: https://developer.wordpress.org/cli/commands/plugin/

I manage a lot of Wordpress sites, most of which are OK to auto-update and would save me a lot of time if they did, as well as reducing security risks.

I'd like to enable auto-updates for plugins across over many wordpress sites. Any solutions?

6
  • Sounds like a feature request to github.com/wp-cli/extension-command – leymannx Aug 11 '20 at 21:14
  • Interesting question. I also manage a pile of WP sites, and use the excellent "Infinite WP" plugin to manage them; installing updates on all sites with just one click. Have used it for a couple of years, and it's well-maintained and supported. But a function to set all plugins to auto-update would be interesting. – Rick Hellewell Aug 11 '20 at 21:37
  • 1
    @leymannx I have submitted a feature request. Thank you! – Alexnl Aug 13 '20 at 14:05
  • @RickHellewell thanks for the information. I will look into that plugin. To date I was using the Easy Update Manager plugin, but this does not allow granular control from one dashboard for all sites. Although I would prefer this option was built into wordpress. – Alexnl Aug 13 '20 at 14:07
  • 1
    Yes, that feature is now in the latest WP. But not available when question and comment was entered. @MikeEng - you should put your comment as the answer, for those that wander by here. – Rick Hellewell Feb 27 at 3:31
2

The simplest way via wp-cli that comes to mind (while it's not supported yet as far as I can see) is something like:

wp eval "update_option( 'auto_update_plugins', array_keys( get_plugins() ) );"

that will update the auto_update_plugins option with the array of all plugin files to update.

This should probably be extended further to only update plugins that are truly updateable or e.g. from a json list to use the json format option of wp-cli.

One can also enable all plugin updates with a filter in a plugin:

add_filter( 'auto_update_plugin', '__return_true' );

That will show up as "Auto-updates enabled" for each plugin in the plugins admin table but the user will not be able to change it from the UI.

ps: this wp-cli command suggestion by Jeffrey Paul seems very useful.

Update: This seems to be supported in wp-cli/extension-command version 2.0.12 by this pull request:

wp plugin auto-updates status [<plugin>...] [--all] [--enabled-only] [--disabled-only] [--field=<field>]
wp plugin auto-updates enable [<plugin>...] [--all] [--disabled-only]
wp plugin auto-updates disable [<plugin>...] [--all] [--enabled-only]

but it looks like it's not merged into the main wp-cli yet in version 2.4.

It's possible to get the latest version with:

wp package install git@github.com:wp-cli/extension-command.git

according to the installing part of the wp-cli/extension-command docs.

2
1

This is not using wp-cli, but maybe the next best thing:

From the Plugins page in WordPress Admin: siteurl.com/wp-admin/plugins.php

You can check all plugins and then from the bulk actions, choose “enable auto updates”.

enable auto updates

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.