-
-
Save mlangone/545b9a70f97c125b2c5cf554edd8320b to your computer and use it in GitHub Desktop.
Update a specific site from 'http://' to 'https://'.
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
<?php | |
/** | |
* Update a specific site from 'http://' to 'https://'. | |
* | |
* Only touches the 'home' and 'siteurl' options. | |
* Depending on plugins, etc., you may need to update other options too. | |
* | |
* Run on WordPress multisite with: | |
* | |
* wp site list --field=url | xargs -I % wp eval-file http-to-https.php --url=% | |
*/ | |
foreach ( array( 'home', 'siteurl' ) as $option ) { | |
$existing = get_option( $option ); | |
$new = str_replace( 'http://', 'https://', $existing ); | |
if ( update_option( $option, $new ) ) { | |
WP_CLI::log( "Updated '{$option}' to '{$new}'" ); | |
} else { | |
WP_CLI::log( "Didn't update '{$option}' to '{$new}'" ); | |
} | |
} | |
WP_CLI::success( 'Options updated for ' . home_url() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment