Bulk update plugins in a WordPress VIP repository that are available in the WordPress.org plugins directory.
Updating plugins on a WordPress VIP install can be a chore. Because the VIP filesystem is locked down, plugin updates must be made outside of WordPress. The VIP Dashboard lets you automatically create pull requests, but only to update one plugin at a time.
Using this script and a locally cloned copy of a site's VIP repository, you can automatically update all plugins that are available on the WordPress.org plugin directory.
Open a terminal and cd
to the root directory of your repository. Make sure the branch you wish to update plugins for is checked out in Git. Run the script and the plugins with available updates will be downloaded to a temporary directory and unzipped into your plugins
folder.
- The current directory is assumed to be the VIP application name. The current branch is assumed to be the environment name. The script accepts optional
--app
and--env
flags to override these values. - The script uses the VIP CLI to run the
wp plugin list
command against the VIP application and environment, fetching the list of plugins in JSON format. - Next, the script uses
jq
to extract and loop through the plugin slug and update status of each plugin. - If the plugin has an update available, the script uses
curl
to attempt to download the plugin from WordPress.org to a temporary directory. - If the download is successful, the plugin is extracted into the plugin directory, and the slug and "updated" are output to the terminal. If the download fails, the plugin slug and "notfound" are output to the terminal. This information can then be used to determine plugins that will need manual updates (e.g., those not on the WordPress.org plugin directory).
- Finally, a count of successes and failures is displayed, and the temporary directory is deleted.
- Download the
update-vip-plugins.sh
file. $ chmod +x update-vip-plugins.sh
$ mv update-vip-plugins.sh /usr/local/bin/update-vip-plugins
To use the script, run the following command in a terminal:
$ update-vip-plugins [--app <directory>] [--env <environment_name>] [--help]
--app
: Specify the directory name to override the current_directory variable.--env
: Specify the environment name to override the branch variable.--help
: Display this help message.
The script will download plugin updates for a WordPress VIP site, updating only the plugins that are publicly available on the WordPress.org plugin directory.