Esempio n. 1
0
 /**
  * Filter the package to add dist and other meta information.
  */
 function filterPackage(CompletePackage $package)
 {
     list($vendor, $shortName) = explode('/', $package->getName());
     // try to get the plugin info - may return an array or null/false
     try {
         $info = $this->getPluginInfo($shortName);
     } catch (RuntimeException $e) {
         if ($io->isVerbose()) {
             $io->writeError($e->getMessage());
         }
         // this allows us to try again for this plugin
         return;
     }
     if ($info) {
         // set the dist info
         $package->setDistType('zip');
         // strip out "tags", "trunk", slashes, and spaces
         $version = preg_replace('/tags|trunk|[\\/ ]/', '', $package->getSourceReference());
         // if there is a version identifier, prepend with a period
         $version = $version ? ".{$version}" : '';
         // set the dist url
         $package->setDistUrl('https://downloads.wordpress.org/plugin/' . urlencode($shortName . $version) . '.zip');
         // set some additional meta info
         // this is inconsequential to the solver, but it gets stored in composer.lock
         // and appears when running `composer show vendor/package`
         if (isset($info['short_description'])) {
             $package->setDescription($info['short_description']);
         }
         if (!empty($info['contributors'])) {
             $authors = [];
             foreach ($info['contributors'] as $name => $homepage) {
                 $authors[] = ['name' => $name, 'homepage' => $homepage];
             }
             $package->setAuthors($authors);
         }
         if (!empty($info['tags'])) {
             $package->setKeywords($info['tags']);
         }
         // URL-ready slug
         $pluginSlug = urlencode($shortName);
         $package->setSupport(['forum' => "https://wordpress.org/support/plugin/{$pluginSlug}/", 'source' => "http://plugins.trac.wordpress.org/browser/{$pluginSlug}/", 'docs' => "https://wordpress.org/plugins/{$pluginSlug}/"]);
         $package->setHomepage("https://wordpress.org/plugins/{$pluginSlug}/");
     } else {
         // null means the package is no longer active
         $package->setAbandoned(true);
     }
 }
Esempio n. 2
0
 /**
  * Filter the package to add dist and other meta information.
  */
 function filterPackage(CompletePackage $package)
 {
     list($vendor, $shortName) = explode('/', $package->getName());
     if (($themeInfo = $this->getThemeInfo()) && isset($themeInfo[$shortName])) {
         $info = $themeInfo[$shortName];
         // set the dist info
         $package->setDistType('zip');
         $package->setDistUrl($info['download_uri']);
         // additional meta info
         $package->setDescription($info['description']);
         $package->setAuthors([['name' => $info['author'], 'homepage' => $info['author_uri']]]);
         $package->setHomepage($info['theme_uri']);
         // is this theme retired?
         if (in_array($shortName, $this->getRetiredThemes())) {
             $package->setAbandoned(true);
         }
     }
 }