This commit is contained in:
kate522 committed 2026-08-22 18:54:12 +08:00
1 parent 25bb0213d4
commit 31e185664a
19 files changed
+12 -672

No files matched your search

-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;