public static function getPluginDirectory($pluginName)
    {
        if (isset(self::$pluginsToPathCache[$pluginName])) {
            return self::$pluginsToPathCache[$pluginName];
        }

        $corePluginsDir = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName;
        if (is_dir($corePluginsDir)) {
            // for faster performance
            self::$pluginsToPathCache[$pluginName] = self::getPluginRealPath($corePluginsDir);
            return self::$pluginsToPathCache[$pluginName];
        }

        foreach (self::getPluginsDirectories() as $dir) {
            $path = $dir . $pluginName;
            if (is_dir($path)) {
                self::$pluginsToPathCache[$pluginName] = self::getPluginRealPath($path);
                return $path;
            }
        }

        // assume default directory when plugin does not exist just yet
        return self::getPluginsDirectory() . $pluginName;
    }