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?
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.