Created
          March 2, 2015 16:53 
        
      - 
      
- 
        Save chriszarate/45d6882b75ff61cdda90 to your computer and use it in GitHub Desktop. 
    WordPress Multisite HTTP to HTTPS migration
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | !/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