Skip to content

Instantly share code, notes, and snippets.

@chriszarate
Created March 2, 2015 16:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chriszarate/45d6882b75ff61cdda90 to your computer and use it in GitHub Desktop.
WordPress Multisite HTTP to HTTPS migration
!/bin/bash
# WordPress Multisite HTTP to HTTPS migration
# Use wp-cli to assist HTTP to HTTPS migration for a WP Multisite installation.
# Update site metadata for the main site as well as each site in the network.
WP_PATH=/var/www
WPCLI_PATH=/home/admin/bin/wp-cli.phar
UPDATE_FIELDS="siteurl home fileupload_url"
# Get list of all sites in network.
SITELIST=$(php $WPCLI_PATH --path=$WP_PATH --quiet site list | awk '{if (NR!=1) {print $2}}' | sed 's/\/$//g')
# Get item count.
SITELIST_COUNT=${#SITELIST[@]}
# Loop through sites and update site metadata.
if [ "$SITELIST_COUNT" -gt "0" ]; then
for SITE in $SITELIST; do
for FIELD in $UPDATE_FIELDS; do
php $WPCLI_PATH --path=$WP_PATH --url=$SITE --user=1 option update $FIELD https://$SITE
done
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment