Files
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.

Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
  cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
  window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)

Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
  so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
  (dropped 3 stale entries, added the 17 missing ones)

Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
  get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
  when it is empty

Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.

Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-01 20:05:04 +08:00

181 lines
6.3 KiB
PHP

<?php
/**
* Header shell orchestration (legacy contract).
*
* @package Jio
*/
defined('ABSPATH') || exit;
if (!function_exists('jio_get_header_nav_context')) :
/**
* Shared header render context (settings + brand + user flags).
*
* @return array<string,mixed>
*/
function jio_get_header_nav_context(): array {
static $ctx = null;
if ($ctx !== null) {
return $ctx;
}
$settings = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::read_domain('page_display', 'header-nav')
: [];
$layout = sanitize_key((string) ($settings['header_layout'] ?? '1'));
if (!in_array($layout, ['1', '2', '3'], true)) {
$layout = '1';
}
$mobile_layout = sanitize_key((string) ($settings['mobile_header_layout'] ?? 'center'));
if (!in_array($mobile_layout, ['center', 'left'], true)) {
$mobile_layout = 'center';
}
$mobile_align = sanitize_key((string) ($settings['mobile_navbar_align'] ?? 'left'));
if (!in_array($mobile_align, ['top', 'left', 'right'], true)) {
$mobile_align = 'left';
}
$nav_fixed = !isset($settings['nav_fixed']) || !empty($settings['nav_fixed']);
$site_name = get_bloginfo('name');
$brand_name = function_exists('jio_get_site_logo_text') ? jio_get_site_logo_text() : $site_name;
$brand_name = $brand_name !== '' ? $brand_name : $site_name;
$logo_url = function_exists('jio_get_site_logo_url') ? trim((string) jio_get_site_logo_url()) : '';
$logo_dark = function_exists('jio_get_site_logo_dark_url') ? trim((string) jio_get_site_logo_dark_url()) : '';
$logo_width = function_exists('jio_get_site_logo_width') ? jio_get_site_logo_width() : 150;
$logo_more = $logo_width > 0
? 'style="height:36px;width:auto;max-width:' . max(36, (int) $logo_width) . 'px"'
: 'style="height:36px;width:auto"';
$logo_html = '';
if ($logo_url !== '' || $logo_dark !== '') {
$logo_html = function_exists('jio_get_adaptive_theme_img')
? jio_get_adaptive_theme_img($logo_url, $logo_dark, $brand_name, $logo_more)
: '';
}
$theme_positions = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::get_theme_mode_button_positions()
: ['pc_nav', 'm_menu'];
$can_publish = (!isset($settings['nav_newposts']) || !empty($settings['nav_newposts'])) && (
current_user_can('manage_options')
|| (class_exists('\Jio\Core\FrontSubmit') && \Jio\Core\FrontSubmit::get_instance()->can_submit())
);
$show_slide = function_exists('jio_header_slide_is_show')
? jio_header_slide_is_show()
: false;
$current_user = wp_get_current_user();
$user_id = (int) $current_user->ID;
$user_desc = $user_id > 0 && function_exists('jio_get_user_description') ? jio_get_user_description($user_id) : '';
$notification_settings = class_exists('\Jio\Settings\Settings')
? \Jio\Settings\Settings::notification_settings()
: ['enabled' => false, 'icon_show' => []];
$ctx = [
'settings' => $settings,
'layout' => $layout,
'mobile_layout' => $mobile_layout,
'mobile_align' => $mobile_align,
'scroll_down_hide' => (!isset($settings['nav_scroll_down_hide']) || !empty($settings['nav_scroll_down_hide'])) && $nav_fixed,
'brand_name' => $brand_name,
'logo_html' => $logo_html,
'has_logo' => $logo_html !== '',
'theme_positions' => is_array($theme_positions) ? $theme_positions : [],
'can_publish' => $can_publish,
'show_slide' => $show_slide,
'current_user' => $current_user,
'user_id' => $user_id,
'user_desc' => $user_desc,
'unread_count' => ($user_id > 0 && function_exists('jio_get_user_unread_notification_count'))
? (int) jio_get_user_unread_notification_count($user_id)
: 0,
'message_icon_positions' => (array) ($notification_settings['icon_show'] ?? []),
'messages_url' => !empty($notification_settings['enabled']) && function_exists('jio_get_messages_page_url') ? jio_get_messages_page_url() : '',
'orders_url' => function_exists('jio_get_user_center_tab_url') ? jio_get_user_center_tab_url('orders') : '',
'publish_url' => function_exists('jio_get_new_post_url') ? jio_get_new_post_url() : admin_url('post-new.php'),
'theme_settings_url' => function_exists('jio_get_admin_settings_url')
? jio_get_admin_settings_url('')
: admin_url('admin.php?page=jio-settings'),
'search_state' => function_exists('jio_get_search_form_state')
? jio_get_search_form_state()
: [
'type' => 'post',
'types' => ['post' => __('文章', 'jio')],
'category_id' => 0,
'category_enabled' => false,
'categories' => [],
],
'search_placeholder' => function_exists('jio_get_search_placeholder')
? jio_get_search_placeholder()
: __('开启精彩搜索', 'jio'),
'search_hot_keywords' => function_exists('jio_get_search_hot_keywords')
? jio_get_search_hot_keywords()
: [],
];
if ($ctx['publish_url'] === '') {
$ctx['publish_url'] = admin_url('post-new.php');
}
return $ctx;
}
endif;
if (!function_exists('jio_header')) :
/**
* Render top header + mobile drawer (+ optional slide after caller).
*/
function jio_header(): void {
$ctx = jio_get_header_nav_context();
$layout = $ctx['layout'];
$header_class = [
'header',
'header-layout-' . $layout,
];
if (!empty($ctx['show_slide'])) {
$header_class[] = 'show-slide';
}
if (!empty($ctx['scroll_down_hide'])) {
$header_class[] = 'scroll-down-hide';
}
$nav_class = [
'navbar',
'navbar-top',
$ctx['mobile_layout'],
];
echo '<header class="' . esc_attr(implode(' ', array_map('sanitize_html_class', $header_class))) . '">';
echo '<nav class="' . esc_attr(implode(' ', array_map('sanitize_html_class', $nav_class))) . '">';
echo '<div class="container-fluid container-header">';
jio_navbar_header($ctx);
echo '<div class="collapse navbar-collapse">';
if ('3' !== $layout) {
jio_menu_items('primary', true);
}
if ('2' === $layout) {
jio_get_menu_search($ctx);
}
jio_menu_button($ctx);
if ('3' === $layout) {
echo '<div class="navbar-right">';
jio_menu_items('primary', true);
echo '</div>';
}
echo '</div></div></nav></header>';
jio_nav_mobile_shell($ctx);
if (!empty($ctx['show_slide']) && function_exists('jio_header_slide')) {
jio_header_slide();
}
if (function_exists('jio_render_signout_modal')) {
jio_render_signout_modal();
}
}
endif;