Uninstalls a Plugin (deletes plugin files from the disk)
Only deactivated plugins can be uninstalled

@param $pluginName
@throws \Exception
@return bool
770290
public function uninstallPlugin($pluginName)
    {
        if ($this->isPluginLoaded($pluginName)) {
            throw new \Exception("To uninstall the plugin $pluginName, first disable it in Matomo > Settings > Plugins");
        }
        $this->loadAllPluginsAndGetTheirInfo();

        SettingsStorage\Backend\PluginSettingsTable::removeAllSettingsForPlugin($pluginName);
        SettingsStorage\Backend\MeasurableSettingsTable::removeAllSettingsForPlugin($pluginName);

        $this->executePluginDeactivate($pluginName);
        $this->executePluginUninstall($pluginName);

        $this->removePluginFromPluginsInstalledConfig($pluginName);

        $this->unloadPluginFromMemory($pluginName);

        $this->removePluginFromConfig($pluginName);
        $this->removeInstalledVersionFromOptionTable($pluginName);
        $this->clearCache($pluginName);

        self::deletePluginFromFilesystem($pluginName);
        if ($this->isPluginInFilesystem($pluginName)) {
            return false;
        }

        /**
         * Event triggered after a plugin has been uninstalled.
         *
         * @param string $pluginName The plugin that has been uninstalled.
         */
        Piwik::postEvent('PluginManager.pluginUninstalled', array($pluginName));

        return true;
    }
597666
public function enablePlugin($pluginName)
	{
		if (isset($this->pluginsConfig[$pluginName]))
		{
			$this->pluginsConfig[$pluginName]['isDisabled'] = false;
		}
	}
528158
def uninstall(ctx, plugin):
    
    ensure_inside_venv(ctx)

    if plugin not in get_installed_plugins():
        echo_error("Plugin {} does not seem to be installed.".format(plugin))
        sys.exit(1)

    plugin_name = get_plugin_name(plugin)
    try:
        run_command([sys.executable, '-m', 'pip', 'uninstall', '-y',
                     plugin_name])
    except subprocess.CalledProcessError as e:
        echo_error(
            "Error when trying to uninstall plugin {}. Error message "
            "was:\n\n{}".format(plugin, e.output.decode())
        )
        sys.exit(1)
    else:
        echo_success("Plugin {} uninstalled successfully.".format(plugin))
503462
public function uninstall($moduleName)
    {
        $module = $this->findOrFalse('module_name', $moduleName);
        if ($module)
        {
            $version = $this->def($moduleName, 'version');
            if ($this->checkModuleDepends($moduleName, new Version($version)))
                return false;

            $this->app['events']->fire('modules.uninstall.'.$moduleName, null);

            $module->delete();

            if (!$this->removeAssets($moduleName))
                $this->errors->add('delete_assets', "Unable to delete assets $moduleName");

            if (!$this->removeModuleDirectory($moduleName))
                $this->errors->add('delete_module', "Unable to delete $moduleName");

            return true;
        }
        return false;
    }
1366052
public static function delete(String $name) : Bool
    {
        $name = Info::rpath($name);

        if( ! is_file($name))
        {
            throw new Exception\FileNotFoundException(NULL, $name);
        }
        else
        {
            return unlink($name);
        }
    }
264566
public function deletePlugin($pluginId)
    {
        if (!isset($this->commandPlugin[$pluginId])) {
            return;
        }

        foreach ($this->commandPlugin[$pluginId] as $cmdTxt => $command) {
            unset($this->commands[$cmdTxt]);
        }
        unset($this->commandPlugin[$pluginId]);
    }
914151
public void removePlugin(String name){
		configs.remove(name);
		MoskitoPlugin plugin = plugins.remove(name);
		if (plugin==null){
			log.warn("Trying to remove not registered plugin "+name);
			return;
		}
		try{
			plugin.deInitialize();
		}catch(Exception e){
			log.warn("Couldn't de-initialize plugin "+name+" - "+plugin,e );
		}
	}
