Check if $plugin is active and return it's template paths or return the aps template paths.

@param string|null $plugin The plugin in question.

@return array
422014
private function getPaths($plugin): array
    {
        if ($plugin === null || !Plugin::loaded($plugin)) {
            return App::path('Template');
        }

        return App::path('Template', $plugin);
    }
791688
public static function getPluginModels($plugin) {
        return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
            $search = 'Model';
            $core = Configure::read('Admin.coreName') ?: 'Core';

            if ($plugin !== $core) {
                $search = $plugin . '.' . $search;
            }

            // Fetch models and filter out AppModel's
            $models = array_filter(App::objects($search), function($value) {
                return (mb_strpos($value, 'AppModel') === false);
            });

            // Filter out models that don't connect to the database or are admin disabled
            $map = array();
            $ignore = Configure::read('Admin.ignoreModels');

            foreach ($models as $model) {
                list($plugin, $model, $id, $class) = Admin::parseName($plugin . '.' . $model);

                if (in_array($id, $ignore)) {
                    continue;
                }

                $object = Admin::introspectModel($id);

                if (!$object) {
                    continue;
                }

                $map[] = array_merge($object->admin, array(
                    'id' => $id,
                    'title' => $object->pluralName,
                    'alias' => $model,
                    'class' => $class,
                    'url' => Inflector::underscore($id),
                    'installed' => Admin::isModelInstalled($id),
                    'group' => $object->useDbConfig
                ));
            }

            return $map;
        });
    }
726722
public function getRequiredBy($plugin)
    {
        $requiredBy = [];
        $plugin = $this->getBundle($plugin);

        foreach ($this->getInstalledBundles() as $bundle) {
            $requirements = $bundle['instance']->getRequiredPlugins();
            if (in_array(get_class($plugin), $requirements)) {
                $requiredBy[] = get_class($bundle['instance']);
            }
        }

        return $requiredBy;
    }
632388
public function validate(PluginBundleInterface $plugin)
    {
        $validationErrors = [];

        foreach ($this->checkers as $checker) {
            if (null !== $errors = $checker->check($plugin, $this->isInUpdateMode())) {
                $validationErrors = array_merge($validationErrors, $errors);
                continue;
            }

            if ($checker instanceof ConfigurationChecker) {
                $this->pluginConfiguration = $checker->getProcessedConfiguration();
            }
        }

        return $validationErrors;
    }
121180
private static function get_network_plugins() {
            self::require_plugin_essentials();

            $all_plugins = fs_get_plugins();

            $network_active_basenames = is_multisite() ?
                get_site_option( 'active_sitewide_plugins' ) :
                array();

            foreach ( $all_plugins as $basename => &$data ) {
                // By default set to inactive (next foreach update the active plugins).
                $data['is_active'] = false;
                // Enrich with plugin slug.
                $data['slug'] = self::get_plugin_slug( $basename );
            }

            // Flag active plugins.
            foreach ( $network_active_basenames as $basename ) {
                if ( isset( $all_plugins[ $basename ] ) ) {
                    $all_plugins[ $basename ]['is_active'] = true;
                }
            }

            return $all_plugins;
        }
748003
public static function findByPluginID($pluginID)
    {
        if (is_null(self::$plugins)) {
            self::loadAllPlugins();
        }

        foreach (self::$plugins as $plugin) { /* @var $plugin \Stagehand\TestRunner\Core\Plugin\PluginInterface */
            if (strtolower($plugin->getPluginID()) == strtolower($pluginID)) {
                return $plugin;
            }
        }
    }
152367
public function get_all_plugins_paths()
	{
	    $plugin_names = CakePlugin::loaded();
	    
	    $plugin_paths = array();
	    foreach($plugin_names as $plugin_name)
	    {
	        $plugin_paths[] = CakePlugin::path($plugin_name);
	    }
	    
	    return $plugin_paths;
	}
1315337
public function get_enabled_plugins($type) {
        $this->load_enabled_plugins();
        if (isset($this->enabledplugins[$type])) {
            return $this->enabledplugins[$type];
        }
        return null;
    }
685429
protected function getActivePlugins(): array
    {
        if ($this->activePlugins) {
            return $this->activePlugins;
        }

        $this->activePlugins = (array) get_option('active_mu_plugins', []);

        return $this->activePlugins;
    }
663731
public function validatePlugin($plugin)
    {
        //bug fix: not all plugin implements the ViewHelperInterface
        //eg: PaginationControl, but it has the setView method so it's ok to inject
        if ($plugin instanceof ViewHelperInterface || method_exists($plugin, 'setView')) {
            // we're okay
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement Zend_View_Helper_Interface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin))
        ));
    }
849899
public static function getDimensions(Plugin $plugin)
    {
        $dimensions = $plugin->findMultipleComponents('Columns', '\\Piwik\\Plugin\\Dimension\\VisitDimension');
        $instances  = array();

        foreach ($dimensions as $dimension) {
            $instances[] = new $dimension();
        }

        return $instances;
    }
617409
public function getResourcePaths($domain = null) {
        return isset($this->_paths[$domain]) ? $this->_paths[$domain] : $this->_paths;
    }
697395
public function getBundle($plugin)
    {
        $shortName = $this->getPluginShortName($plugin);

        foreach ($this->getInstalledBundles() as $bundle) {
            if ($bundle['instance']->getName() === $shortName) {
                return $bundle['instance'];
            }
        }

        return null;
    }
83885
protected function getPlugin($plugin)
    {
        try {
            list($vendor, $package) = explode('/', $plugin);

            return $this->get('anime_db.api.client')->getPlugin($vendor, $package);
        } catch (\RuntimeException $e) {
            return;
        }
    }
453731
public function getMissingRequirements($plugin)
    {
        $requirements = $this->getRequirements($plugin);
        $bundle = $this->getBundle($plugin);

        return [
            'extensions' => $this->checkExtensionRequirements($requirements['extensions']),
            'plugins' => $this->checkPluginsRequirements($requirements['plugins']),
            'extras' => $this->checkExtraRequirements($bundle->getExtraRequirements()),
        ];
    }
1242763
protected function _getBasePath($plugin = false)
    {
        if ($plugin !== false) {
            return $this->_getPluginPath($plugin) . 'webroot' . DS;
        }

        return WWW_ROOT;
    }
1234975
static public function loadPlugin($plugin=null)
	{
	    $path = Config::getPluginPath();
	    if ($plugin) {
	        $pluginPath = $path . trim($plugin, '/') . '/autoload.php';
	        static::load($pluginPath);
	    }
	}