WordPress.org

Ready to get started?Download WordPress

Forums

How to get the directory a plugin is in? (1 post)

  1. richardxthripp
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by richardxthripp
  • This topic is not resolved
  • WordPress version: 3.0.1