feat(navigation): hard-switch to Zibll navigation and Font Awesome 5

This commit is contained in:
kate522 committed 2026-08-18 20:46:21 +08:00
1 parent 3c3ddac8be
commit a0b84977a2
630 files changed
+101647 -11293

No files matched your search

+7 -30
View File
@@ -1,6 +1,6 @@
<?php
/**
* Menu decoration helpers — aksrt_menu_options meta only (zibll zib_menu_pz).
* Menu decoration helpers — Zibll's zib_menu_options contract.
*
* @package AKSRT
*/
@@ -8,30 +8,7 @@
defined('ABSPATH') || exit;
/**
* Global decoration switches (SPA). Per-item data is always from meta.
*
* @return array<string,mixed>
*/
function aksrt_get_menu_decoration_settings(): array {
static $cache = null;
if ($cache !== null) {
return $cache;
}
$all = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_all()
: [];
$cache = [
'icon_enabled' => !isset($all['menu_icon_enabled']) || !empty($all['menu_icon_enabled']),
'badge_enabled' => !isset($all['menu_badge_enabled']) || !empty($all['menu_badge_enabled']),
];
return $cache;
}
/**
* Read one menu item option from post meta aksrt_menu_options.
* Read one menu item option from post meta zib_menu_options.
*
* @param int $id Menu item ID.
* @param string $key Option key.
@@ -41,7 +18,7 @@ function aksrt_get_menu_decoration_settings(): array {
function aksrt_menu_pz(int $id, string $key = '', $default = '') {
static $options = [];
if (!isset($options[$id])) {
$raw = get_post_meta($id, 'aksrt_menu_options', true);
$raw = get_post_meta($id, 'zib_menu_options', true);
$options[$id] = is_array($raw) ? $raw : [];
}
if ($key === '') {
@@ -68,18 +45,18 @@ function aksrt_get_menu_item_decoration($menu_item): array {
}
/**
* @param string $icon_class FA5 / icon class.
* @param string $icon_class FA5 icon class.
* @param bool $enabled Global switch.
*/
function aksrt_render_menu_icon(string $icon_class, bool $enabled = true): string {
if (!$enabled || $icon_class === '') {
return '';
}
// Allow bare "fa-home" → "fas fa-home".
// Zibll uses the Font Awesome 5 `fa` prefix.
if (strpos($icon_class, 'fa') === false) {
$icon_class = 'fas fa-' . ltrim($icon_class, '-');
$icon_class = 'fa fas fa-' . ltrim($icon_class, '-');
} elseif (strpos($icon_class, 'fa-') === 0 && strpos($icon_class, ' ') === false) {
$icon_class = 'fas ' . $icon_class;
$icon_class = 'fa ' . $icon_class;
}
return '<i class="' . esc_attr($icon_class) . ' mr3 menu-item-icon" aria-hidden="true"></i>';
}