fix: populate sidebar context for pages using Page with Sidebar template, use block_template_part for footer (v1.0.6)

- ContextBuilder now calls getSidebarData() when page template slug is
  'page-sidebar', fixing empty sidebar on pages with that template
- Added block_template_part() Twig function to TwigService for FSE
  Template Editor compatibility
- Changed footer rendering from include to block_template_part() so
  footer edits in the Template Editor take effect

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 21:44:45 +01:00
parent 815f6fa19e
commit 67cd585a82
5 changed files with 23 additions and 2 deletions

View File

@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## [1.0.6] - 2026-02-14
### Fixed
- Sidebar widgets not rendered on pages using the "Page with Sidebar" template — `ContextBuilder::build()` only populated `sidebar` context for `is_home()`, so `page-sidebar.html.twig` received no widget data
## [1.0.5] - 2026-02-11
### Added

View File

@@ -69,6 +69,14 @@ class ContextBuilder
$context['sidebar'] = $this->getSidebarData();
}
// Sidebar data for pages/posts using the "Page with Sidebar" template.
if (is_page() || is_singular('post')) {
$slug = get_page_template_slug();
if ($slug === 'page-sidebar') {
$context['sidebar'] = $this->getSidebarData();
}
}
return $context;
}

View File

@@ -136,6 +136,13 @@ class TwigService
$this->twig->addFunction(new TwigFunction('number_format_i18n', function (float $number, int $decimals = 0): string {
return number_format_i18n($number, $decimals);
}));
// Block template parts (allows FSE Template Editor changes to take effect).
$this->twig->addFunction(new TwigFunction('block_template_part', function (string $part): string {
ob_start();
block_template_part($part);
return ob_get_clean();
}, ['is_safe' => ['html']]));
}
private function registerWordPressGlobals(): void

View File

@@ -7,7 +7,7 @@ Description: A modern WordPress Block Theme built from scratch with Bootstrap 5.
Requires at least: 6.7
Tested up to: 6.7
Requires PHP: 8.3
Version: 1.0.5
Version: 1.0.6
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wp-bootstrap

View File

@@ -19,7 +19,7 @@
</main>
{% block footer %}
{% include 'partials/footer.html.twig' %}
{{ block_template_part('footer') }}
{% endblock %}
{{ wp_footer() }}