How make WP multisite create sites in https


I would like to know how I can edit the core files of wordpress so that it automatically creates each subsite in https and not http.

How can this be done?

I have already tried to use the force ssl plugin but some of my plugins won’t work properly because within the wp-admin/network/site-info.php?id=1 area my site still says http.

I know I can update the site manually from http to https but I am using the pro-sites plugin so I want it to create each site into https upon sign up.

Do you think this could work?

Plugin Name: Make new sites in the network with https URLs
Description: Force new sites in a multisite network to use HTTPS as the scheme.

add_action( 'wpmu_new_blog', 'mh_new_site_http', 10, 6 );

function mh_new_site_http( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {

switch_to_blog( $blog_id );

$mh_old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
$mh_old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );

$mh_new_home_url = preg_replace( '/^http:/' , 'https:' , $mh_old_home_url );
$mh_new_site_url = preg_replace( '/^http:/' , 'https:' , $mh_old_site_url );

update_option( 'home', $mh_new_home_url );
update_option( 'siteurl', $mh_new_site_url );



Thank you,