What is the function to get plugin base url in multisite?

I’m using this function plugins_url().

But it always echoes main site url even in subsite.

Read More

So i’m getting ajax errors like Domains, protocols and ports must match.

Lets say my main domain name is blahblah.com and my subdomain is mysubdomain.blahblah.com

Is there any function available that returns mysubdomain.blahblah.com/wp-content/plugins instead of blahblah.com/wp-content/plugins?

Thanks

Update:

As of now i’m using like this.

home_url( '/' ).'wp-content/plugins/'.str_replace(basename(__FILE__),"",plugin_basename(__FILE__))

Here wp-content/plugins/ text hard coded.

So any other alternative method there?

Related posts

Leave a Reply

1 comment

  1. The plugins_url() function is designed to work in WordPress Multisite. Here is an example of its proper usage:

    <?php
    echo "<img src="' .plugins_url( 'images/wordpress.png' , __FILE__ ). '" > ';
    ?>
    

    If you are using this function in a file that is nested inside a
    subdirectory, you should use PHP’s dirname() function:

    <?php
    echo "<img src="' .plugins_url( 'images/wordpress.png' , dirname(__FILE__) ). '" > ';
    ?>