Index: wp-includes/ms-settings.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/ms-settings.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/ms-settings.php	(revision )
@@ -148,8 +148,7 @@
 	// No site has been found, bail.
 	if ( empty( $current_blog ) ) {
 		// We're going to redirect to the network URL, with some possible modifications.
-		$scheme = is_ssl() ? 'https' : 'http';
-		$destination = "$scheme://{$current_site->domain}{$current_site->path}";
+		$destination = wp_get_protocol() . $current_site->domain . $current_site->path;
 
 		/**
 		 * Fires when a network can be determined but a site cannot.
Index: wp-includes/canonical.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/canonical.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/canonical.php	(revision )
@@ -61,7 +61,7 @@
 
 	if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) {
 		// build the URL in the address bar
-		$requested_url  = is_ssl() ? 'https://' : 'http://';
+		$requested_url  = wp_get_protocol();
 		$requested_url .= $_SERVER['HTTP_HOST'];
 		$requested_url .= $_SERVER['REQUEST_URI'];
 	}
Index: wp-includes/general-template.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/general-template.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/general-template.php	(revision )
@@ -406,7 +406,7 @@
 	$defaults = array(
 		'echo' => true,
 		// Default 'redirect' value takes the user back to the request URI.
-		'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
+		'redirect' => wp_get_protocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
 		'form_id' => 'loginform',
 		'label_username' => __( 'Username' ),
 		'label_password' => __( 'Password' ),
Index: wp-includes/admin-bar.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/admin-bar.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/admin-bar.php	(revision )
@@ -351,7 +351,7 @@
 		return;
 	}
 
-	$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+	$current_url = wp_get_protocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 	$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
 
 	$wp_admin_bar->add_menu( array(
Index: wp-includes/link-template.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/link-template.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/link-template.php	(revision )
@@ -3386,11 +3386,11 @@
 	$orig_scheme = $scheme;
 
 	if ( ! $scheme ) {
-		$scheme = is_ssl() ? 'https' : 'http';
+		$scheme = wp_get_protocol( false );
 	} elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) {
 		$scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http';
 	} elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) {
-		$scheme = is_ssl() ? 'https' : 'http';
+		$scheme = wp_get_protocol( false );
 	}
 
 	$url = trim( $url );
Index: wp-includes/class-wp-admin-bar.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/class-wp-admin-bar.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/class-wp-admin-bar.php	(revision )
@@ -24,7 +24,7 @@
 	public function __get( $name ) {
 		switch ( $name ) {
 			case 'proto' :
-				return is_ssl() ? 'https://' : 'http://';
+				return wp_get_protocol();
 
 			case 'menu' :
 				_deprecated_argument( 'WP_Admin_Bar', '3.3', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' );
Index: wp-includes/functions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/functions.php	(revision e19a8796fd0bc32790f62a586c24f693766a34a0)
+++ wp-includes/functions.php	(revision )
@@ -3965,6 +3965,19 @@
 }
 
 /**
+ * Return protocol
+ *
+ * @since 4.5.0
+ *
+ * @param bool $slashes Add `://` after protocol. Default true.
+ *
+ * @return string
+ */
+function wp_get_protocol( $slashes = true ) {
+	return ( is_ssl() ? 'https' : 'http' ) . ( $slashes ? '://' : '' );
+}
+
+/**
  * Whether to force SSL used for the Administration Screens.
  *
  * @since 2.6.0
@@ -4028,8 +4041,7 @@
 			}
 		}
 
-		$schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet
-		$url = $schema . $_SERVER['HTTP_HOST'] . $path;
+		$url = wp_get_protocol() . $_SERVER['HTTP_HOST'] . $path;
 	}
 
 	return rtrim($url, '/');
@@ -4952,7 +4964,7 @@
  */
 function wp_auth_check_html() {
 	$login_url = wp_login_url();
-	$current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'];
+	$current_domain = wp_get_protocol() . $_SERVER['HTTP_HOST'];
 	$same_domain = ( strpos( $login_url, $current_domain ) === 0 );
 
 	/**