809079
public function activatePlugin($pluginName)
    {
        $plugins = $this->pluginList->getActivatedPlugins();
        if (in_array($pluginName, $plugins)) {
            // plugin is already activated
            return;
        }

        if (!$this->isPluginInFilesystem($pluginName)) {
            throw new \Exception("Plugin '$pluginName' cannot be found in the filesystem in plugins/ directory.");
        }
        $this->deactivateThemeIfTheme($pluginName);

        // Load plugin
        $plugin = $this->loadPlugin($pluginName);
        if ($plugin === null) {
            throw new \Exception("The plugin '$pluginName' was found in the filesystem, but could not be loaded.'");
        }
        $this->installPluginIfNecessary($plugin);
        $plugin->activate();

        EventDispatcher::getInstance()->postPendingEventsTo($plugin);

        $this->pluginsToLoad[] = $pluginName;

        $this->updatePluginsConfig($this->pluginsToLoad);
        PiwikConfig::getInstance()->forceSave();

        $this->clearCache($pluginName);

        /**
         * Event triggered after a plugin has been activated.
         *
         * @param string $pluginName The plugin that has been activated.
         */
        Piwik::postEvent('PluginManager.pluginActivated', array($pluginName));
    }
1207201
public function is_plugin_folder_removable($component) {

        $pluginfo = $this->get_plugin_info($component);

        if (is_null($pluginfo)) {
            return false;
        }

        // To be able to remove the plugin folder, its parent must be writable, too.
        if (!is_writable(dirname($pluginfo->rootdir))) {
            return false;
        }

        // Check that the folder and all its content is writable (thence removable).
        return $this->is_directory_removable($pluginfo->rootdir);
    }
1254664
protected function executePluginParser($pluginName)
	{
		$pluginConfig = $this->pluginsConfig[$pluginName];
		if (isset($pluginConfig['quickMatch']) && strpos($this->text, $pluginConfig['quickMatch']) === false)
		{
			return;
		}

		$matches = [];
		if (isset($pluginConfig['regexp']))
		{
			$matches = $this->getMatches($pluginConfig['regexp'], $pluginConfig['regexpLimit']);
			if (empty($matches))
			{
				return;
			}
		}

		// Execute the plugin's parser, which will add tags via $this->addStartTag() and others
		call_user_func($this->getPluginParser($pluginName), $this->text, $matches);
	}
554374
function removePlugin(config, pluginName) {
    var deps = config.getPluginDependencies();

    // For default plugin, we have to disable it instead of removing from the list
    if (isDefaultPlugin(pluginName)) {
        return togglePlugin(config, pluginName, false);
    }

    // Remove the dependency from the list
    deps = deps.filterNot(function(dep) {
        return dep.getName() === pluginName;
    });
    return config.setPluginDependencies(deps);
}
645966
function uninstall(names, callback) {
  callback = utils.defineCallback(callback);
  if (_.isString(names)) {
    names = [ names ];
  }
  var errs = [ ];
  var numPlugins = 0;
  names.forEach(function(name) {
    rimraf(pluginsDir + "/" + name, cb);
  });

  function cb(err) {
    if (err) {
      errs.push(err);
    }
    if (++numPlugins === names.length) {
      return callback(errs.length === 0 ? null : errs);
    }
  }
}
1220646
public function removePlugin($key) {
        if (!isset($this->plugins[$key])) {
            return $this;
        }
        if (method_exists($this->plugins[$key], 'unconfigure')) {
            $this->plugins[$key]->unconfigure($this);
        }
        unset($this->plugins[$key]);
        return $this;
    }
142051
def uninstall(plugin_package, plugins_directory):
    '''
    
    '''
    # Check existing version (if any).
    plugin_path = plugins_directory.joinpath(plugin_package)

    if not plugin_path.isdir():
        raise IOError('Plugin `%s` is not installed in `%s`' %
                      (plugin_package, plugins_directory))
    else:
        try:
            plugin_metadata = yaml.load(plugin_path.joinpath('properties.yml').bytes())
            existing_version = plugin_metadata['version']
        except:
            existing_version = None

    if existing_version is not None:
        # Uninstall existing package.
        print 'Uninstalling `{}=={}`.'.format(plugin_package, existing_version)
    else:
        print 'Uninstalling `{}`.'.format(plugin_package)

    # Uninstall latest release
    # ======================
    plugin_path.rmtree()
    print '  \--> done'
