From a0ee8ca0a71b21b80c124d2cb44935759126baae Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Thu, 5 Feb 2015 17:28:16 +0200 Subject: [PATCH] Added support for plugin banners 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. --- plugin-update-checker.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugin-update-checker.php b/plugin-update-checker.php index 601d50a..979dc84 100644 --- a/plugin-update-checker.php +++ b/plugin-update-checker.php @@ -1,9 +1,9 @@ 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; } } @@ -856,7 +864,7 @@ if ( !class_exists('PluginUpdate_1_6') ): * A simple container class for holding information about an available update. * * @author Janis Elsts - * @copyright 2014 + * @copyright 2015 * @version 1.6 * @access public */