fix(navigation): align mega-menu rendering and menu-item backend with the reference

Renderer:
- Graphic-card images carry fit-cover so they crop into the fixed card box
  instead of stretching it and pushing the title out of alignment.
- Mega-menu link icons use fa-fw (fixed glyph column) instead of the
  undefined menu-item-icon class, so link titles line up.

Backend:
- Restore show_policy (login / vip / vip_2 / auth) on menu items; the field
  was missing entirely, so items could not be gated by identity.
- Default submenu_type to graphic_card, badge_class to jb-red, arrangement
  to swiper, size to md.
- Clamp img_scale to 20-300 to match the reference's spinner bounds.
- Drop the now-meaningless "none" submenu_type option: the senior-submenu
  switch is itself the on/off control.
- Admin JS gains the align control (left/center/space-around).

Cleanup:
- Remove the unused header_actions nav menu location.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-05 10:51:36 +08:00
1 parent 55423403a6
commit e6d9ff49a2
6 files changed
+113 -29

No files matched your search

+50 -6
View File
@@ -28,21 +28,26 @@ function jio_menu_pz(int $id, string $key = '', $default = '') {
}
/**
* @param string $icon_class Icon-picker value (FA5 class, jiosvg- or customsvg-).
* @param bool $enabled Global switch.
* @param string $icon_class Icon-picker value (FA5 class, jiosvg- or customsvg-).
* @param bool $enabled Global switch.
* @param string $extra_classes Classes appended to the glyph. Top-level menu
* titles use the default; mega-menu link lists use
* `mr3 fa-fw` so every row's glyph is the same width.
*/
function jio_render_menu_icon(string $icon_class, bool $enabled = true): string {
function jio_render_menu_icon(string $icon_class, bool $enabled = true, string $extra_classes = 'mr3 menu-item-icon'): string {
if (!$enabled || $icon_class === '') {
return '';
}
$extra = trim($extra_classes);
// Sprite/inline values must reach jio_icon_markup untouched — the legacy
// FA class padding below would corrupt them (jiosvg-hot → fa fas fa-jiosvg-hot).
if (str_starts_with($icon_class, 'jiosvg-')) {
return jio_icon_markup($icon_class, 'icon mr3 menu-item-icon');
return jio_icon_markup($icon_class, $extra === '' ? 'icon' : 'icon ' . $extra);
}
if (str_starts_with($icon_class, 'customsvg-')) {
return jio_icon_markup($icon_class, 'mr3 menu-item-icon');
return jio_icon_markup($icon_class, $extra);
}
// legacy uses the Font Awesome 5 `fa` prefix.
@@ -51,7 +56,46 @@ function jio_render_menu_icon(string $icon_class, bool $enabled = true): string
} elseif (strpos($icon_class, 'fa-') === 0 && strpos($icon_class, ' ') === false) {
$icon_class = 'fa ' . $icon_class;
}
return jio_icon_markup($icon_class, 'mr3 menu-item-icon');
return jio_icon_markup($icon_class, $extra);
}
/**
* Whether a menu item passes its display policy (show_policy).
*
* @param int $menu_item_id Menu item ID.
* @return bool
*/
function jio_menu_item_match_show_policy(int $menu_item_id): bool {
$policy = (string) jio_menu_pz($menu_item_id, 'show_policy', '');
if ($policy === '') {
return true;
}
$user_id = get_current_user_id();
if ($user_id <= 0) {
return false;
}
switch ($policy) {
case 'signin':
return true;
case 'vip':
return function_exists('jio_is_vip') && jio_is_vip($user_id);
case 'vip_2':
return function_exists('jio_is_vip2') && jio_is_vip2($user_id);
case 'auth':
if (!function_exists('jio_get_user_identity_signals')) {
return false;
}
foreach (jio_get_user_identity_signals($user_id) as $signal) {
if ((string) ($signal['type'] ?? '') === 'verify') {
return true;
}
}
return false;
}
return true;
}
/**