Skip to content

Commit

Permalink
Added support for plugin banners
Browse files Browse the repository at this point in the history
Usage: 
Add a new key named "banners" to the metadata file. It should be a JSON object with two string properties: "low" and "high". "low" must be a fully qualified URL pointing to a 772x250 image (PNG or JPG). "high" must point to a 1544x500 image. Only one of "low" or "high" is required. 

Example:
{
    "banners" : {
        "low" : "//example.com/assets/banner-772x250.png",
        "high" : "//example.com/assets/banner-1544x500.png"
    }
}

Banners are entirely optional.
  • Loading branch information
YahnisElsts committed Feb 5, 2015
1 parent b8102ed commit a0ee8ca
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions plugin-update-checker.php
@@ -1,9 +1,9 @@
<?php
/**
* Plugin Update Checker Library 1.6.1
* Plugin Update Checker Library 1.6.2
* http://w-shadow.com/
*
* Copyright 2014 Janis Elsts
* Copyright 2015 Janis Elsts
* Released under the MIT license. See license.txt for details.
*/

Expand All @@ -13,7 +13,7 @@
* A custom plugin update checker.
*
* @author Janis Elsts
* @copyright 2014
* @copyright 2015
* @version 1.6
* @access public
*/
Expand Down Expand Up @@ -734,8 +734,8 @@ public function initDebugBarPanel() {
* A container class for holding and transforming various plugin metadata.
*
* @author Janis Elsts
* @copyright 2014
* @version 1.6
* @copyright 2015
* @version 1.6.2
* @access public
*/
class PluginInfo_1_6 {
Expand All @@ -746,6 +746,7 @@ class PluginInfo_1_6 {
public $version;
public $homepage;
public $sections;
public $banners;
public $download_url;

public $author;
Expand Down Expand Up @@ -843,7 +844,14 @@ public function toWpFormat(){
} else {
$info->sections = array('description' => '');
}


if ( !empty($this->banners) ) {
//WP expects an array with two keys: "high" and "low". Both are optional.
//Docs: https://wordpress.org/plugins/about/faq/#banners
$info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
$info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
}

return $info;
}
}
Expand All @@ -856,7 +864,7 @@ public function toWpFormat(){
* A simple container class for holding information about an available update.
*
* @author Janis Elsts
* @copyright 2014
* @copyright 2015
* @version 1.6
* @access public
*/
Expand Down

0 comments on commit a0ee8ca

Please sign in to comment.