Get a path to a different plugin

My best guess would be:

if ( ! is_file( $dir = WPMU_PLUGIN_DIR . '/pluginb/pluginb.php' ) ) {
    if ( ! is_file( $dir = WP_PLUGIN_DIR . '/pluginb/pluginb.php' ) )
        $dir = null;
}

return $dir;

However, the danger here is still the assumption of the plugin’s “basename” – a well written plugin will still function even when its directory and/or main file has been renamed (for whatever reason).

Which goes back to my original comment – depending on which third-party plugin this is referring to, many authors define their own methods/constants to hold the plugin path – it would make sense to check for their existence & use these instead (if available).

Leave a Comment