@author Vova Feldman (@svovaf)
@since  1.2.2.7

@param string $plugin_prev_version
@param string $plugin_version
347571
function _after_version_update( $plugin_prev_version, $plugin_version ) {
            if ( $this->is_theme() ) {
                // Expire the cache of the previous tabs since the theme may
                // have setting updates.
                $this->_cache->expire( 'tabs' );
                $this->_cache->expire( 'tabs_stylesheets' );
            }
        }
1025866
private function get_plugin_checksums( $plugin, $version ) {
		$url = str_replace(
			array(
				'{slug}',
				'{version}',
			),
			array(
				$plugin,
				$version,
			),
			$this->url_template
		);

		$options = array(
			'timeout' => 30,
		);

		$headers  = array(
			'Accept' => 'application/json',
		);
		$response = Utils\http_request( 'GET', $url, null, $headers, $options );

		if ( ! $response->success || 200 !== $response->status_code ) {
			return false;
		}

		$body = trim( $response->body );
		$body = json_decode( $body, true );

		if ( ! is_array( $body ) || ! isset( $body['files'] ) || ! is_array( $body['files'] ) ) {
			return false;
		}

		return $body['files'];
	}
1342689
protected function loadPlugin($plugin)
    {
        $pluginName = get_class($plugin);

        $apiVersion = self::API_VERSION_0_9;
        if ($plugin instanceof PicoPluginInterface) {
            if (defined($pluginName . '::API_VERSION')) {
                $apiVersion = $pluginName::API_VERSION;
            } else {
                $apiVersion = self::API_VERSION_1_0;
            }
        }

        if (!isset($this->plugins[$apiVersion][$pluginName])) {
            // PicoDeprecated currently supports all previous API versions
            $this->plugins[$apiVersion][$pluginName] = $plugin;
        }
    }
768339
function update( FS_Plugin $plugin, $store = true ) {
			if ( ! ($this->_module instanceof FS_Plugin ) ||
			     $this->_module->slug != $plugin->slug ||
			     $this->_module->public_key != $plugin->public_key ||
			     $this->_module->secret_key != $plugin->secret_key ||
			     $this->_module->parent_plugin_id != $plugin->parent_plugin_id ||
			     $this->_module->title != $plugin->title
			) {
				$this->store( $plugin, $store );

				return true;
			}

			return false;
		}
75090
private function executePluginInstall(Plugin $plugin)
    {
        try {
            $plugin->install();
        } catch (\Exception $e) {
            throw new \Piwik\Plugin\PluginException($plugin->getPluginName(), $e->getMessage());
        }
    }
524768
public static function in_plugin_update_message( $plugin_data, $r ) {
		$current_version = $plugin_data['Version'];
		$new_version = $plugin_data['new_version'];
		$upgrade_magnitude = self::get_upgrade_magnitude($current_version, $new_version);
		if ( $upgrade_magnitude == 'milestone' ) {
			$message = self::update_message_milestone();
			echo '<br />'.sprintf($message);
			return;
		} elseif ( $upgrade_magnitude == 'major' ) {
			//major version
			$message = self::update_message_major();
			echo '<br />'.sprintf($message);
			return;
		}
		$message = self::update_message_minor();
		echo '<br />'.($message);
		return;

	}
451870
public static function get_instance( $plugin_name, $plugin_file ) {
		if ( ! isset( self::$_instances[ $plugin_name ] ) ) {
			self::$_instances[ $plugin_name ] = new static( $plugin_name, $plugin_file );
		}

		return self::$_instances[ $plugin_name ];
	}
795995
public void addPlugin(final Plugin plugin) {
        // put plugin into the repository's reciever map
        synchronized (pluginMap) {
            String name = plugin.getName();

            // make sure the plugin has reference to repository
            plugin.setLoggerRepository(getLoggerRepository());

            Plugin existingPlugin = (Plugin) pluginMap.get(name);
            if (existingPlugin != null) {
                existingPlugin.shutdown();
            }

            // put the new plugin into the map
            pluginMap.put(name, plugin);
            firePluginStarted(plugin);
        }
    }
1119576
public function enableAction(Plugin $plugin)
    {
        $this->pluginManager->enable($plugin);

        return new JsonResponse(
            $this->pluginManager->getPluginsData()
        );
    }
