How to get the directory a plugin is in?
What’s the best way to get the name of the directory a WordPress plugin resides in? Currently I am using this:
<?php $dir = str_replace(array('/' . basename(__FILE__), '.php'), array('', ''), plugin_basename(__FILE__)); ?>
This is to get the plugin directory ONLY, without slashes. If a plugin is in
/home/thripp/public_html/wp-content/plugins/my-cool-plugin/plugin.php, this returns “my-cool-plugin”, which is all I want.
- The topic ‘How to get the directory a plugin is in?’ is closed to new replies.