Hi,
The problem seems to be that WordPress decides all home_urls have to be SSL once it is on an SSL page.
I’ve run into this same issue when on the admin panel. When you’re on the admin, WP by default shows all sites with https links, even those without SSL. I’ve fixed this in the plugin, using the admin_url filter.
Coincidentally, another user posted a similar issue here, I think the code I posted there might work for you too. I haven’t tested it, it’s purely based on the admin_url filter. But if your code uses the home_url function to get those links, this should fix it.
https://really-simple-ssl.com/forums/topic/force-external-links-to-open-in-http-before-https/#post-27314
Thanks for your prompt reply, would the below code need to go into the theme’s functions.php file or somewhere else?
add_filter( 'home_url', 'rsssl_fix_https_urls' );
function rsssl_fix_https_urls($url, $path, $orig_scheme, $blog_id){
$ssl_enabled = false
$options = get_blog_option($blog_id, "rlrsssl_options");
if ($options && isset($options)) {
$site_has_ssl = isset($options['site_has_ssl']) ? $options['site_has_ssl'] : FALSE;
$ssl_enabled = isset($options['ssl_enabled']) ? $options['ssl_enabled'] : $site_has_ssl;
}
if (!$ssl_enabled) {
$url = str_replace("https://","http://",$url);
}
return $url;
}
The theme’s functions.php should be fine.
Let me know if this helps!
I dropped it in there but got a syntax error: Parse error: syntax error, unexpected ‘$options’ (T_VARIABLE)
Sorry about that. to quick copy pasted. I’ve tested this, this works for the home_url function:
add_filter( 'home_url', 'rsssl_fix_https_urls' , 10,4);
function rsssl_fix_https_urls($url, $path, $orig_scheme, $blog_id){
$ssl_enabled = false;
$options = get_blog_option($blog_id, "rlrsssl_options");
if ($options && isset($options)) {
$site_has_ssl = isset($options['site_has_ssl']) ? $options['site_has_ssl'] : FALSE;
$ssl_enabled = isset($options['ssl_enabled']) ? $options['ssl_enabled'] : $site_has_ssl;
}
if (!$ssl_enabled) {
$url = str_replace("https://","http://",$url);
}
return $url;
}
Thanks that worked perfectly! Incidentally I’ve spoken to the author of Multisite Language Switcher and they are going to be working on a fix for this apparently: https://github.com/lloc/Multisite-Language-Switcher/issues/103
Thanks for the update. I think it could be considered a WordPress bug, as it is such a basic function in WordPress.
I’ll think about incorporating it in the plugin, as it’s a pretty common issue I think.