Added Theme Support, Added Bricks Icon

This commit is contained in:
Stingray82 2025-08-06 20:20:09 +01:00
parent 055ac5119f
commit 3a1db3d84c

View file

@ -21,18 +21,31 @@ Replace `yourusername` with your actual GitHub username or organization name.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ php
add_filter('mainwp_before_save_cached_icons', function ($cached_icons, $icon, $slug, $type, $custom_icon, $noexp) {
$json_url = 'https://raw.githubusercontent.com/stingray82/mainwp-plugin-icons/main/icons-map.json';
$response = wp_remote_get($json_url);

// Determine correct JSON source based on type
$json_url = '';
if ($type === 'plugin') {
$json_url = 'https://raw.githubusercontent.com/stingray82/mainwp-plugin-icons/main/icons-map.json';
} elseif ($type === 'theme') {
$json_url = 'https://raw.githubusercontent.com/stingray82/mainwp-plugin-icons/main/themes-icons-map.json';
} else {
return $cached_icons;
}

// Fetch JSON data
$response = wp_remote_get($json_url);
if (is_wp_error($response)) {
error_log("[MainWP ICONS] Failed to fetch {$type} icon map: " . $response->get_error_message());
return $cached_icons;
}

$icons_map = json_decode(wp_remote_retrieve_body($response), true);
if (!is_array($icons_map)) {
error_log("[MainWP ICONS] Invalid JSON for {$type} icons.");
return $cached_icons;
}

// Inject custom icons if not already cached
foreach ($icons_map as $custom_slug => $custom_icon_url) {
if (!isset($cached_icons[$custom_slug])) {
$cached_icons[$custom_slug] = [
@ -40,13 +53,16 @@ add_filter('mainwp_before_save_cached_icons', function ($cached_icons, $icon, $s
'path_custom' => '',
'path' => urlencode($custom_icon_url),
];

error_log("[MainWP ICONS] Injected {$type} icon for: {$custom_slug}");
}
}

return $cached_icons;

}, 10, 6);


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Repository Structure