fair-plugin/inc/icons/namespace.php
Andy Fragen 38d2269c5f
Add random color SVG icons for updates (#120)
Signed-off-by: Andy Fragen <andy@thefragens.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
2025-06-26 07:46:47 -07:00

30 lines
640 B
PHP

<?php
/**
* Adds a local source for default icon SVG.
*
* @package FAIR
*/
namespace FAIR\Icons;
use FAIR;
function bootstrap(){
add_filter( 'site_transient_update_plugins', __NAMESPACE__ . '\\set_default_icon', 99, 1 );
}
function set_default_icon( $transient ) {
foreach ( $transient->response as $updates ) {
$url = plugin_dir_url( FAIR\PLUGIN_FILE ) . 'inc/icons/svg.php';
$url = add_query_arg( 'color', set_random_color(), $url );
$updates->icons['default'] = $url;
}
return $transient;
}
function set_random_color() {
$rand = str_pad( dechex( rand( 0x000000, 0xFFFFFF ) ), 6, 0, STR_PAD_LEFT );
return $rand;
}