diff --git a/plugin-update-checker.php b/plugin-update-checker.php
index b565f597..fc4c665a 100644
--- a/plugin-update-checker.php
+++ b/plugin-update-checker.php
@@ -1027,7 +1027,7 @@ public static function fromJson($json){
}
//Very, very basic validation.
- $valid = isset($apiResponse->name) && !empty($apiResponse->name) && isset($apiResponse->version) && !empty($apiResponse->version);
+ $valid = isset($apiResponse->name, $apiResponse->version) && !empty($apiResponse->name) && !empty($apiResponse->version);
if ( !$valid ){
trigger_error(
"The plugin metadata file does not contain the required 'name' and/or 'version' keys.",
@@ -1040,6 +1040,9 @@ public static function fromJson($json){
foreach(get_object_vars($apiResponse) as $key => $value){
$info->$key = $value;
}
+
+ //json_decode decodes assoc. arrays as objects. We want it as an array.
+ $info->sections = (array)$info->sections;
return $info;
}
@@ -1068,20 +1071,8 @@ public function toWpFormat(){
//Other fields need to be renamed and/or transformed.
$info->download_link = $this->download_url;
-
- if ( !empty($this->author_homepage) ){
- $info->author = sprintf('%s', $this->author_homepage, $this->author);
- } else {
- $info->author = $this->author;
- }
-
- if ( is_object($this->sections) ){
- $info->sections = get_object_vars($this->sections);
- } elseif ( is_array($this->sections) ) {
- $info->sections = $this->sections;
- } else {
- $info->sections = array('description' => '');
- }
+ $info->author = $this->getFormattedAuthor();
+ $info->sections = array_merge(array('description' => ''), $this->sections);
if ( !empty($this->banners) ) {
//WP expects an array with two keys: "high" and "low". Both are optional.
@@ -1092,6 +1083,13 @@ public function toWpFormat(){
return $info;
}
+
+ protected function getFormattedAuthor() {
+ if ( !empty($this->author_homepage) ){
+ return sprintf('%s', $this->author_homepage, $this->author);
+ }
+ return $this->author;
+ }
}
endif;