fix
This commit is contained in:
1 parent
31e185664a
commit
c6dcf9687a
4 files changed
+19
-11
No files matched your search
@@ -16,13 +16,10 @@ if (!function_exists('aksrt_single_render_aside')) :
|
||||
function aksrt_single_render_aside(array $ctx): void {
|
||||
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
|
||||
|
||||
if (get_post_type($post_id) !== 'post') {
|
||||
if (get_post_type($post_id) !== 'post' || empty($ctx['show_aside'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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.
|
||||
?>
|
||||
<div class="sidebar aksrt-article-sidebar" role="complementary" aria-label="<?php esc_attr_e('侧栏', 'aksrt'); ?>">
|
||||
<?php
|
||||
|
||||
@@ -107,7 +107,7 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
// browsers). The responsive stylesheet owns narrow-screen hiding.
|
||||
$show_aside = get_post_type($post_id) === 'post'
|
||||
&& $layout !== 'no_sidebar'
|
||||
&& (!function_exists('aksrt_is_show_sidebar') || aksrt_is_show_sidebar());
|
||||
&& aksrt_is_show_sidebar();
|
||||
|
||||
return [
|
||||
'post_id' => $post_id,
|
||||
|
||||
@@ -61,9 +61,7 @@ if (!function_exists('aksrt_has_current_sidebar_widgets')):
|
||||
* sidebar, so any of these zones makes the column meaningful.
|
||||
*/
|
||||
function aksrt_has_current_sidebar_widgets(): bool {
|
||||
$sidebar_id = function_exists('aksrt_resolve_sidebar_id')
|
||||
? aksrt_resolve_sidebar_id()
|
||||
: 'home_sidebar';
|
||||
$sidebar_id = aksrt_resolve_sidebar_id();
|
||||
$sidebar_ids = array_unique(['all_sidebar_top', $sidebar_id, 'all_sidebar_bottom']);
|
||||
|
||||
foreach ($sidebar_ids as $sidebar_id) {
|
||||
@@ -122,7 +120,7 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_is_show_sidebar')):
|
||||
/**
|
||||
* legacy-strict sidebar visibility (settings + post meta, not widget presence).
|
||||
* Sidebar visibility from settings, post meta, and available article widgets.
|
||||
*
|
||||
* Filter: aksrt_is_show_sidebar
|
||||
*
|
||||
@@ -148,6 +146,10 @@ function aksrt_is_show_sidebar_filter(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_single() && !aksrt_has_current_sidebar_widgets()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Single / page: post meta can force show/hide (legacy show_layout).
|
||||
if (is_singular()) {
|
||||
$layout = aksrt_get_post_show_layout(get_queried_object_id());
|
||||
@@ -189,8 +191,7 @@ function aksrt_is_show_sidebar_filter(): bool {
|
||||
}
|
||||
}
|
||||
|
||||
// Scene switches above already gated; when enabled, show the column
|
||||
// (widgets may be empty — matches legacy empty sidebar column policy).
|
||||
// Scene switches above already gated; when enabled, show the column.
|
||||
if (is_home() || is_front_page()) {
|
||||
return !empty($cfg['home']);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user