fix(navigation): stop mangling zibsvg/customsvg menu icons
aksrt_render_menu_icon() prefixed any value without an fa substring with fa fas fa-, turning picker values like zibsvg-hot into fa fas fa-zibsvg-hot — blank icons in the frontend nav. Sprite and inline SVG values now flow through aksrt_icon_markup with the menu-item-icon classes attached; FA values keep the legacy padding.
This commit is contained in:
1 parent
70cba11fb7
commit
2e25894eb5
2 files changed
+40
-2
No files matched your search
@@ -45,20 +45,30 @@ function aksrt_get_menu_item_decoration($menu_item): array {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $icon_class FA5 icon class.
|
||||
* @param string $icon_class Icon-picker value (FA5 class, zibsvg- or customsvg-).
|
||||
* @param bool $enabled Global switch.
|
||||
*/
|
||||
function aksrt_render_menu_icon(string $icon_class, bool $enabled = true): string {
|
||||
if (!$enabled || $icon_class === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Sprite/inline values must reach aksrt_icon_markup untouched — the legacy
|
||||
// fa-prefix padding below would corrupt them (zibsvg-hot → fa fas fa-zibsvg-hot).
|
||||
if (str_starts_with($icon_class, 'zibsvg-')) {
|
||||
return aksrt_icon_markup($icon_class, 'icon mr3 menu-item-icon');
|
||||
}
|
||||
if (str_starts_with($icon_class, 'customsvg-')) {
|
||||
return aksrt_icon_markup($icon_class, 'mr3 menu-item-icon');
|
||||
}
|
||||
|
||||
// legacy uses the Font Awesome 5 `fa` prefix.
|
||||
if (strpos($icon_class, 'fa') === false) {
|
||||
$icon_class = 'fa fas fa-' . ltrim($icon_class, '-');
|
||||
} elseif (strpos($icon_class, 'fa-') === 0 && strpos($icon_class, ' ') === false) {
|
||||
$icon_class = 'fa ' . $icon_class;
|
||||
}
|
||||
return '<i class="' . esc_attr($icon_class) . ' mr3 menu-item-icon" aria-hidden="true"></i>';
|
||||
return aksrt_icon_markup($icon_class, 'mr3 menu-item-icon');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user