• When hooking activated_plugin (for example), the hook is called with two parameters, $plugin and $network. It looks like $plugin contains only relative path information. If I want to use the get_plugin_data() function, it wants an absolute path.

    How do I obtain this absolute path, given the relative path passed to me, the WordPress way? Everywhere I look, it explicitly states that the WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants are for internal use only.

    Sorry if this has already been beaten to death here and elsewhere. And, please do not suggest I pass __FILE__ to some function. I don’t want to find out the absolute path to my own code.

    I’m obviously doing something wrong, and am hoping for someone to tell me what that wrong is 🙂

    -joho

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Where does it say WP_PLUGIN_DIR is for internal use only? I’m fairly sure that constant is the standard way to get the absolute path of the plugins directory, and then you just append the relative path of the particular plugin you want the data for.

    Thread Starter joho68

    (@joho68)

    https://codex.wordpress.org/Determining_Plugin_and_Content_Directories

    WordPress provides several functions for easily determining where a given file or directory lives. Always use these functions in your plugins instead of hard-coding references to the wp-content directory or using the WordPress internal constants

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Relative plugin paths in some places, absolute paths in other places?’ is closed to new replies.