diff --git a/assets/css/frontend/header-userbox.css b/assets/css/frontend/header-userbox.css index d762f0cf..01e78904 100644 --- a/assets/css/frontend/header-userbox.css +++ b/assets/css/frontend/header-userbox.css @@ -332,13 +332,14 @@ .aksrt-header-payvip__active { display: flex; - flex-direction: column; + flex-direction: row; align-items: center; justify-content: center; - gap: 2px !important; + gap: 8px !important; width: 100%; min-height: 42px; padding: 7px 10px !important; + white-space: nowrap; } .aksrt-header-payvip__level { @@ -353,7 +354,7 @@ } .aksrt-header-payvip__exp { - display: block; + display: inline; margin: 0; padding: 0; border: 0; @@ -364,6 +365,7 @@ font-weight: 400; line-height: 1.3; opacity: .9; + white-space: nowrap; } /* Navigation links are globally capped at 50px. Account actions are taller diff --git a/inc/helpers/aksrt-header-userbox.php b/inc/helpers/aksrt-header-userbox.php index d0651ca0..71a030f9 100644 --- a/inc/helpers/aksrt-header-userbox.php +++ b/inc/helpers/aksrt-header-userbox.php @@ -139,7 +139,10 @@ if (!function_exists('aksrt_header_payvip_bar')) : $exp_label = ''; if (function_exists('aksrt_get_vip_info')) { $info = aksrt_get_vip_info($user_id); - $exp_label = (string) ($info['expires_label'] ?? ''); + $expires = max(0, (int) ($info['expires'] ?? 0)); + $exp_label = $expires > 0 + ? sprintf(__('到期时间:%s', 'aksrt'), wp_date('Y年m月d日', $expires)) + : (string) ($info['expires_label'] ?? ''); } $html = '
'; $html .= ''; diff --git a/tests/widget-system/page-display-contract.test.cjs b/tests/widget-system/page-display-contract.test.cjs index 6e2b485c..52e369cd 100644 --- a/tests/widget-system/page-display-contract.test.cjs +++ b/tests/widget-system/page-display-contract.test.cjs @@ -19,6 +19,7 @@ const headerMenuButtons = read('inc/helpers/aksrt-header-menu-buttons.php') const frontendRenderer = read('src/WidgetSystem/FrontendRenderer.php') const userRenderer = read('src/WidgetSystem/Renderers/UserRenderer.php') const headerNavbar = read('inc/helpers/header/aksrt-header-navbar.php') +const headerUserbox = read('inc/helpers/aksrt-header-userbox.php') const headerSearch = read('inc/helpers/header/aksrt-header-menu-search.php') const headerCss = read('assets/css/frontend/header-userbox.css') @@ -244,6 +245,13 @@ test('header user-card publish controls are removed from configuration and runti assert.match(headerNavbar, /esc_html__\('发布内容', 'aksrt'\)/) }) +test('header user-card membership stays on one row with a date-only expiry', () => { + assert.match(headerUserbox, /wp_date\('Y年m月d日', \$expires\)/) + assert.doesNotMatch(headerUserbox, /wp_date\('Y-m-d H:i', \$expires\)/) + assert.match(headerCss, /\.aksrt-header-payvip__active\s*\{[^}]*flex-direction:\s*row;[^}]*gap:\s*8px !important;[^}]*white-space:\s*nowrap;/s) + assert.match(headerCss, /\.aksrt-header-payvip__exp\s*\{[^}]*display:\s*inline;[^}]*white-space:\s*nowrap;/s) +}) + test('save contract rejects invalid input and round-trips canonical nested values', () => { const result = spawnSync(process.env.PHP_BINARY || 'php', [path.join(__dirname, 'page-display-save-harness.php')], { cwd: root,