plugin-update-checker
plugin-update-checker copied to clipboard
How to load assets folder from Git?
Hi Janis,
First let me thank you for the outstanding work you have done. Really appreciate it! Now my updates are working correctly from my private Bitbucket git repository, but how do we load assets since WordPress says we should leave it out of the trunk folder?
I saw how in the example - plugin.json you had these icons and screenshots linked nicely, but is something like this possible also if updating from git repo?
Thanks
Unfortunately, that's currently not possible. Icons and banners are only available when using JSON metadata.
+1 for this, if you are able to include Github support for icons, @YahnisElsts.
I saw how in the example - plugin.json you had these icons and screenshots linked nicely, but is something like this possible also if updating from git repo?
@smadds I realize this is an old issue, but I ran across it when working on my plugin. My solution was to add the icons to an assets folder at the root of my repo, then include the following snippet:
$myUpdateChecker->addResultFilter( function( $info, $response = null ) {
// Add icons for Dashboard > Updates screen.
$info->icons = array(
'1x' => MY_PLUGIN_ASSET_PATH . 'icon-128x128.png',
'2x' => MY_PLUGIN_ASSET_PATH . 'icon-256x256.png',
);
});
This worked well for icons. Still trying to figure out how to add the banner!
@paulmiller3000
The Puc_v4p8_Plugin_Info
class also has a banners
property. It should be an associative array with up to two entries:
-
low
: URL of a 772x250 banner image. -
high
: URL of a 1544x500 banner image for high-DPI screens.
Here's a modified version of your code example that adds banners instead of icons:
$myUpdateChecker->addResultFilter( function( $info, $response = null ) {
$info->banners = array(
'low' => MY_PLUGIN_ASSET_PATH . 'banner-772x250.png',
'high' => MY_PLUGIN_ASSET_PATH . 'icon-1544x500.png',
);
return $info;
});
I believe you don't necessarily have to provide both URLs. If you only specify one of them, WordPress will just use that image for both regular and high-DPI screens.
For anyone interested in filtering update information, here's a more detailed description of JSON response fields:
https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing
Note: JSON key names usually match $info
object property names.
@paulmiller3000 The
Puc_v4p8_Plugin_Info
class also has abanners
property. It should be an associative array with up to two entries:
Thanks!!