101950
public function update_plugin( $plugin_slug, $tag = 'master' ) {
		$plugin           = null;
		$is_plugin_active = false;

		foreach ( (array) Singleton::get_instance( 'Plugin', $this )->get_plugin_configs() as $config_entry ) {
			if ( $config_entry->slug === $plugin_slug ) {
				$plugin = $config_entry;
				break;
			}
		}

		if ( ! $plugin ) {
			throw new \UnexpectedValueException( 'Plugin not found or not updatable with GitHub Updater: ' . $plugin_slug );
		}

		if ( is_plugin_active( $plugin->file ) ) {
			$is_plugin_active = true;
		}

		$this->get_remote_repo_meta( $plugin );
		$repo_api = Singleton::get_instance( 'API', $this )->get_repo_api( $plugin->git, $plugin );

		$update = [
			'slug'        => $plugin->slug,
			'plugin'      => $plugin->file,
			'new_version' => null,
			'url'         => $plugin->uri,
			'package'     => $repo_api->construct_download_link( $tag ),
		];

		add_filter(
			'site_transient_update_plugins',
			function ( $current ) use ( $plugin, $update ) {
				$current->response[ $plugin->file ] = (object) $update;

				return $current;
			}
		);

		$upgrader = new \Plugin_Upgrader( $this->upgrader_skin );
		$upgrader->upgrade( $plugin->file );

		if ( $is_plugin_active ) {
			$activate = is_multisite() ? activate_plugin( $plugin->file, null, true ) : activate_plugin( $plugin->file );
			if ( ! $activate ) {
				$this->upgrader_skin->messages[] = 'Plugin reactivated successfully.';
			}
		}
	}
1221825
public static function unload($plugin = null)
    {
        deprecationWarning('Plugin::unload() will be removed in 4.0. Use PluginCollection::remove() or clear()');
        if ($plugin === null) {
            static::getCollection()->clear();
        } else {
            static::getCollection()->remove($plugin);
        }
    }
217717
public function inPluginUpdateMessage( $plugin_data ) {
		$untested_plugins = $this->getUntestedPlugins( $plugin_data['new_version'] );
		if ( ! empty( $untested_plugins ) ) {
			echo $this->blade->render(
				'admin.incompatible-plugins', [
					'version' => $plugin_data['new_version'],
					'plugins' => $untested_plugins,
					'div_class' => 'incompatible-plugin-upgrade-notice',
					'table_class' => 'incompatible-plugin-details-table',
				]
			);
		}
	}
871116
protected function installVagrantPlugin($plugin) {
    if (!$this->getInspector()->isVagrantPluginInstalled($plugin)) {
      $this->logger->warning("The $plugin plugin is not installed! Attempting to install it...");
      $this->taskExec("vagrant plugin install $plugin")->run();
    }
  }
848044
public function preOptionActivePlugins($plugins)
    {
        remove_filter('pre_option_active_plugins', [$this, 'preOptionActivePlugins']);

        if (
            !defined('WP_PLUGIN_DIR') ||
            !defined('WPMU_PLUGIN_DIR') ||
            !is_blog_installed()
        ) {
            return false;
        }

        $this->validatePlugins();

        $haveUnactivatedPlugins = false;
        foreach (array_keys($this->getPlugins()) as $plugin) {
            if ($this->isPluginActive($plugin)) {
                require_once WPMU_PLUGIN_DIR.'/'.$plugin;
            } else {
                $haveUnactivatedPlugins = true;
            }
        }

        if ($haveUnactivatedPlugins) {
            add_action('wp_loaded', [$this, 'activatePlugins']);
        }

        return $plugins;
    }
1128472
public function updatePlugin($plugin, $stopOnVersion = null)
    {
        $code = is_string($plugin) ? $plugin : $this->pluginManager->getIdentifier($plugin);

        if (!$this->hasVersionFile($code)) {
            return false;
        }

        $currentVersion = $this->getLatestFileVersion($code);
        $databaseVersion = $this->getDatabaseVersion($code);

        // No updates needed
        if ($currentVersion == $databaseVersion) {
            $this->note('- <info>Nothing to update.</info>');
            return;
        }

        $newUpdates = $this->getNewFileVersions($code, $databaseVersion);
        foreach ($newUpdates as $version => $details) {
            $this->applyPluginUpdate($code, $version, $details);

            if ($stopOnVersion === $version) {
                return true;
            }
        }

        return true;
    }
864833
private function updateWidget($widgetConfiguration, Plugin $plugin)
    {
        /** @var Widget $widget */
        $widget = $this->em
            ->getRepository('ClarolineCoreBundle:Widget\Widget')
            ->findOneBy(['name' => $widgetConfiguration['name']]);

        if (is_null($widget)) {
            return $this->createWidget($widgetConfiguration, $plugin);
        } else {
            return $this->persistWidget($widgetConfiguration, $widget);
        }
    }
1013011
public function prependPlugin(Plugin ...$plugin): HttpClientConfigurator
    {
        $plugin = array_reverse($plugin);
        foreach ($plugin as $p) {
            array_unshift($this->prependPlugins, $p);
        }

        return $this;
    }