Add support for "Requires PHP" header fields.
In the update metadata the field is called "requires_php". Closes #355
This commit is contained in:
parent
ce3f43c10f
commit
9748abe1bd
|
|
@ -27,6 +27,7 @@ if ( !class_exists('Puc_v4p9_Plugin_Info', false) ):
|
|||
|
||||
public $requires;
|
||||
public $tested;
|
||||
public $requires_php;
|
||||
public $upgrade_notice;
|
||||
|
||||
public $rating;
|
||||
|
|
@ -94,6 +95,7 @@ if ( !class_exists('Puc_v4p9_Plugin_Info', false) ):
|
|||
$sameFormat = array(
|
||||
'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
|
||||
'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
|
||||
'requires_php',
|
||||
);
|
||||
foreach($sameFormat as $field){
|
||||
if ( isset($this->$field) ) {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,12 @@ if ( !class_exists('Puc_v4p9_Plugin_Update', false) ):
|
|||
public $homepage;
|
||||
public $upgrade_notice;
|
||||
public $tested;
|
||||
public $requires_php = false;
|
||||
public $icons = array();
|
||||
public $filename; //Plugin filename relative to the plugins directory.
|
||||
|
||||
protected static $extraFields = array(
|
||||
'id', 'homepage', 'tested', 'upgrade_notice', 'icons', 'filename',
|
||||
'id', 'homepage', 'tested', 'requires_php', 'upgrade_notice', 'icons', 'filename',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -79,6 +80,7 @@ if ( !class_exists('Puc_v4p9_Plugin_Update', false) ):
|
|||
$update->id = $this->id;
|
||||
$update->url = $this->homepage;
|
||||
$update->tested = $this->tested;
|
||||
$update->requires_php = $this->requires_php;
|
||||
$update->plugin = $this->filename;
|
||||
|
||||
if ( !empty($this->upgrade_notice) ) {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,8 @@ if ( !class_exists('Puc_v4p9_Vcs_PluginUpdateChecker') ):
|
|||
'Tested WP' => 'tested',
|
||||
'Requires at least' => 'requires',
|
||||
'Tested up to' => 'tested',
|
||||
|
||||
'Requires PHP' => 'requires_php',
|
||||
);
|
||||
foreach ($headerToPropertyMap as $headerName => $property) {
|
||||
if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) {
|
||||
|
|
@ -172,6 +174,9 @@ if ( !class_exists('Puc_v4p9_Vcs_PluginUpdateChecker') ):
|
|||
if ( !empty($readme['requires_at_least']) ) {
|
||||
$pluginInfo->requires = $readme['requires_at_least'];
|
||||
}
|
||||
if ( !empty($readme['requires_php']) ) {
|
||||
$pluginInfo->requires_php = $readme['requires_php'];
|
||||
}
|
||||
|
||||
if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) {
|
||||
$pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version];
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ class PucReadmeParser {
|
|||
else
|
||||
$tested_up_to = NULL;
|
||||
|
||||
// Requires PHP: 5.2.4
|
||||
if ( preg_match('|Requires PHP:(.*)|i', $file_contents, $_requires_php) ) {
|
||||
$requires_php = $this->sanitize_text( $_requires_php[1] );
|
||||
} else {
|
||||
$requires_php = null;
|
||||
}
|
||||
|
||||
// Stable tag: 10.4-ride-the-fire-eagle-danger-day
|
||||
if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) )
|
||||
|
|
@ -196,6 +202,7 @@ class PucReadmeParser {
|
|||
'tags' => $tags,
|
||||
'requires_at_least' => $requires_at_least,
|
||||
'tested_up_to' => $tested_up_to,
|
||||
'requires_php' => $requires_php,
|
||||
'stable_tag' => $stable_tag,
|
||||
'contributors' => $contributors,
|
||||
'donate_link' => $donate_link,
|
||||
|
|
|
|||
Loading…
Reference in New Issue