优化了一些问题
This commit is contained in:
@@ -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 '<style id="aksrt-410-page">' . $css . '</style>' . "\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);
|
||||
?>
|
||||
<main id="main-content" class="aksrt-410" tabindex="-1">
|
||||
<div class="aksrt-410__card">
|
||||
<span class="aksrt-410__icon" aria-hidden="true"><i class="fa fas fa-hourglass-end"></i></span>
|
||||
<p class="aksrt-410__code">410</p>
|
||||
<h1 class="aksrt-410__title"><?php esc_html_e('下载链接已失效', 'aksrt'); ?></h1>
|
||||
<p class="aksrt-410__desc"><?php esc_html_e('下载链接已过期或无效,请回到资源页重新获取。', 'aksrt'); ?></p>
|
||||
<div class="aksrt-410__actions">
|
||||
<a href="javascript:history.back()" class="btn-primary">
|
||||
<i class="fa fas fa-arrow-left" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('返回上一页', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<a href="<?php echo esc_url(home_url('/')); ?>" class="btn-outline">
|
||||
<i class="fa fas fa-home" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('返回首页', 'aksrt'); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?php
|
||||
get_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
private function issue_token(int $user_id, int $post_id, int $source_index, int $cost, array $config = []) {
|
||||
|
||||
Reference in New Issue
Block a user