Files
wordpress-theme-aksrt/index.php
T
kate522 1839150ecb fix(sidebar): collapse empty sidebar column on every scene
Sidebar visibility had two disconnected decisions: the body site-layout-*
class (via aksrt_is_show_sidebar_filter) only checked widget activity for
singles, while the homepage aside renderer skipped the column and
sidebar.php rendered an empty one. With the toggle on and no widgets, the
homepage kept a reserved gutter and squeezed the main content aside.

- collapse every scene to no-sidebar when the sidebar widget stack is empty
- resolve home_sidebar before the page branch so a static front page is
  checked against the zones the homepage renders
- guard the homepage aside with aksrt_is_show_sidebar() alone and drop the
  duplicate aksrt_homepage_has_sidebar gate
- early-return sidebar.php instead of rendering an empty column
- drop dead code: archive helper $preferred param, wp_is_mobile fallback,
  container--no-sidebar class, unreachable front-page fallback
- update post-visual-contract to pin the single visibility decision

Verification: php -l on all changed files; node --test
tests/widget-system/*.test.cjs 242/243 (the toast-contract failure is
pre-existing and unrelated).
2026-09-05 15:40:11 +08:00

52 lines
1.4 KiB
PHP

<?php
/**
* Homepage / posts index template.
*
* The homepage shell is handled by the fixed homepage helper so the blog entry
* behaves like a primary product surface instead of a generic archive loop.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (function_exists('aksrt_render_fixed_homepage') && aksrt_render_fixed_homepage()) {
return;
}
get_header();
// Fallback: when homepage shell is unavailable, keep a standard archive loop.
?>
<?php
// legacy dual-column: sidebar is a sibling of .content-wrap under main.container.
// aksrt_is_show_sidebar() is the single visibility decision (settings, post/term
// meta, and widget activity); the body site-layout-* class carries the geometry.
$has_sidebar = function_exists('aksrt_is_show_sidebar') ? aksrt_is_show_sidebar() : true;
?>
<main id="main-content" class="site-main container" tabindex="-1">
<div class="content-wrap">
<div class="content-layout">
<?php
$render_config = aksrt_resolve_post_list_render_config(['context' => 'archive']);
?>
<?php if (have_posts()) : ?>
<?php aksrt_render_post_list($render_config); ?>
<?php aksrt_render_pagination(); ?>
<?php else : ?>
<div class="no-results">
<p><?php esc_html_e('暂无文章。', 'aksrt'); ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php if ($has_sidebar) : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
</main>
<?php
get_footer();