false, 'echo' => false, 'fallback_cb' => false, 'items_wrap' => '', 'theme_location' => $location, ]; if ($walker) { $args['walker'] = $walker; } if (!wp_is_mobile()) { $args['depth'] = 0; } else { $args['depth'] = 3; } $menu = ''; if (has_nav_menu($location)) { $menu = (string) wp_nav_menu($args); } if ($menu === '' && is_super_admin()) { $menu = ''; } if ($echo) { echo $menu; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return; } return $menu; } endif; if (!function_exists('aksrt_navbar_header')) : /** * Logo + mobile toggles (zibll zib_navbar_header). * * @param array $ctx */ function aksrt_navbar_header(array $ctx): void { $brand_name = (string) ($ctx['brand_name'] ?? get_bloginfo('name')); $logo_inner = !empty($ctx['logo_html']) ? $ctx['logo_html'] : '' . esc_html($brand_name) . ''; $logo = ''; $button = ''; if (($ctx['mobile_layout'] ?? 'center') === 'center' && !empty($ctx['search_enabled'])) { $button .= ''; } echo ''; } endif; if (!function_exists('aksrt_get_menu_search')) : /** * Layout-2 inline search form (zibll zib_get_menu_search simplified). * * @param array $ctx */ function aksrt_get_menu_search(array $ctx): void { if (is_search()) { return; } $placeholder = (string) ($ctx['search_placeholder'] ?? __('搜索内容', 'aksrt')); // zibll: form + input + remote-box (action=menu_search). echo ''; } endif; if (!function_exists('aksrt_header_user_box_html')) : /** * User dropdown inner content for nav sub-menu (logged-in / guest). * * @param array $ctx */ function aksrt_header_user_box_html(array $ctx): string { static $html = null; if ($html !== null) { return $html; } if (empty($ctx['user_menu'])) { $html = ''; return $html; } $user_id = (int) ($ctx['user_id'] ?? 0); $con = ''; if ($user_id > 0) { $user = $ctx['current_user'] instanceof WP_User ? $ctx['current_user'] : wp_get_current_user(); $display_name = $user->display_name ?: $user->user_login; $avatar = get_avatar($user_id, 44, '', esc_attr($display_name), ['loading' => 'lazy']); $desc = (string) ($ctx['user_desc'] ?? ''); $vip_badge = function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($user_id, 'sm') : ''; $payvip = function_exists('aksrt_header_payvip_bar') ? aksrt_header_payvip_bar($user_id) : ''; // nav_user_pay_vip gate: empty payvip when switch off for non-VIP CTA only — helper already handles VIP status. if (empty($ctx['nav_user_pay_vip']) && $payvip !== '' && strpos($payvip, 'is-vip') === false) { $payvip = ''; } $checkin = function_exists('aksrt_header_user_checkin_btn') ? aksrt_header_user_checkin_btn($user_id) : ''; $wallet = function_exists('aksrt_header_user_wallet_mini') ? aksrt_header_user_wallet_mini($user_id) : ''; $badges = function_exists('aksrt_header_user_badges_row') ? aksrt_header_user_badges_row($user_id) : ''; $unread = (int) ($ctx['unread_count'] ?? 0); $msg_url = (string) ($ctx['messages_url'] ?? ''); $msg_icon = ''; if ($msg_url !== '') { $msg_icon = ''; $msg_icon .= ''; if ($unread > 0) { $msg_icon .= '' . esc_html((string) min(99, $unread)) . ''; } $msg_icon .= ''; } $href = '
'; $href .= ''; $href .= '
'; $href .= '
' . esc_html__('用户中心', 'aksrt') . '
'; $orders = (string) ($ctx['orders_url'] ?? ''); if ($orders !== '') { $href .= ''; $href .= '
'; $href .= '
' . esc_html__('我的订单', 'aksrt') . '
'; } if (!empty($ctx['can_publish'])) { $all = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : []; $pub_text = (string) ($all['header_user_newposts_text'] ?? ''); if ($pub_text === '') { $pub_text = __('发布内容', 'aksrt'); } $pub_type = sanitize_key((string) ($all['header_user_newposts_btn'] ?? 'post')); $pub_url = (string) $ctx['publish_url']; if ($pub_type === 'topic' && function_exists('aksrt_get_forum_compose_url')) { $u = aksrt_get_forum_compose_url(); if ($u) { $pub_url = $u; } } elseif ($pub_type === 'product') { if (function_exists('aksrt_get_product_edit_url')) { $u = (string) aksrt_get_product_edit_url(); if ($u !== '') { $pub_url = $u; } } else { $pub_url = admin_url('post-new.php?post_type=aksrt_product'); } } $href .= ''; $href .= '
'; $href .= '
' . esc_html($pub_text) . '
'; } $href .= ''; $href .= '
'; $href .= '
' . esc_html__('退出登录', 'aksrt') . '
'; $href .= '
'; if (is_super_admin()) { $href .= '
'; $href .= ''; $href .= '
'; $href .= '
' . esc_html__('主题设置', 'aksrt') . '
'; // zibll: 模块布局 → widgets. $href .= ''; $href .= '
'; $href .= '
' . esc_html__('模块布局', 'aksrt') . '
'; // zibll: 商城中心. $shop_url = post_type_exists('aksrt_product') ? admin_url('edit.php?post_type=aksrt_product') : admin_url('admin.php?page=aksrt_pay'); $href .= ''; $href .= '
'; $href .= '
' . esc_html__('商城中心', 'aksrt') . '
'; $href .= ''; $href .= '
'; $href .= '
' . esc_html__('后台管理', 'aksrt') . '
'; $href .= '
'; } $con = ''; $con .= $payvip ? $payvip : ''; $con .= $checkin ? '
' . $checkin . '
' : ''; $con .= $wallet ? '
' . $wallet . '
' : ''; $con .= $badges; $con .= '
'; $con .= '
' . $href . '
'; } else { $vip_guest = ''; if (!empty($ctx['nav_user_pay_vip']) && class_exists('\AKSRT\Settings\Settings')) { $vs = \AKSRT\Settings\Settings::get_payment_vip_settings(); if (!empty($vs['enabled'])) { $vip_guest = '
'; } } $href = $vip_guest; $href .= '
'; $href .= ''; if (get_option('users_can_register')) { $href .= ''; } $href .= '
' . esc_html__('找回密码', 'aksrt') . '
'; $href .= '
'; $con = '
' . $href . '
'; if (class_exists('\AKSRT\Auth\OAuth') && method_exists(\AKSRT\Auth\OAuth::get_instance(), 'render_social_buttons')) { $oauth_html = (string) \AKSRT\Auth\OAuth::get_instance()->render_social_buttons(__('快速登录', 'aksrt')); if ($oauth_html !== '') { $con .= ''; $con .= ''; } } } $html = '
' . $con . '
'; return $html; } endif; if (!function_exists('aksrt_menu_button')) : /** * Right cluster: fold, publish/VIP, theme, user, search (zibll zib_menu_button). * * @param array $ctx */ function aksrt_menu_button(array $ctx): void { $layout = (string) ($ctx['layout'] ?? '1'); $user_id = (int) ($ctx['user_id'] ?? 0); $button = ''; // Publish + VIP (respect nav_pay_vip). if (function_exists('aksrt_render_header_menu_buttons')) { $button .= aksrt_render_header_menu_buttons(); } // Theme toggle. $radius_but = ''; if (in_array('pc_nav', (array) ($ctx['theme_positions'] ?? []), true)) { $radius_but .= ''; $radius_but .= ''; $radius_but .= ''; $radius_but .= ''; } if (function_exists('aksrt_get_translate_language_btn')) { $radius_but .= aksrt_get_translate_language_btn('ml10 pull-right'); } if ($radius_but !== '') { $button .= ''; } // User + search. $sign_but = ''; $user_sub = ''; if (!empty($ctx['user_menu'])) { $user_sub = '
' . aksrt_header_user_box_html($ctx) . '
'; if ('2' === $layout) { if ($user_id > 0) { $avatar = get_avatar($user_id, 36, '', '', ['loading' => 'lazy', 'class' => 'avatar']); $sign_but = '
  • ' . $avatar . '
  • '; } else { $sign_but = '
  • '; if (get_option('users_can_register')) { $sign_but .= '
  • '; } } } else { $trigger = $user_id > 0 ? get_avatar($user_id, 36, '', '', ['loading' => 'lazy']) : ''; $cls = $user_id > 0 ? 'navbar-avatar' : 'btn signin-loader'; $dot = ($user_id > 0 && (int) ($ctx['unread_count'] ?? 0) > 0) ? '' : ''; $sign_but = '
  • ' . $trigger . $dot . '
  • '; } } $search_but = ''; if ('2' !== $layout && !empty($ctx['search_enabled'])) { $search_but = '
  • '; } $right_but = ''; $fold = ''; $html = $fold; if ('3' === $layout) { $html .= $right_but . $button; } else { $html .= $button . $right_but; } echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } endif;