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

Stephen Rider wp-hackers at striderweb.com
Fri Nov 23 04:01:08 GMT 2007


This works even better:

PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)

plugin_basename() is a standard WordPress function.

:)

Stephen

On Nov 22, 2007, at 8:10 PM, John Blackbourn wrote:

> 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.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list