Open sudar opened 6 years ago
@sduar,
Here is my analysis on the update icons so far.
This update icons is only applicable on the Updates screen which can be reached using Dashboard
⟶ Updates
There are two places where we have to make the code changes.
<?php
/**
* Filter the EDD license response data to include icons for our Downloads.
* This has to be run from your server.
* For testing, you may have to clear edd_api_request_{%} transient key (3 hours) on the client side.
*
* @param (array) $response - All response data (e.g. new_version, package, etc.)
* @param (object) $download - EDD_SL_Download
*
* @return (array) $response
*
* @author Ren Ventura (renventura.com)
*/
function rv_eddsl_api_response_add_update_icons( $response, $download ) {
// Retrieve icon URLs
$response['icons'] = serialize( array(
'svg' => '',
'1x' => '',
'2x' => '',
'default' => ''
) );
return $response;
}
add_filter( 'edd_sl_license_response', 'rv_eddsl_api_response_add_update_icons', 5, 2 );
The following are the action items from Step 1.
$response['icons']
array.<?php
/**
* Filter the transient data for our plugin's icons.
* Since icons are passed back as serialized arrays, we need to unserialize them.
* This has to be run from within your plugin.
*
* @param (object) $transient - Full transient data
* @return (object) $transient
*
* @author Ren Ventura (renventura.com)
*/
function rv_update_plugins_transient_unserialize_icons( $transient ) {
if ( is_object( $transient ) && isset( $transient->response ) && is_array( $transient->response ) ) {
$basename = plugin_basename( __FILE__ );
// Received a response for our plugin
$plugin = isset( $transient->response[$basename] ) ? $transient->response[$basename] : new stdClass;
// Are there any icons set for the plugin?
if ( isset( $plugin->icons ) ) {
$icons = is_string( $plugin->icons ) ? unserialize( $plugin->icons ) : $plugin->icons;
$transient->response[$basename]->icons = $icons;
}
}
return $transient;
}
add_filter( 'pre_set_site_transient_update_plugins', 'rv_update_plugins_transient_unserialize_icons', 99 );
https://renventura.com/adding-update-icons-for-commercial-plugins/