From 38d2269c5f5abb09855e868ce9c23fd011f8044c Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Thu, 26 Jun 2025 07:46:47 -0700 Subject: [PATCH] Add random color SVG icons for updates (#120) Signed-off-by: Andy Fragen Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- inc/icons/namespace.php | 30 ++++++++++++++++++++++++ inc/icons/svg.php | 52 +++++++++++++++++++++++++++++++++++++++++ inc/namespace.php | 1 + plugin.php | 1 + 4 files changed, 84 insertions(+) create mode 100644 inc/icons/namespace.php create mode 100644 inc/icons/svg.php diff --git a/inc/icons/namespace.php b/inc/icons/namespace.php new file mode 100644 index 0000000..2bb9f0c --- /dev/null +++ b/inc/icons/namespace.php @@ -0,0 +1,30 @@ +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; +} diff --git a/inc/icons/svg.php b/inc/icons/svg.php new file mode 100644 index 0000000..2c82ca9 --- /dev/null +++ b/inc/icons/svg.php @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +'; diff --git a/inc/namespace.php b/inc/namespace.php index 8dae326..7b56b3b 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -28,6 +28,7 @@ function bootstrap() { Dashboard_Widgets\bootstrap(); Default_Repo\bootstrap(); Disable_Openverse\bootstrap(); + Icons\bootstrap(); Importers\bootstrap(); Pings\bootstrap(); Salts\bootstrap(); diff --git a/plugin.php b/plugin.php index 97e434d..e2758d0 100644 --- a/plugin.php +++ b/plugin.php @@ -26,6 +26,7 @@ require_once __DIR__ . '/inc/credits/namespace.php'; require_once __DIR__ . '/inc/dashboard-widgets/namespace.php'; require_once __DIR__ . '/inc/default-repo/namespace.php'; require_once __DIR__ . '/inc/disable-openverse/namespace.php'; +require_once __DIR__ . '/inc/icons/namespace.php'; require_once __DIR__ . '/inc/importers/namespace.php'; require_once __DIR__ . '/inc/pings/namespace.php'; require_once __DIR__ . '/inc/salts/namespace.php';