diff --git a/category.php b/category.php index b403f5ba..390e977c 100644 --- a/category.php +++ b/category.php @@ -46,7 +46,7 @@ $archive_settings = class_exists('\AKSRT\Core\TermMeta') ]; $has_sidebar = function_exists('aksrt_archive_has_sidebar') - ? aksrt_archive_has_sidebar('cat_sidebar', !empty($archive_settings['show_sidebar'])) + ? aksrt_archive_has_sidebar(!empty($archive_settings['show_sidebar'])) : (!empty($archive_settings['show_sidebar']) && is_active_sidebar('cat_sidebar')); $description = !empty($archive_settings['show_desc']) ? wp_kses_post((string) $archive_settings['description']) : ''; $header_style = (string) $archive_settings['header_style']; diff --git a/front-page.php b/front-page.php index d43ab059..372d18c9 100644 --- a/front-page.php +++ b/front-page.php @@ -11,21 +11,6 @@ get_header(); -if (function_exists('aksrt_homepage_render_layout')) { - aksrt_homepage_render_layout(); -} else { - ?> -
-
-
-
-

-

-
-
-
-
-
diff --git a/sidebar.php b/sidebar.php index 5c23aa70..a7288cba 100644 --- a/sidebar.php +++ b/sidebar.php @@ -1,19 +1,22 @@ -
+
diff --git a/tag.php b/tag.php index 55edc3b0..c909d863 100644 --- a/tag.php +++ b/tag.php @@ -27,7 +27,7 @@ $archive_settings = class_exists('\AKSRT\Core\TermMeta') ]; $has_sidebar = function_exists('aksrt_archive_has_sidebar') - ? aksrt_archive_has_sidebar('tag_sidebar', !empty($archive_settings['show_sidebar'])) + ? aksrt_archive_has_sidebar(!empty($archive_settings['show_sidebar'])) : (!empty($archive_settings['show_sidebar']) && is_active_sidebar('tag_sidebar')); $description = !empty($archive_settings['show_desc']) ? wp_kses_post((string) $archive_settings['description']) : ''; $header_style = (string) $archive_settings['header_style']; diff --git a/tests/widget-system/post-visual-contract.test.cjs b/tests/widget-system/post-visual-contract.test.cjs index c7d71bc1..07b81c7f 100644 --- a/tests/widget-system/post-visual-contract.test.cjs +++ b/tests/widget-system/post-visual-contract.test.cjs @@ -356,14 +356,42 @@ test('the pinned visual baseline records all source checksums', () => { } }); -test('single posts reserve a sidebar column only when its widget stack has content', () => { +test('every scene reserves a sidebar column only when its widget stack has content', () => { const layout = read('inc/helpers/template-tags/site-layout.php'); const single = read('inc/helpers/aksrt-single.php'); const aside = read('inc/helpers/aksrt-single-aside.php'); + const homepage = read('inc/helpers/homepage/content.php'); + const sidebarTemplate = read('sidebar.php'); + const archiveHelpers = read('inc/helpers/aksrt-archive.php'); + + // Single visibility decision: an empty widget stack collapses every scene + // (home/category/tag/search/page/archive) to no-sidebar, not just singles. + assert.match(layout, /if \(!aksrt_has_current_sidebar_widgets\(\)\) \{\s*return false;/); + assert.doesNotMatch(layout, /is_single\(\) && !aksrt_has_current_sidebar_widgets/); + + // The resolver must answer home_sidebar before the is_page() branch so a + // static front page is checked against the zones the homepage renders. + const resolver = layout.match(/function aksrt_resolve_sidebar_id\(\): string \{[\s\S]*?\n\}/); + assert.ok(resolver, 'aksrt_resolve_sidebar_id should exist'); + assert.ok( + resolver[0].indexOf('is_home() || is_front_page()') < resolver[0].indexOf('is_page()'), + 'home/front_page branch must precede the is_page() branch' + ); - assert.match(layout, /if \(is_single\(\) && !aksrt_has_current_sidebar_widgets\(\)\) \{\s*return false;/); assert.match(single, /\$show_aside = get_post_type\(\$post_id\) === 'post'[\s\S]*?&& aksrt_is_show_sidebar\(\);/); assert.match(aside, /get_post_type\(\$post_id\) !== 'post' \|\| empty\(\$ctx\['show_aside'\]\)/); + + // Homepage aside renders under the same single decision; no dual gate. + assert.match(homepage, /function aksrt_homepage_render_sidebar\(\): void \{\s*if \(!aksrt_is_show_sidebar\(\)\) \{\s*return;/); + assert.doesNotMatch(homepage, /aksrt_homepage_has_sidebar/); + + // Generic sidebar template early-returns instead of rendering an empty column. + assert.match(sidebarTemplate, /if \(!function_exists\('aksrt_is_show_sidebar'\) \|\| !aksrt_is_show_sidebar\(\)\) \{\s*return;/); + assert.doesNotMatch(sidebarTemplate, /legacy parity/); + + // Archive helper takes only the page-level toggle; no dead params. + assert.match(archiveHelpers, /function aksrt_archive_has_sidebar\(bool \$enabled = true\): bool/); + assert.doesNotMatch(archiveHelpers, /preferred|wp_is_mobile/); }); test('article visual matrix pins every breakpoint, state and strict threshold', () => {