Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 18407)
+++ wp-includes/functions.php	(working copy)
@@ -3622,6 +3622,33 @@
 }
 
 /**
+ * Filter a url to have the correct protocol
+ *
+ * @since 3.3
+ * @param string $url, url to filter 
+ * @return string $url, filtered url
+ */
+function set_url_scheme($url, $scheme = null) {
+	$orig_scheme = $scheme;
+	if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
+		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
+			$scheme = 'https';
+		elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
+			$scheme = 'https';
+		elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
+			$scheme = 'https';
+		else
+			$scheme = ( is_ssl() ? 'https' : 'http' );
+	}
+	if ($scheme == 'https') {
+		$url = str_replace( 'http://', 'https://', $url ); 
+	} else {
+		$url = str_replace( 'https://', 'http://', $url ); 
+  }
+	return apply_filters('set_url_scheme', $url, $scheme);
+}
+
+/**
  * Whether SSL login should be forced.
  *
  * @since 2.6.0
