YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.24k stars 405 forks source link

How to load assets folder from Git? #198

Open Streamlinelv opened 6 years ago

Streamlinelv commented 6 years ago

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

YahnisElsts commented 6 years ago

Unfortunately, that's currently not possible. Icons and banners are only available when using JSON metadata.

smadds commented 5 years ago

+1 for this, if you are able to include Github support for icons, @YahnisElsts.

paulmiller3000 commented 4 years ago

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!

YahnisElsts commented 4 years ago

@paulmiller3000 The Puc_v4p8_Plugin_Info class also has a banners property. It should be an associative array with up to two entries:

  1. low: URL of a 772x250 banner image.
  2. 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 commented 4 years ago

@paulmiller3000 The Puc_v4p8_Plugin_Info class also has a banners property. It should be an associative array with up to two entries:

Thanks!!