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).
This commit is contained in:
1 parent
2bf9b00022
commit
1839150ecb
10 files changed
+64
-70
No files matched your search
@@ -122,19 +122,13 @@ if (!function_exists('aksrt_archive_has_sidebar')) :
|
||||
/**
|
||||
* Resolve whether a stream page should show an aside.
|
||||
*
|
||||
* @param string $preferred Preferred sidebar id (compat only).
|
||||
* @param bool $enabled Page-level sidebar toggle.
|
||||
* @param bool $enabled Page-level sidebar toggle.
|
||||
*/
|
||||
function aksrt_archive_has_sidebar(string $preferred = '', bool $enabled = true): bool {
|
||||
// $preferred kept for call-site compat; visibility is settings/meta driven (legacy).
|
||||
unset($preferred);
|
||||
function aksrt_archive_has_sidebar(bool $enabled = true): bool {
|
||||
if (!$enabled) {
|
||||
return false;
|
||||
}
|
||||
if (function_exists('aksrt_is_show_sidebar')) {
|
||||
return aksrt_is_show_sidebar();
|
||||
}
|
||||
return !wp_is_mobile();
|
||||
return function_exists('aksrt_is_show_sidebar') ? aksrt_is_show_sidebar() : false;
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
@@ -139,35 +139,15 @@ if (!function_exists('aksrt_homepage_render_widget_zone')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_has_sidebar')) {
|
||||
/**
|
||||
* Whether the fixed homepage should render an aside column.
|
||||
*/
|
||||
function aksrt_homepage_has_sidebar(): bool {
|
||||
$has_widgets = function_exists('aksrt_has_current_sidebar_widgets')
|
||||
? aksrt_has_current_sidebar_widgets()
|
||||
: aksrt_homepage_has_active_sidebars([
|
||||
'all_sidebar_top',
|
||||
'home_sidebar',
|
||||
'all_sidebar_bottom',
|
||||
]);
|
||||
if (!$has_widgets) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (function_exists('aksrt_is_show_sidebar')) {
|
||||
return aksrt_is_show_sidebar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_render_sidebar')) {
|
||||
/**
|
||||
* Render the homepage aside column.
|
||||
*
|
||||
* Visibility is aksrt_is_show_sidebar() alone; its filter already
|
||||
* collapses the layout when the sidebar widget stack is empty.
|
||||
*/
|
||||
function aksrt_homepage_render_sidebar(): void {
|
||||
if (!aksrt_homepage_has_sidebar()) {
|
||||
if (!aksrt_is_show_sidebar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,14 +41,18 @@ function aksrt_resolve_sidebar_id(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_page()) {
|
||||
return 'page_sidebar_' . get_queried_object_id();
|
||||
}
|
||||
|
||||
// The fixed homepage renders home_sidebar for both is_home() and
|
||||
// is_front_page(); a static front page also matches the page branch below,
|
||||
// so this branch must come first to keep visibility checks aligned with
|
||||
// the renderer.
|
||||
if (is_home() || is_front_page()) {
|
||||
return 'home_sidebar';
|
||||
}
|
||||
|
||||
if (is_page()) {
|
||||
return 'page_sidebar_' . get_queried_object_id();
|
||||
}
|
||||
|
||||
return 'home_sidebar';
|
||||
}
|
||||
endif;
|
||||
@@ -147,7 +151,9 @@ function aksrt_is_show_sidebar_filter(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_single() && !aksrt_has_current_sidebar_widgets()) {
|
||||
// An empty widget stack would leave the reserved column as a bare gutter,
|
||||
// so every scene (not only singles) collapses to no-sidebar.
|
||||
if (!aksrt_has_current_sidebar_widgets()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user