Gustavo Straube
Member
Posted 3 years ago #
Hi all!
I want to get the plugin directory for a specific plugin, how can I do this? The target is show a image hosted on my plugin directory inside a widget. Something like this:
function my_plugin_widget() {
...
$dir = fn_to_get_plugin_directory();
echo "<img src='{$dir}/img.gif' />";
...
}
Is it possible? Anyone have another suggestion for how can I do this?
Thanks!
Here is one method I use sometimes. To replace the line you have above, try this:
$dir = ABSPATH . 'wp-content/plugins/plugin-folder/img.gif'
Gustavo Straube
Member
Posted 3 years ago #
I've tried to use the ABSPATH constant, but it doesn't work. The value contained in this constant is the full path from my HD root directory (C:\...). There is some constant or var that contains the absolute path from Apache's root directory (http://localhost/...) or something like this?
Thank you!
Gustavo Straube
Member
Posted 3 years ago #
I got this working now!
I'm using bloginfo('wpurl') function followed by the plugin directory path (/wp-content/plugins/...).
Any better way to do this?
Ishimwe
Member
Posted 3 years ago #