Skip to content

Commit

Permalink
Merge pull request #16 from jrfnl/Support-plugin-dependencies-metadata
Browse files Browse the repository at this point in the history
Add support for metainfo about plugin dependencies
  • Loading branch information
YahnisElsts committed Sep 25, 2014
2 parents c896259 + 1f40956 commit 5ca60e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
19 changes: 12 additions & 7 deletions includes/Wpup/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ public static function extractMetadata($zipFilename){
if ( isset($packageInfo['header']) && !empty($packageInfo['header']) ){
$mapping = array(
'Name' => 'name',
'Version' => 'version',
'PluginURI' => 'homepage',
'ThemeURI' => 'homepage',
'Author' => 'author',
'AuthorURI' => 'author_homepage',
'DetailsURI' => 'details_url', //Only for themes.
'Version' => 'version',
'PluginURI' => 'homepage',
'ThemeURI' => 'homepage',
'Author' => 'author',
'AuthorURI' => 'author_homepage',
'DetailsURI' => 'details_url', //Only for themes.
'Depends' => 'depends', // plugin-dependencies plugin
'Provides' => 'provides', // plugin-dependencies plugin
);
foreach($mapping as $headerField => $metaField){
if ( array_key_exists($headerField, $packageInfo['header']) && !empty($packageInfo['header'][$headerField]) ){
Expand All @@ -145,7 +147,10 @@ public static function extractMetadata($zipFilename){
}

if ( !empty($packageInfo['readme']) ){
$mapping = array('requires', 'tested');
$mapping = array(
'requires',
'tested',
);
foreach($mapping as $readmeField){
if ( !empty($packageInfo['readme'][$readmeField]) ){
$meta[$readmeField] = $packageInfo['readme'][$readmeField];
Expand Down
13 changes: 13 additions & 0 deletions includes/extension-meta/extension-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public static function getPluginHeaders($fileContents) {
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
'Network' => 'Network',
'Depends' => 'Depends',
'Provides' => 'Provides',

//Site Wide Only is deprecated in favor of Network.
'_sitewide' => 'Site Wide Only',
);
Expand All @@ -277,6 +280,16 @@ public static function getPluginHeaders($fileContents) {

//For backward compatibility by default Title is the same as Name.
$headers['Title'] = $headers['Name'];

//"Depends" is a comma-separated list. Convert it to an array.
if ( !empty($headers['Depends']) ){
$headers['Depends'] = array_map('trim', explode(',', $headers['Depends']));
}

//Same for "Provides"
if ( !empty($headers['Provides']) ){
$headers['Provides'] = array_map('trim', explode(',', $headers['Provides']));
}

//If it doesn't have a name, it's probably not a plugin.
if ( empty($headers['Name']) ){
Expand Down

0 comments on commit 5ca60e9

Please sign in to comment.