Skip to content

Instantly share code, notes, and snippets.

@Sam-R
Created November 1, 2024 07:59
Show Gist options
  • Save Sam-R/3d7cc89a6f02e823cbf6d65d2a2dd23d to your computer and use it in GitHub Desktop.
Save Sam-R/3d7cc89a6f02e823cbf6d65d2a2dd23d to your computer and use it in GitHub Desktop.
Script to bulk update wordpress sites, plugins and themes using wp-cli
#!/bin/bash
###################
# Script to update wordpress sites, plugins and themes
# Created by: Sam R.
# Created at: 2024-11-01
# Usage:
# - edit the script BASE_PATH as appropriate
# - add the site directories to the SITES array
# - run the script ./wordpress-update.sh
###################
WP_CLI_COMMAND="$HOME/bin/wp-cli.phar"
BASE_PATH="/var/www"
SITES=(
"example.com"
)
for i in "${SITES[@]}"; do
echo "# === UPDATING SITE CORE: ${i}"
${WP_CLI_COMMAND} core update --path="${BASE_PATH}/${i}"
echo "# === UPDATING SITE PLUGINS: ${i}"
${WP_CLI_COMMAND} plugin update --path="${BASE_PATH}/${i}" --all
echo "# === UPDATING SITE THEMES: ${i}"
${WP_CLI_COMMAND} theme update --path="${BASE_PATH}/${i}" --all
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment