Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For some reason I get the following output from

var_dump( plugin_dir_url( __FILE__ ) );

http://local.dev/wp-content/plugins/C:/development/xampp/htdocs/vanilla/wp-content/themes/twentyeleven/

in a local install.

Note: I deactivated all plugins and added the line on top of the functions.php file of the default and unmodified TwentyEleven Theme

share|improve this question
3  
Perhaps it's confused because the file isn't in the plug-ins directory? It probably finds the 'relative' path to it to append onto the plugin-url, in this case the 'relative' path is an absolute one, because it couldn't it in the directory (a dodgy fallback...?) –  Stephen Harris Feb 10 '12 at 12:31
add comment

1 Answer

up vote 7 down vote accepted

There is plugin_basename() call some levels inside which seems to use WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants, so my guess would be this function is only meant to be used for things inside plugin directories and not other places like theme.

share|improve this answer
    
So the only chance left is to use get_stylesheet_directory_uri().'/path/to/some/file.ext;? –  kaiser Feb 10 '12 at 12:48
    
@kaiser that would be my idea for use in theme. –  Rarst Feb 10 '12 at 12:49
1  
Rarst beat me to it - and I totally missed that @Kaiser was calling this from within a Theme. –  Chip Bennett Feb 10 '12 at 12:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.