Habari\Plugins::list_active PHP Метод

list_active() публичный статический Метод

function list_active Gets a list of active plugin filenames to be included
public static list_active ( boolean $refresh = false ) : array
$refresh boolean Whether to refresh the cached array. Default false
Результат array An array of filenames
    public static function list_active($refresh = false)
    {
        if (empty(self::$plugin_files) || $refresh) {
            $plugins = Options::get('active_plugins');
            if (is_array($plugins)) {
                foreach ($plugins as $class => $filename) {
                    // add base path to stored path
                    if (!preg_match('#^([^:]+://)#i', $filename, $matches)) {
                        $filename = HABARI_PATH . $filename;
                    }
                    // if class is somehow empty we'll throw an error when trying to load it - deactivate the plugin instead
                    if ($class == '') {
                        self::deactivate_plugin($filename, true);
                        EventLog::log(_t('An empty plugin definition pointing to file "%1$s" was removed.', array($filename)), 'err', 'plugin', 'habari');
                        // and skip adding it to the active stack
                        continue;
                    }
                    if (file_exists($filename)) {
                        self::$plugin_files[$class] = $filename;
                    } else {
                        // file does not exist, deactivate plugin
                        self::deactivate_plugin($filename, true);
                        EventLog::log(_t('Plugin "%1$s" deactivated because it could no longer be found.', array($class)), 'err', 'plugin', 'habari', $filename);
                    }
                }
            }
            // make sure things work on Windows
            self::$plugin_files = array_map(function ($s) {
                return str_replace('\\', '/', $s);
            }, self::$plugin_files);
        }
        return self::$plugin_files;
    }