From d60829558b0b057ad862da06484b907104b4f849 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Fri, 31 Mar 2023 11:38:58 -0400 Subject: [PATCH] Fix sidebar behavior in News theme ** Why are these changes being introduced: * The News theme templates refer to a "subscribe" sidebar, rather than properly receiving sidebars defined in the Parent theme. * Additionally, some sidebars from the Parent theme are not relevant for this theme, and should be removed to prevent accidental use. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/lm-296 ** How does this address that need: * This takes the approach of unregistering sidebars, which we already use in the Child theme, and implements it (via functions.php) for the News theme. We unregister inherited sidebars that are not needed, leaving only "sidebar-1" and "sidebar-404" (the migrated content area) * The sidebar.php partial, which references the "subscribe" sidebar, is updated to refer instead to "sidebar-1" ** Document any side effects to this change: * The indenting on the sidebar partial is also reduced, and some extra whitespace removed. --- web/app/themes/mitlib-news/functions.php | 11 +++++++++++ web/app/themes/mitlib-news/sidebar.php | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/web/app/themes/mitlib-news/functions.php b/web/app/themes/mitlib-news/functions.php index 13ebb4f7..d3a0b614 100644 --- a/web/app/themes/mitlib-news/functions.php +++ b/web/app/themes/mitlib-news/functions.php @@ -91,6 +91,17 @@ function prune_inherited_templates( $page_templates ) { } add_filter( 'theme_page_templates', 'Mitlib\News\prune_inherited_templates' ); +/** + * Remove unwanted widget areas inherited from the Parent theme. + */ +function remove_parent_widgets() { + unregister_sidebar( 'sidebar-2' ); + unregister_sidebar( 'sidebar-3' ); + unregister_sidebar( 'sidebar-search' ); + unregister_sidebar( 'sidebar-hours' ); +} +add_action( 'widgets_init', 'Mitlib\News\remove_parent_widgets', 11 ); + /** * ============================================================================ * ============================================================================ diff --git a/web/app/themes/mitlib-news/sidebar.php b/web/app/themes/mitlib-news/sidebar.php index b13a6ab0..e836403f 100644 --- a/web/app/themes/mitlib-news/sidebar.php +++ b/web/app/themes/mitlib-news/sidebar.php @@ -12,8 +12,8 @@ ?> - +