Skip to content

Instantly share code, notes, and snippets.

@nawawi
Last active June 22, 2022 02:56
Show Gist options
  • Save nawawi/0cd920bf641fbe1b9d4948d946de14f7 to your computer and use it in GitHub Desktop.
Save nawawi/0cd920bf641fbe1b9d4948d946de14f7 to your computer and use it in GitHub Desktop.
<?php
add_action('plugins_loaded', function() {
if ( is_multisite() ) {
$sites = get_sites();
foreach ( $sites as $site ) {
switch_to_blog( $site->blog_id );
$old_siteurl = get_option('siteurl');
$old_homeurl = get_option('home');
$new_siteurl = str_replace('http://', 'https://', $old_siteurl);
$new_homeurl = str_replace('http://', 'https://', $old_homeurl);
update_option('siteurl', $new_siteurl);
update_option('home', $new_homeurl);
restore_current_blog();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment