Title: Bug in class-admin.php / function get_plugin_url()
Last modified: October 3, 2016

---

# Bug in class-admin.php / function get_plugin_url()

 *  Resolved [Gahapati](https://wordpress.org/support/users/gahapati/)
 * (@gahapati)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/bug-in-class-admin-php-function-get_plugin_url/)
 * Goedendag Rogier,
 * thank you very much for this outstanding plugin!
 * I found (and possibly fixed) the following bug:
    `File: class-admin.php` `Function:
   get_plugin_url()` `Lines: 1232 - 1239`
 * _$this->plugin\_url_ returns a malformed URL like:
    _sub.example.**comwp**-content/
   plugins/really-simple-ssl/_.
 * In Multisite sub-sites this breaks the SSL in the Configuration tab and causes
   an extended delay until the request times out.
 * I found the use of _home\_url()_ instead of _network\_home\_url()_ to be the 
   main culprit. In addition, the final _str\_replace()_ appears to be mixed up.
 * The original code reads:
 *     ```
       if (is_multisite() && ( !is_main_site(get_current_blog_id()) ) && (!$this->is_multisite_subfolder_install()) ) {
              $mainsiteurl = str_replace("http://","https://",network_site_url());
   
              $home = str_replace("http://","https://",home_url());
              $this->plugin_url = str_replace($mainsiteurl,home_url(), $this->plugin_url);
   
              //return http link if original url is http.
              if (strpos(home_url(), "https://")===FALSE) $this->plugin_url = str_replace("https://","http://",$this->plugin_url);
       ```
   
 * The proposed replacement code reads:
 *     ```
       if (is_multisite() && ( !is_main_site(get_current_blog_id()) ) && (!$this->is_multisite_subfolder_install()) ) {
              $mainsiteurl = str_replace("http://","https://",network_site_url());
   
              $home = str_replace("http://","https://",network_home_url());
              $this->plugin_url = str_replace($mainsiteurl,network_home_url(), $this->plugin_url);
   
              //return http link if original url is http.
              if (strpos(network_home_url(), "https://")===FALSE) $this->plugin_url = str_replace("http://","https://",$this->plugin_url);
       ```
   
 * This at least works on my server. I wasn’t able to test out the last line of 
   code in particular, because I have SSL configured to be always on, and I cannot
   turn it off easily.
 * Kind regards

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * (@rogierlankhorst)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/bug-in-class-admin-php-function-get_plugin_url/#post-8247511)
 * Thanks for reporting the issue, and for taking the time to investigate. Your 
   fix is not entirely correct though. The network_home_url returns the home_url
   of the main site, but that is not what is needed here, because the plugin needs
   to validate the SSL on this specific subdomain url, not on the main url. So the
   home_url is good. This is probably caused by the fact that the network_homeurl
   in your case ends with a slash, but the sub-site does not. So when the plugin_url,
   which points to the main site plugin directory, is replaced, there is a slash
   missing. This explains why this issue doesn’t occur in most cases. It can be 
   fixed by using the trailingslashit function on both variables.
 * I also now notice that the $home variable, that is meant to use for replacement,
   is not used.
 * Finally, the last line you mention, is meant to return http when the home_url
   is http, and should return only https when the home_url is https. So what happens
   here is that when the home_url does not contain https, the plugin_url gets replaced
   back to http.
 * So I would propose the following code:
 *     ```
       if (is_multisite() && ( !is_main_site(get_current_blog_id()) ) && (!$this->is_multisite_subfolder_install()) ) {
              $mainsiteurl = trailingslashit(str_replace("http://","https://",network_site_url()));
   
              $home = trailingslashit(str_replace("http://","https://",home_url()));
              $this->plugin_url = str_replace($mainsiteurl, $home, $this->plugin_url);
   
              //return http link if original url is http.
              if (strpos(home_url(), "https://")===FALSE) $this->plugin_url = str_replace("https://","http://",$this->plugin_url);
       ```
   
 * Let me know if this code works for you.

Viewing 1 replies (of 1 total)

The topic ‘Bug in class-admin.php / function get_plugin_url()’ is closed to new 
replies.

 * ![](https://ps.w.org/really-simple-ssl/assets/icon-256x256.png?rev=2839720)
 * [Really Simple Security - Simple and Performant Security (formerly Really Simple SSL)](https://wordpress.org/plugins/really-simple-ssl/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/really-simple-ssl/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/really-simple-ssl/)
 * [Active Topics](https://wordpress.org/support/plugin/really-simple-ssl/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/really-simple-ssl/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/really-simple-ssl/reviews/)

## Tags

 * [bug fix](https://wordpress.org/support/topic-tag/bug-fix/)
 * [home_url](https://wordpress.org/support/topic-tag/home_url/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/bug-in-class-admin-php-function-get_plugin_url/#post-8247511)
 * Status: resolved