1278243
def release_plugin(self, name):
        
        plugin = self._active_plugins[name]
        if id(plugin) in self._provided_by_preset:
            self._provided_by_preset.remove(id(plugin))

        del self._active_plugins[name]
        delattr(self, name)
1213096
function uninstall($name)
    {
	    $result = array();
    	$result['status'] = false;
	    try {
		    $JFusionAdmin = Factory::getAdmin($name);
		    if ($JFusionAdmin->isConfigured()) {
			    //if this plugin had been valid, call its uninstall function if it exists
			    $success = 0;
			    try {
				    list($success, $reasons) = $JFusionAdmin->uninstall();

				    $reason = '';
				    if (is_array($reasons)) {
					    $reason = implode('</li><li>' . $name . ': ', $reasons);
				    } else {
					    $reason = $name . ': ' . $reasons;
				    }
			    } catch (Exception $e) {
				    $reason = $e->getMessage();
			    }
			    if (!$success) {
				    throw new RuntimeException(Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ' ' . Text::_('FAILED') . ': ' . $reason);
			    }
		    }
		    $db = Factory::getDBO();

		    $query = $db->getQuery(true)
			    ->select('name , original_name')
			    ->from('#__jfusion')
			    ->where('name = ' . $db->quote($name));

		    $db->setQuery($query);
		    $plugin = $db->loadObject();

		    // delete raw
		    $query = $db->getQuery(true)
			    ->delete('#__jfusion')
			    ->where('name = ' . $db->quote($name));
		    $db->setQuery($query);
		    $db->execute();

		    $query = $db->getQuery(true)
			    ->delete('#__jfusion_users')
			    ->where('jname = ' . $db->quote($name));
		    $db->setQuery($query);
		    $db->execute();

		    $event = new Event('onInstallerPluginUninstall');
		    $event->addArgument('name', $name);
		    Factory::getDispatcher()->triggerEvent($event);

		    if ($plugin || !$plugin->original_name) {
			    $dir = JFusionFramework::getPluginPath($name);

			    if (!$name || !is_dir(Path::clean($dir))) {
				    throw new RuntimeException(Text::_('UNINSTALL_ERROR_PATH'));
			    } else {
				    /**
				     * ---------------------------------------------------------------------------------------------
				     * Remove Language files Processing Section
				     * ---------------------------------------------------------------------------------------------
				     */
				    // Get the extension manifest object
				    $manifest = $this->getManifest($dir);
				    if (is_null($manifest)) {
					    throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN'));
				    } else {
					    $this->manifest = $manifest;

					    // remove files
					    if (!Folder::delete($dir)) {
						    throw new RuntimeException(Text::_('UNINSTALL_ERROR_DELETE'));
					    } else {
						    //return success
						    $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UNINSTALL') . ': ' . Text::_('SUCCESS');
						    $result['message'] = $msg;
						    $result['status'] = true;
					    }
				    }
			    }
		    }
	    } catch (Exception $e) {
		    $result['message'] = $name . ' ' . $e->getMessage();
		    $this->installer->abort($e->getMessage());
	    }
        return $result;
    }
58466
public function rollbackPlugin($name)
    {
        /*
         * Remove the plugin database and version
         */
        if (!($plugin = $this->pluginManager->findByIdentifier($name))
            && $this->versionManager->purgePlugin($name)
        ) {
            $this->note('<info>Purged from database:</info> ' . $name);
            return $this;
        }

        if ($this->versionManager->removePlugin($plugin)) {
            $this->note('<info>Rolled back:</info> ' . $name);
            return $this;
        }

        $this->note('<error>Unable to find:</error> ' . $name);

        return $this;
    }