[wp-hackers] Definitive way of getting path to plugin

John Blackbourn johnbillion+wp at gmail.com
Fri Nov 23 02:10:06 GMT 2007


Hi everyone,

A plugin of mine references a CSS file which resides in the plugin
directory (wp-content/plugins/myplugin/style.css) but the path is
currently hard-coded as I've found no way to get the directory name of
the plugin. My current code is:

$css = get_bloginfo( 'wpurl' ) . '/' . PLUGINDIR . '/myplugin/style.css' ;

I'd rather not have the "myplugin/" bit hardcoded. Does anyone know of
an elegant way of getting the name of the plugin directory? Or even
the entire path to the plugin?

I've been playing around with dirname(), realpath(), __FILE__ and all
sorts but to no avail. Thanks in advance if anyone is kind enough to
help.


More information about the wp-hackers mailing list