• Resolved peterbisset

    (@peterbisset)


    Hello, firstly great plugin! I have recently upgraded one of my multisite domains to SSL and everything works fine except the links to the other sites in my network through the Multisite Language Switcher are now all https:// as well. The problem is the other sites are on http:// rather than https:// and therefore the links don’t work. On all of the other http:// sites the links work fine it’s just on the https:// site they point to the wrong url. Any ideas how I could resolve this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    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

    Thread Starter peterbisset

    (@peterbisset)

    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;
    }
    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    The theme’s functions.php should be fine.

    Let me know if this helps!

    Thread Starter peterbisset

    (@peterbisset)

    I dropped it in there but got a syntax error: Parse error: syntax error, unexpected ‘$options’ (T_VARIABLE)

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    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;
    }
    Thread Starter peterbisset

    (@peterbisset)

    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

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Multisite Language Switcher on WP Multisite’ is closed to new replies.