too long

I'm trying to get a url to my plugin, but plugins_url function returns an incorrect one.

in main plugin file there's this line:

$this->plugin_url     = plugins_url( '/', __FILE__ );

Note, I've changed my plugins folder through wp-config.php:

...
define( 'WP_PLUGIN_DIR', '/home/victor/hg/' );
define( 'WP_PLUGIN_URL', 'http://hg.victorpc.org' );
...

hg.victorpc.org is a vhost with document root set to /home/victor/hg

the function returns this URL http://hg.victorpc.org/home/victor/hg/<plugin-folder> and the correct is http://hg.victorpc.org/hg/<plugin-folder>

I've worked around it, using:

plugins_url( basename( __DIR__ ) );

which returns what I expect.

Use plugin_dir_url() instead.

Codex: http://codex.wordpress.org/Function_Reference/plugin_dir_url

Usage:

$this->plugin_url = plugin_dir_url( __FILE__ );

This will return: http://hg.victorpc.org/hg/<plugin-folder>/ (notice the trailing slash).