This commit is contained in:
2026-08-22 18:54:12 +08:00
parent 25bb0213d4
commit 31e185664a
19 changed files with 12 additions and 672 deletions
@@ -2,11 +2,8 @@ export const pageSchema = {
key: 'post_list.page',
title: '文章页面',
icon: 'fa fas fa-file-alt',
description: '配置单篇文章页面的布局、目录树、图片灯箱、版权区和互动功能。',
description: '配置单篇文章页面的布局、图片灯箱、版权区和互动功能。',
defaults: {
post_toc_enabled: true,
post_toc_depth: 3,
article_nav_mobile_nav_s: true,
post_reading_progress: true,
breadcrumbs_single_s: true,
breadcrumbs_home_text: '首页',
@@ -60,9 +57,6 @@ export const pageSchema = {
title: '文章导航',
icon: 'fa fas fa-compass',
fields: [
{ key: 'post_toc_enabled', label: '目录树导航', type: 'switch', default: true, help: '自动生成文章目录树' },
{ key: 'post_toc_depth', label: '目录深度', type: 'number', default: 3, min: 1, max: 6, dependsOn: { key: 'post_toc_enabled', value: true } },
{ key: 'article_nav_mobile_nav_s', label: '移动端弹出菜单', type: 'switch', default: true, dependsOn: { key: 'post_toc_enabled', value: true }, help: '在移动端弹出菜单中显示目录导航' },
{ key: 'post_reading_progress', label: '阅读进度条', type: 'switch', default: true },
{ key: 'breadcrumbs_single_s', label: '面包屑导航', type: 'switch', default: true },
{ key: 'breadcrumbs_home_text', label: '面包屑首页文字', type: 'input', default: '首页', dependsOn: { key: 'breadcrumbs_single_s', value: true } },
@@ -165,7 +165,7 @@ a, button, input, select, textarea {
/* --- 卡片 hover 统一 --- */
.post-card, .widget, .aksrt-theme-box, .theme-box,
.comment-body, .friend-card, .special-card,
.resource-download-box, .resource-meta-box {
.resource-download-box {
transition: box-shadow var(--dur) var(--ease),
border-color var(--dur) var(--ease),
transform var(--dur) var(--ease);
-5
View File
@@ -191,17 +191,12 @@ body.site-layout-3 .sidebar,
/* Sticky widgets inside sidebar */
@media (min-width: 992px) {
body.site-layout-2 .sidebar .posts-nav-box,
body.site-layout-3 .sidebar .posts-nav-box,
body.site-layout-2 .aksrt-article-sidebar .posts-nav-box,
body.site-layout-3 .aksrt-article-sidebar .posts-nav-box,
.sidebar .content-layout__aside,
.content-layout__aside {
position: sticky;
top: calc(var(--nav-height, 60px) + 16px);
}
.has-static-nav .sidebar .posts-nav-box,
.has-static-nav .content-layout__aside {
top: 16px;
}
-1
View File
@@ -86,7 +86,6 @@
}
/* 资源元信息 */
.resource-meta-box,
.resource-download-box {
border: 1px solid #ccc;
padding: 12px;
@@ -184,23 +184,6 @@
line-height: 1.3;
}
/* ============================================================
* 元信息卡片图标增强
* ============================================================ */
.resource-meta-box__key {
display: flex;
align-items: center;
gap: 8px;
}
.resource-meta-box__key i {
width: 16px;
text-align: center;
color: var(--color-ink-4, #8A8F98);
font-size: 13px;
flex-shrink: 0;
}
/* ============================================================
* 渐变价格标签(模仿 legacy 渐变 pay-tag)
* ============================================================ */
@@ -323,152 +323,6 @@ html.dark .article-end-separator span {
background: var(--surface-2);
}
.toc-widget {
position: sticky;
top: 88px;
padding: 18px 18px 14px;
margin-bottom: 16px;
border: none;
border-radius: var(--radius-2xl, 16px);
box-shadow: var(--shadow-sm);
background: var(--surface-1);
}
.toc-widget .widget-title {
margin-bottom: 10px;
}
.toc-list {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 8px;
}
.toc-list li {
min-width: 0;
}
.toc-list a {
display: block;
color: var(--color-ink-3);
font-size: 13px;
line-height: 1.55;
text-decoration: none;
transition: color 0.2s ease, transform 0.2s ease;
}
.toc-list a:hover,
.toc-list a.is-active {
color: var(--color-primary);
}
.toc-list .toc-h1 a {
font-weight: 700;
}
.toc-list .toc-h3 a {
padding-left: 12px;
}
.toc-list .toc-h4 a {
padding-left: 24px;
}
/* Built-in article TOC shell. */
.sidebar .posts-nav-box.toc-widget {
margin: 0;
box-shadow: none;
background: transparent;
padding: 0;
border-radius: 0;
}
.sidebar .posts-nav-box.toc-widget > h3,
.sidebar .posts-nav-box.toc-widget .toc-widget__title {
margin: 0 0 10px;
font-size: 15px;
font-weight: 700;
}
body.single .sidebar .posts-nav-box.toc-widget.is-affix,
body.single .sidebar .posts-nav-box.toc-widget[data-affix="true"] {
position: sticky;
top: calc(var(--nav-height, 60px) + 16px);
}
.toc-float-btn {
position: fixed;
right: 18px;
bottom: 86px;
z-index: 41;
width: 48px;
height: 48px;
border: none;
border-radius: 999px;
display: none;
align-items: center;
justify-content: center;
background: var(--color-primary);
color: #fff;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.toc-drawer-overlay {
position: fixed;
inset: 0;
z-index: 79;
display: none;
background: rgba(15, 23, 42, 0.36);
}
.toc-drawer-overlay.is-open {
display: block;
}
.toc-drawer {
position: fixed;
right: 0;
top: 0;
bottom: 0;
z-index: 80;
width: min(86vw, 340px);
padding: 18px 18px 28px;
background: var(--surface-1);
border-left: 1px solid rgba(255, 255, 255, 0.55);
box-shadow: var(--shadow-drawer);
transform: translateX(100%);
transition: transform 0.25s ease;
overflow-y: auto;
}
.toc-drawer.is-open {
transform: translateX(0);
}
.toc-drawer__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 14px;
}
.toc-drawer__head h3 {
margin: 0;
font-size: 16px;
}
.toc-drawer__close {
width: 36px;
height: 36px;
border: none;
border-radius: 999px;
background: var(--surface-2);
color: var(--color-ink-3);
}
.resource-mobile-fab {
position: fixed;
right: 18px;
@@ -509,14 +363,6 @@ body.single .sidebar .posts-nav-box.toc-widget[data-affix="true"] {
}
@media (max-width: 991px) {
.toc-widget {
display: none;
}
.toc-float-btn {
display: inline-flex;
}
.resource-mobile-download-bar {
display: block;
}
-59
View File
@@ -25,12 +25,6 @@ body.single main.container .content-layout > .breadcrumbs-wrap {
padding-top: 2px;
}
/* Sticky TOC widget in sidebar — parent .sidebar is position:unset like legacy */
body.single .sidebar .posts-nav-box.toc-widget {
position: sticky;
top: calc(var(--nav-height, 60px) + 16px);
}
body.single .sidebar .aksrt-panel,
body.single .sidebar .widget {
margin-bottom: 15px;
@@ -56,56 +50,3 @@ body.single main.container {
align-items: center;
gap: 5px;
}
/* Useful fallback for sites that enable the column before adding widgets. */
.single-overview-widget {
padding: 18px;
border-radius: var(--main-radius, 8px);
background: var(--main-bg-color, #fff);
box-shadow: 0 0 10px var(--main-shadow, rgba(116, 116, 116, 0.08));
}
.single-overview-widget__title {
display: flex;
align-items: center;
gap: 8px;
margin: 0 0 12px;
font-size: 15px;
}
.single-overview-widget__title i {
color: var(--focus-color, #f04494);
}
.single-overview-widget__list {
margin: 0;
}
.single-overview-widget__list > div {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 8px 0;
border-bottom: 1px dashed var(--main-border-color, rgba(50, 50, 50, 0.08));
}
.single-overview-widget__list > div:last-child {
padding-bottom: 0;
border-bottom: 0;
}
.single-overview-widget__list dt,
.single-overview-widget__list dd {
margin: 0;
font-size: 12px;
}
.single-overview-widget__list dt {
color: var(--muted-color, #777);
}
.single-overview-widget__list dd {
color: var(--key-color, #333);
text-align: right;
}
+1 -168
View File
@@ -1,7 +1,7 @@
/**
* AKSRT Page Template
*
* Handles template-scoped content interactions: TOC, lightbox,
* Handles template-scoped content interactions: lightbox,
* expandable article bodies, and one-shot query cleanup banners.
*
* @package AKSRT
@@ -10,172 +10,6 @@
(function () {
'use strict';
function slugifyHeading(text) {
return 'heading-' + String(text || '')
.trim()
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w\u4e00-\u9fff-]/g, '');
}
function initPostToc() {
// Accept either explicit data-aksrt-toc="1" or any [data-nav] article body.
var content =
document.querySelector('.wp-posts-content[data-nav="posts"][data-aksrt-toc="1"]') ||
document.querySelector('.wp-posts-content[data-nav]') ||
document.querySelector('[data-nav="posts"]') ||
document.querySelector('[data-nav]');
// The article sidebar and mobile drawer share one built-in TOC source.
var tocWidgets = Array.prototype.slice.call(
document.querySelectorAll('.posts-nav-box.toc-widget')
);
var tocLists = [];
tocWidgets.forEach(function (box) {
if (!box.classList.contains('toc-widget')) {
box.classList.add('toc-widget');
}
var list = box.querySelector('.toc-list');
if (!list) {
list = document.createElement('ol');
list.className = 'toc-list';
box.appendChild(list);
}
tocLists.push(list);
});
var mobileToggle = document.querySelector('.toc-float-btn');
var drawer = document.querySelector('.toc-drawer');
var overlay = document.querySelector('.toc-drawer-overlay');
var drawerList = drawer ? drawer.querySelector('.toc-list') : null;
var closeBtn = drawer ? drawer.querySelector('.toc-drawer__close') : null;
if (!content || content.dataset.aksrtTocBound === '1') return;
if (!tocLists.length && !drawerList && !mobileToggle) return;
content.dataset.aksrtTocBound = '1';
var maxDepth = parseInt(content.dataset.aksrtTocDepth || '3', 10) || 3;
// legacy section-navs: only fill when heading count > 2 (≥3).
var MIN_HEADINGS = 3;
function getHeadings() {
// legacy scans h1–h4 inside [data-nav]; depth setting still caps lower levels.
return Array.prototype.slice.call(content.querySelectorAll('h1, h2, h3, h4')).filter(function (heading) {
if (heading.closest('.no-nav') || heading.classList.contains('item-heading')) {
return false;
}
var level = parseInt((heading.tagName || 'H2').replace('H', ''), 10) || 2;
// toc_depth is typically 2–4 meaning deepest heading level from h2 baseline;
// allow h1 always, then h2..h(1+maxDepth) capped at h4.
if (level === 1) return true;
return level <= Math.min(4, maxDepth + 1);
});
}
function buildToc(container) {
if (!container) return false;
var headings = getHeadings();
if (headings.length < MIN_HEADINGS) return false;
var html = '';
headings.forEach(function (heading) {
if (!heading.id) {
heading.id = slugifyHeading(heading.textContent);
}
var levelClass = '';
if (heading.tagName === 'H1') {
levelClass = 'toc-h1';
} else if (heading.tagName === 'H3') {
levelClass = 'toc-h3';
} else if (heading.tagName === 'H4') {
levelClass = 'toc-h4';
}
html += '<li' + (levelClass ? ' class="' + levelClass + '"' : '') + '><a href="#' + heading.id + '">' + heading.textContent.trim() + '</a></li>';
});
container.innerHTML = html;
return true;
}
var hasToc = false;
tocLists.forEach(function (list) {
if (buildToc(list)) hasToc = true;
});
if (drawerList && tocLists.indexOf(drawerList) === -1) {
if (buildToc(drawerList)) hasToc = true;
}
if (!hasToc) {
tocWidgets.forEach(function (box) {
var widget = box.closest('.widget');
// A built-in TOC is a direct child of the article sidebar. Its parent
// is therefore not widget chrome and must never be removed here.
if (widget && widget !== document.body && widget.querySelectorAll('.posts-nav-box').length <= 1) {
widget.remove();
} else {
box.remove();
}
});
if (mobileToggle) mobileToggle.remove();
if (drawer) drawer.remove();
if (overlay) overlay.remove();
return;
}
function closeDrawer() {
if (drawer) drawer.classList.remove('is-open');
if (overlay) overlay.classList.remove('is-open');
document.body.style.overflow = '';
}
function openDrawer() {
if (drawer) drawer.classList.add('is-open');
if (overlay) overlay.classList.add('is-open');
document.body.style.overflow = 'hidden';
}
function trackActiveHeading() {
var headings = content.querySelectorAll('h1[id], h2[id], h3[id], h4[id]');
if (!headings.length) return;
var activeId = '';
var fromTop = window.scrollY + 120;
for (var i = headings.length - 1; i >= 0; i -= 1) {
if (headings[i].offsetTop <= fromTop) {
activeId = headings[i].id;
break;
}
}
document.querySelectorAll('.toc-list a').forEach(function (link) {
link.classList.toggle('is-active', link.getAttribute('href') === '#' + activeId);
});
}
document.querySelectorAll('.toc-list a').forEach(function (link) {
link.addEventListener('click', function (event) {
var target = document.querySelector(link.getAttribute('href'));
if (!target) return;
event.preventDefault();
var top = target.getBoundingClientRect().top + window.pageYOffset - 105;
window.scrollTo({ top: Math.max(0, top), behavior: 'smooth' });
closeDrawer();
});
});
if (mobileToggle) mobileToggle.addEventListener('click', openDrawer);
if (overlay) overlay.addEventListener('click', closeDrawer);
if (closeBtn) closeBtn.addEventListener('click', closeDrawer);
window.addEventListener('scroll', trackActiveHeading, { passive: true });
trackActiveHeading();
}
function initLightbox() {
var overlay = document.getElementById('lightbox-overlay');
var content = document.querySelector(".wp-posts-content[data-aksrt-lightbox='1'], .entry-content[data-aksrt-lightbox='1']");
@@ -316,7 +150,6 @@
}
function init() {
initPostToc();
initLightbox();
initContentExpand();
initFlashQueryCleanup();
-6
View File
@@ -70,8 +70,6 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_page_settings()
: [
'toc_enabled' => true,
'toc_depth' => 3,
'reading_progress' => true,
'lightbox' => true,
'related_enabled' => true,
@@ -129,10 +127,6 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
$settings['authordesc'] = !empty($settings['authordesc_s']);
}
$meta = class_exists('\AKSRT\Core\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta($post->ID) : [];
// show_toc new route: '' follow | '1' on | '0' off
if (array_key_exists('show_toc', $meta) && $meta['show_toc'] !== '' && $meta['show_toc'] !== null) {
$settings['toc_enabled'] = (string) $meta['show_toc'] === '1';
}
foreach ([
'show_reading_progress' => 'reading_progress',
'enable_lightbox' => 'lightbox',
+6 -67
View File
@@ -7,47 +7,9 @@
defined('ABSPATH') || exit;
if (!function_exists('aksrt_single_render_overview_widget')) :
/**
* Render a useful fallback when no article sidebar widgets are configured.
*
* @param array<string,mixed> $ctx Single context.
*/
function aksrt_single_render_overview_widget(array $ctx): void {
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
$categories = get_the_category($post_id);
$primary_category = !empty($categories) && $categories[0] instanceof WP_Term ? $categories[0] : null;
$modified = get_the_modified_date('', $post_id);
$overview_items = is_array($ctx['meta_items_secondary'] ?? null) ? $ctx['meta_items_secondary'] : [];
?>
<section class="aksrt-panel single-overview-widget" aria-labelledby="single-overview-title">
<h3 id="single-overview-title" class="single-overview-widget__title">
<i class="fa fas fa-file-alt" aria-hidden="true"></i>
<?php esc_html_e('文章概览', 'aksrt'); ?>
</h3>
<dl class="single-overview-widget__list">
<?php if ($primary_category instanceof WP_Term) : ?>
<div><dt><?php esc_html_e('分类', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url(get_category_link($primary_category)); ?>"><?php echo esc_html($primary_category->name); ?></a></dd></div>
<?php endif; ?>
<div><dt><?php esc_html_e('浏览', 'aksrt'); ?></dt><dd><?php echo esc_html(number_format_i18n((int) ($ctx['views'] ?? 0))); ?></dd></div>
<div><dt><?php esc_html_e('评论', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url(get_comments_link($post_id)); ?>"><?php echo esc_html(number_format_i18n((int) ($ctx['comment_count'] ?? 0))); ?></a></dd></div>
<?php foreach ($overview_items as $item) : ?>
<?php if (is_array($item) && !empty($item['text'])) : ?>
<div><dt><i class="<?php echo esc_attr((string) ($item['icon'] ?? 'fa fas fa-circle')); ?>" aria-hidden="true"></i></dt><dd><?php echo esc_html((string) $item['text']); ?></dd></div>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($modified !== '') : ?>
<div><dt><?php esc_html_e('更新', 'aksrt'); ?></dt><dd><?php echo esc_html($modified); ?></dd></div>
<?php endif; ?>
</dl>
</section>
<?php
}
endif;
if (!function_exists('aksrt_single_render_aside')) :
/**
* Render the page-owned single sidebar.
* Render the article sidebar: widget areas only, legacy sidebar.php parity.
*
* @param array<string,mixed> $ctx Single context.
*/
@@ -61,36 +23,13 @@ if (!function_exists('aksrt_single_render_aside')) :
// The body site-layout-* class owns visibility. Always render the post
// sidebar so User-Agent or request-specific context cannot remove widgets
// from an otherwise two-column article page.
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|| is_active_sidebar('single_sidebar')
|| is_active_sidebar('all_sidebar_bottom');
?>
<div class="sidebar aksrt-article-sidebar" role="complementary" aria-label="<?php esc_attr_e('侧栏', 'aksrt'); ?>">
<?php if (!empty($ctx['has_download'])) : ?>
<?php get_template_part('templates/parts/resource-meta-box'); ?>
<?php endif; ?>
<?php if (!$has_article_widgets) : ?>
<?php aksrt_single_render_overview_widget($ctx); ?>
<?php endif; ?>
<?php if (!empty($ctx['show_toc'])) : ?>
<div class="aksrt-panel toc-widget posts-nav-box" data-title="<?php echo esc_attr((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?>">
<h3><?php echo esc_html((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?></h3>
<ol class="toc-list"></ol>
</div>
<?php endif; ?>
<?php if (is_active_sidebar('all_sidebar_top')) : ?>
<?php dynamic_sidebar('all_sidebar_top'); ?>
<?php endif; ?>
<?php if (is_active_sidebar('single_sidebar')) : ?>
<?php dynamic_sidebar('single_sidebar'); ?>
<?php endif; ?>
<?php if (is_active_sidebar('all_sidebar_bottom')) : ?>
<?php dynamic_sidebar('all_sidebar_bottom'); ?>
<?php endif; ?>
<?php
dynamic_sidebar('all_sidebar_top');
dynamic_sidebar('single_sidebar');
dynamic_sidebar('all_sidebar_bottom');
?>
</div>
<?php
}
-3
View File
@@ -839,10 +839,7 @@ if (!function_exists('aksrt_single_render_article')) :
<div class="theme-box wp-posts-content<?php echo $maxheight > 0 ? ' limit-height' : ''; ?>"
<?php echo $maxheight > 0 ? ' style="max-height:' . esc_attr((string) $maxheight) . 'px;"' : ''; ?>
<?php echo !empty($ctx['show_toc']) ? ' data-nav="posts"' : ''; ?>
data-maxheight="<?php echo esc_attr((string) ($maxheight > 0 ? max(0, $maxheight - 80) : 0)); ?>"
data-aksrt-toc="<?php echo !empty($ctx['show_toc']) ? '1' : '0'; ?>"
data-aksrt-toc-depth="<?php echo esc_attr((string) ((int) ($settings['toc_depth'] ?? 3))); ?>"
<?php echo !empty($settings['lightbox']) ? ' data-aksrt-lightbox="1"' : ''; ?>>
<?php the_content(); ?>
<?php
+1 -4
View File
@@ -69,7 +69,6 @@ if (!function_exists('aksrt_single_build_context')) :
}
$show_cover = !empty($settings['show_cover']) && (string) ($settings['cover_url'] ?? '') !== '';
$show_toc = !empty($settings['toc_enabled']);
$has_download = function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($post_id);
$pay_meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post_id) : ['pay_type' => 'no'];
$pay_type = (string) ($pay_meta['pay_type'] ?? 'no');
@@ -114,8 +113,7 @@ if (!function_exists('aksrt_single_build_context')) :
'post_id' => $post_id,
'settings' => $settings,
'show_cover' => $show_cover,
'show_toc' => $show_toc,
'cover_url' => (string) ($settings['cover_url'] ?? ''),
'cover_url' => (string) ($settings['cover_url'] ?? ''),
'cover_type' => (string) ($settings['cover_type'] ?? 'none'),
'img_scale' => (int) ($settings['article_image_cover_scale'] ?? 35),
'video_scale' => (int) ($settings['article_video_cover_scale'] ?? 56),
@@ -146,7 +144,6 @@ if (!function_exists('aksrt_single_build_context')) :
'breadcrumbs_html' => $breadcrumbs_html,
'status_badge' => $status_badge,
'show_aside' => $show_aside,
'toc_title' => __('文章目录', 'aksrt'),
];
}
endif;
-12
View File
@@ -72,18 +72,6 @@ while (have_posts()) :
?>
</main>
<?php if (!empty($ctx['show_toc'])) : ?>
<button type="button" class="toc-float-btn" aria-label="<?php esc_attr_e('打开目录', 'aksrt'); ?>"><i class="fa fas fa-list-ul" aria-hidden="true"></i></button>
<div class="toc-drawer-overlay"></div>
<aside class="toc-drawer posts-nav-box" data-title="<?php echo esc_attr((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?>" aria-label="<?php echo esc_attr((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?>">
<div class="toc-drawer__head">
<h3><?php echo esc_html((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?></h3>
<button type="button" class="toc-drawer__close" aria-label="<?php esc_attr_e('关闭目录', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
</div>
<ol class="toc-list"></ol>
</aside>
<?php endif; ?>
<?php if (!empty($settings['lightbox'])) : ?>
<div class="lightbox-overlay" id="lightbox-overlay" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('图片预览', 'aksrt'); ?>" aria-hidden="true">
<button type="button" class="lightbox-close" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
-3
View File
@@ -50,9 +50,6 @@ class SchemaPostList {
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'navigation', 'title' => '文章导航', 'fields' => [
['key' => 'post_toc_enabled', 'label' => '目录树导航', 'type' => 'switch', 'default' => true],
['key' => 'post_toc_depth', 'label' => '目录深度', 'type' => 'number', 'default' => 3, 'min' => 1, 'max' => 6],
['key' => 'article_nav_mobile_nav_s', 'label' => '移动端弹出菜单', 'type' => 'switch', 'default' => true, 'description' => '在移动端弹出菜单中显示目录导航'],
['key' => 'post_reading_progress', 'label' => '阅读进度条', 'type' => 'switch', 'default' => true],
['key' => 'breadcrumbs_single_s', 'label' => '面包屑导航', 'type' => 'switch', 'default' => true],
['key' => 'breadcrumbs_home_text', 'label' => '面包屑首页文字', 'type' => 'input', 'default' => '首页', 'depends_on' => 'breadcrumbs_single_s'],
-1
View File
@@ -72,7 +72,6 @@ class DomainModel {
'cover_images' => '',
'custom_excerpt' => '',
'header_image_mode' => '',
'show_toc' => '',
'show_reading_progress' => '',
'enable_lightbox' => '',
'show_related' => '',
+1 -35
View File
@@ -44,9 +44,6 @@ class PostMetaBox {
$meta = array_merge($defaults, $saved);
// New route only: episodes is always a list of {url,title}.
$meta['featured_video_episode'] = self::sanitize_video_episodes($meta['featured_video_episode'] ?? []);
if (!in_array((string) ($meta['show_toc'] ?? ''), ['', '0', '1'], true)) {
$meta['show_toc'] = '';
}
return $meta;
}
@@ -186,15 +183,6 @@ class PostMetaBox {
<option value="none" <?php selected($meta['header_image_mode'], 'none'); ?>><?php esc_html_e('不显示', 'aksrt'); ?></option>
</select>
<p>
<label for="aksrt_show_toc"><strong><?php esc_html_e('目录树', 'aksrt'); ?></strong></label>
<select name="aksrt_post_meta[show_toc]" id="aksrt_show_toc" class="widefat">
<option value="" <?php selected((string) ($meta['show_toc'] ?? ''), ''); ?>><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
<option value="1" <?php selected((string) ($meta['show_toc'] ?? ''), '1'); ?>><?php esc_html_e('强制开启', 'aksrt'); ?></option>
<option value="0" <?php selected((string) ($meta['show_toc'] ?? ''), '0'); ?>><?php esc_html_e('强制关闭', 'aksrt'); ?></option>
</select>
</p>
<p><strong><?php esc_html_e('单篇交互覆盖', 'aksrt'); ?></strong></p>
<?php
$toggle_fields = [
@@ -384,8 +372,6 @@ class PostMetaBox {
'cover_images' => isset($raw['cover_images']) ? sanitize_text_field($raw['cover_images']) : '',
'custom_excerpt' => isset($raw['custom_excerpt']) ? sanitize_textarea_field($raw['custom_excerpt']) : '',
'header_image_mode' => isset($raw['header_image_mode']) ? sanitize_key($raw['header_image_mode']) : '',
// New route: '' follow | '1' force on | '0' force off.
'show_toc' => isset($raw['show_toc']) && in_array((string) $raw['show_toc'], ['', '0', '1'], true) ? (string) $raw['show_toc'] : '',
'show_reading_progress' => isset($raw['show_reading_progress']) ? sanitize_key((string) $raw['show_reading_progress']) : '',
'enable_lightbox' => isset($raw['enable_lightbox']) ? sanitize_key((string) $raw['enable_lightbox']) : '',
'show_related' => isset($raw['show_related']) ? sanitize_key((string) $raw['show_related']) : '',
@@ -462,9 +448,8 @@ class PostMetaBox {
echo esc_html($views > 0 ? (string) $views : '—');
} elseif ($column === 'aksrt_likes') {
$likes = (int) ($meta['likes'] ?? 0);
$toc = esc_attr($meta['show_toc'] ?? '');
$mh = (int) ($meta['maxheight'] ?? 0);
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-toc="' . $toc . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
} elseif ($column === 'aksrt_sales') {
$this->render_sales_column($post_id);
}
@@ -616,15 +601,6 @@ class PostMetaBox {
<span class="title"><?php esc_html_e('点赞数', 'aksrt'); ?></span>
<input type="number" name="aksrt_qe_likes" min="0" step="1" value="" class="aksrt-qe-likes">
</label>
<label class="alignleft">
<span class="title"><?php esc_html_e('目录树', 'aksrt'); ?></span>
<select name="aksrt_qe_toc" class="aksrt-qe-toc">
<option value="-1"><?php esc_html_e('— 不更改 —', 'aksrt'); ?></option>
<option value=""><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
<option value="1"><?php esc_html_e('显示', 'aksrt'); ?></option>
<option value="0"><?php esc_html_e('隐藏', 'aksrt'); ?></option>
</select>
</label>
<label class="alignleft">
<span class="title"><?php esc_html_e('限高(px)', 'aksrt'); ?></span>
<input type="number" name="aksrt_qe_maxheight" min="0" step="100" value="" class="aksrt-qe-maxheight" placeholder="<?php esc_attr_e('0=不限', 'aksrt'); ?>">
@@ -745,19 +721,12 @@ class PostMetaBox {
? max(0, (int) $_POST['aksrt_qe_likes'])
: (int) ($existing['likes'] ?? 0);
$toc = $existing['show_toc'] ?? '';
if (isset($_POST['aksrt_qe_toc']) && $_POST['aksrt_qe_toc'] !== '-1') {
$toc_v = sanitize_key((string) $_POST['aksrt_qe_toc']);
$toc = in_array($toc_v, ['', '0', '1'], true) ? $toc_v : ($existing['show_toc'] ?? '');
}
$mh = isset($_POST['aksrt_qe_maxheight']) && $_POST['aksrt_qe_maxheight'] !== ''
? max(0, (int) $_POST['aksrt_qe_maxheight'])
: (int) ($existing['maxheight'] ?? 0);
$existing['views'] = $views;
$existing['likes'] = $likes;
$existing['show_toc'] = $toc;
$existing['maxheight'] = $mh;
update_post_meta($post_id, self::META_KEY, $existing);
@@ -800,7 +769,6 @@ class PostMetaBox {
var v = data.getAttribute('data-views') || '';
var l = data.getAttribute('data-likes') || '';
var toc = data.getAttribute('data-toc') || '';
var mh = data.getAttribute('data-maxheight') || '';
var qv = form.querySelector('.aksrt-qe-views');
@@ -808,8 +776,6 @@ class PostMetaBox {
if (qv) qv.value = v;
if (ql) ql.value = l;
var qToc = form.querySelector('.aksrt-qe-toc');
if (qToc) qToc.value = toc;
var qMh = form.querySelector('.aksrt-qe-maxheight');
if (qMh) qMh.value = mh;
};
+1 -3
View File
@@ -156,7 +156,7 @@ trait FacadeBulk {
/**
* Single post/page display settings.
*
* @return array{toc_enabled:bool,toc_depth:int,reading_progress:bool,lightbox:bool,related_enabled:bool,related_count:int,like_enabled:bool,favorite_enabled:bool,share_enabled:bool,copyright_enabled:bool,print_enabled:bool,pdf_export_enabled:bool,word_count_enabled:bool,reading_time_enabled:bool}
* @return array{reading_progress:bool,lightbox:bool,related_enabled:bool,related_count:int,like_enabled:bool,favorite_enabled:bool,share_enabled:bool,copyright_enabled:bool,print_enabled:bool,pdf_export_enabled:bool,word_count_enabled:bool,reading_time_enabled:bool}
*/
public static function get_post_page_settings(): array {
// Canonical assembly lives in the post-display helper (related style/source split, aliases).
@@ -166,8 +166,6 @@ trait FacadeBulk {
$settings = self::get_all();
return [
'toc_enabled' => !isset($settings['post_toc_enabled']) || !empty($settings['post_toc_enabled']),
'toc_depth' => max(1, min(6, (int) ($settings['post_toc_depth'] ?? 3))),
'reading_progress' => !isset($settings['post_reading_progress']) || !empty($settings['post_reading_progress']),
'breadcrumbs' => !isset($settings['breadcrumbs_single_s']) || !empty($settings['breadcrumbs_single_s']),
'breadcrumbs_home' => trim((string) ($settings['breadcrumbs_home_text'] ?? '')) ?: __('首页', 'aksrt'),
-4
View File
@@ -188,10 +188,6 @@ class PostDisplay {
}
return [
'toc_enabled' => !isset($settings['post_toc_enabled']) || !empty($settings['post_toc_enabled']),
'toc_depth' => max(1, min(6, (int) ($settings['post_toc_depth'] ?? 3))),
'article_nav_mobile_nav_s' => !isset($settings['article_nav_mobile_nav_s']) || !empty($settings['article_nav_mobile_nav_s']),
'mobile_nav_s' => !isset($settings['article_nav_mobile_nav_s']) || !empty($settings['article_nav_mobile_nav_s']),
'reading_progress' => !isset($settings['post_reading_progress']) || !empty($settings['post_reading_progress']),
// Canonical + legacy breadcrumbs.
'breadcrumbs' => $breadcrumbs,
-122
View File
@@ -1,122 +0,0 @@
<?php
/**
* Resource Meta Box
*
* 统一资源/付费内容侧栏信息表。
*
* 由统一 single.php / 资源内容上下文调用:
* set_query_var('aksrt_resource_meta', $meta);
* get_template_part('templates/parts/resource-meta-box');
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$meta = get_query_var('aksrt_resource_meta', null);
if (!is_array($meta)) {
$meta = function_exists('aksrt_get_resource_meta') ? aksrt_get_resource_meta(get_the_ID()) : null;
}
if (!is_array($meta)) return;
// 字段定义及显示顺序
$rows = [
'version' => __('版本', 'aksrt'),
'size' => __('大小', 'aksrt'),
'compat' => __('兼容性', 'aksrt'),
'license' => __('授权', 'aksrt'),
];
// 至少要有一个非空字段才渲染
$has_any = false;
foreach ($rows as $k => $_label) {
if (!empty($meta[$k])) { $has_any = true; break; }
}
$has_demo = !empty($meta['demo_url']);
$has_downloads = ($meta['download_count'] ?? 0) > 0;
if (!$has_any && !$has_demo && !$has_downloads) return;
?>
<aside class="resource-meta-box" aria-label="<?php esc_attr_e('资源信息', 'aksrt'); ?>">
<header class="resource-meta-box__header">
<h2 class="resource-meta-box__title"><?php esc_html_e('资源信息', 'aksrt'); ?></h2>
</header>
<dl class="resource-meta-box__list">
<?php if (!empty($meta['version'])) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('version') : 'fa fas fa-code-branch'); ?>" aria-hidden="true"></i>
<?php echo esc_html($rows['version']); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html((string) $meta['version']); ?></dd>
</div>
<?php endif; ?>
<?php if (!empty($meta['size'])) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('size') : 'fa fas fa-hdd'); ?>" aria-hidden="true"></i>
<?php echo esc_html($rows['size']); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html((string) $meta['size']); ?></dd>
</div>
<?php endif; ?>
<?php if (!empty($meta['compat'])) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('compat') : 'fa fas fa-laptop'); ?>" aria-hidden="true"></i>
<?php echo esc_html($rows['compat']); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html((string) $meta['compat']); ?></dd>
</div>
<?php endif; ?>
<?php if ($has_demo) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('demo_url') : 'fa fas fa-external-link-alt'); ?>" aria-hidden="true"></i>
<?php esc_html_e('演示地址', 'aksrt'); ?>
</dt>
<dd class="resource-meta-box__val">
<a class="resource-meta-box__demo-link" href="<?php echo esc_url($meta['demo_url']); ?>" target="_blank" rel="noopener noreferrer">
<?php esc_html_e('打开演示', 'aksrt'); ?>
<i class="fa fas fa-external-link-alt" aria-hidden="true"></i>
</a>
</dd>
</div>
<?php endif; ?>
<?php if (!empty($meta['license'])) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('license') : 'fa fas fa-shield-alt'); ?>" aria-hidden="true"></i>
<?php echo esc_html($rows['license']); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html((string) $meta['license']); ?></dd>
</div>
<?php endif; ?>
<?php if ($has_downloads) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('download') : 'fa fas fa-download'); ?>" aria-hidden="true"></i>
<?php esc_html_e('下载次数', 'aksrt'); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html(number_format_i18n((int) $meta['download_count'])); ?></dd>
</div>
<?php endif; ?>
<?php if (($meta['view_count'] ?? 0) > 0) : ?>
<div class="resource-meta-box__row">
<dt class="resource-meta-box__key">
<i class="<?php echo esc_attr(function_exists('aksrt_resource_meta_icon') ? aksrt_resource_meta_icon('views') : 'fa fas fa-eye'); ?>" aria-hidden="true"></i>
<?php esc_html_e('浏览次数', 'aksrt'); ?>
</dt>
<dd class="resource-meta-box__val"><?php echo esc_html(number_format_i18n((int) $meta['view_count'])); ?></dd>
</div>
<?php endif; ?>
</dl>
</aside>