diff --git a/src/Content/Download.php b/src/Content/Download.php index 4e1c7341..d20e59a9 100644 --- a/src/Content/Download.php +++ b/src/Content/Download.php @@ -455,7 +455,73 @@ class Download { private function fail_410(): void { status_header(410); nocache_headers(); - wp_die(esc_html__('下载链接已过期或无效,请回到资源页重新获取。', 'aksrt'), 410); + + // Themed expiry page; wp_die stays only as the safety net for the + // paths that already streamed headers/body (send_download_headers, + // stream_body) where the theme chrome can no longer be emitted. + if (function_exists('get_header') && !headers_sent()) { + $this->render_expired_page(); + exit; + } + + wp_die( + esc_html__('下载链接已过期或无效,请回到资源页重新获取。', 'aksrt'), + esc_html__('下载链接已失效', 'aksrt'), + ['response' => 410] + ); + } + + /** + * Flat, theme-native 410 page. All colors resolve from the runtime CSS + * variables (--color-primary plus its html.dark override, legacy ink + * vars flipped by body.dark-theme), so the admin-configured primary + * color and the light/dark mode apply with no extra scripts. + */ + private function render_expired_page(): void { + add_action('wp_head', static function (): void { + $css = <<<'CSS' +.aksrt-410{display:flex;align-items:center;justify-content:center;min-height:72vh;padding:48px 20px;text-align:center} +.aksrt-410__card{max-width:460px} +.aksrt-410__icon{width:92px;height:92px;margin:0 auto 28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:2.25rem;background:var(--color-primary-soft,rgba(0,0,0,.06));color:var(--color-primary,#f04494)} +.aksrt-410__code{font-family:var(--font-display,var(--font-body,inherit));font-size:clamp(4rem,10vw,5.5rem);font-weight:800;line-height:1;letter-spacing:.02em;color:var(--muted-4-color,#d2d2d2);margin:0 0 10px} +.aksrt-410__title{font-family:var(--font-display,inherit);font-size:clamp(20px,3vw,26px);font-weight:700;line-height:1.3;color:var(--key-color,#333);margin:0 0 12px} +.aksrt-410__desc{font-size:15px;line-height:1.7;color:var(--muted-color,#777);margin:0 0 32px} +.aksrt-410__actions{display:flex;gap:12px;justify-content:center;flex-wrap:wrap} +.aksrt-410__actions .btn-primary,.aksrt-410__actions .btn-outline{--btn-h:42px;--btn-px:22px} +CSS; + echo '' . "\n"; + }, 99); + + $title_filter = static function (array $parts): array { + $parts['title'] = __('下载链接已失效', 'aksrt'); + return $parts; + }; + add_filter('document_title_parts', $title_filter); + + get_header(); + remove_filter('document_title_parts', $title_filter); + ?> +
+
+ +

410

+

+

+ +
+
+