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: /
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?
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/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?
Share Improve this question asked Aug 11, 2020 at 19:46 AlexnlAlexnl 3071 gold badge6 silver badges16 bronze badges 6- Sounds like a feature request to github/wp-cli/extension-command – norman.lol Commented Aug 11, 2020 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 Commented Aug 11, 2020 at 21:37
- 1 @leymannx I have submitted a feature request. Thank you! – Alexnl Commented Aug 13, 2020 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 Commented Aug 13, 2020 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 Commented Feb 27, 2021 at 3:31
2 Answers
Reset to default 3The 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 [email protected]:wp-cli/extension-command.git
according to the installing part of the wp-cli/extension-command docs.
This is not using wp-cli, but maybe the next best thing:
From the Plugins page in WordPress Admin: siteurl/wp-admin/plugins.php
You can check all plugins and then from the bulk actions, choose “enable auto updates”.