|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | /** |
9 | | - * Register widget area. |
| 9 | + * Register widgetized areas. |
10 | 10 | */ |
11 | 11 | function sparkpress_theme_widgets_init() { |
| 12 | + register_sidebar( |
| 13 | + array( |
| 14 | + 'name' => 'Primary Sidebar', |
| 15 | + 'id' => 'primary-sidebar', |
| 16 | + 'description' => 'Widget for the sidebar area.', |
| 17 | + 'before_widget' => '<div>', |
| 18 | + 'after_widget' => '</div>', |
| 19 | + ) |
| 20 | + ); |
| 21 | + |
12 | 22 | register_sidebar( |
13 | 23 | array( |
14 | 24 | 'name' => 'Footer', |
15 | 25 | 'id' => 'footer-area', |
16 | | - 'description' => 'Sidebar for a the footer area.', |
| 26 | + 'description' => 'Widget for the footer area.', |
17 | 27 | 'before_widget' => '<div>', |
18 | 28 | 'after_widget' => '</div>', |
19 | | - 'before_title' => '<h3>', |
20 | | - 'after_title' => '</h3>', |
21 | 29 | ) |
22 | 30 | ); |
23 | 31 | } |
24 | 32 | add_action( 'widgets_init', 'sparkpress_theme_widgets_init' ); |
| 33 | + |
| 34 | +/** |
| 35 | + * Adds sidebar and footer widgets to the Timber context. |
| 36 | + * |
| 37 | + * @param array $context The Timber context array. |
| 38 | + * @return array The updated Timber context array with sidebar and footer widgets. |
| 39 | + */ |
| 40 | +function sparkpress_add_widgets_to_context( $context ) { |
| 41 | + $context['sidebar_widget'] = Timber\Timber::get_widgets( 'primary-sidebar' ); |
| 42 | + $context['footer_widget'] = Timber\Timber::get_widgets( 'footer-area' ); |
| 43 | + return $context; |
| 44 | +} |
| 45 | +add_filter( 'timber/context', 'sparkpress_add_widgets_to_context' ); |
0 commit comments