diff --git a/inc/class-storefront.php b/inc/class-storefront.php index f7996ac5..ec6a1bfc 100644 --- a/inc/class-storefront.php +++ b/inc/class-storefront.php @@ -125,41 +125,56 @@ if ( ! class_exists( 'Storefront' ) ) : * * @link http://codex.wordpress.org/Function_Reference/register_sidebar */ - public function widgets_init() { - register_sidebar( array( - 'name' => __( 'Sidebar', 'storefront' ), - 'id' => 'sidebar-1', - 'description' => '', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '
', - 'after_title' => '
', - ) ); - - register_sidebar( array( + public function widgets_init() { + $sidebar_args['header'] = array( 'name' => __( 'Below Header', 'storefront' ), 'id' => 'header-1', - 'description' => 'Widgets added to this region will appear beneath the header and above the main content.', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '
', - 'after_title' => '
', - ) ); + 'description' => 'Widgets added to this region will appear beneath the header and above the main content.' + ); + + $sidebar_args['sidebar'] = array( + 'name' => __( 'Sidebar', 'storefront' ), + 'id' => 'sidebar-1', + 'description' => '' + ); - $footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 ); + $footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 ); + + for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) { + $footer = sprintf( 'footer_%d', $i ); + + $sidebar_args[ $footer ] = array( + 'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ), + 'id' => sprintf( 'footer-%d', $i ), + 'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i ) + ); + } - for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) { - register_sidebar( array( - 'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ), - 'id' => sprintf( 'footer-%d', $i ), - 'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i ), - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '
', - 'after_title' => '
', - ) - ); - } + foreach ( $sidebar_args as $sidebar => $args ) { + $widget_tags = array( + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '', + 'after_title' => '' + ); + + // Dynamically generated filter hooks. Allow changing widget wrapper and title tags. See the list below. + // + // 'storefront_header_widget_tags' + // 'storefront_sidebar_widget_tags' + // + // 'storefront_footer_1_widget_tags' + // 'storefront_footer_2_widget_tags' + // 'storefront_footer_3_widget_tags' + // 'storefront_footer_4_widget_tags' + // ...and so on if you did add more footer widget regions via `storefront_footer_widget_regions` filter hook. + $filter_hook = sprintf( 'storefront_%s_widget_tags', $sidebar ); + $widget_tags = apply_filters( $filter_hook, $widget_tags ); + + if ( is_array( $widget_tags ) ) { + register_sidebar( $args + $widget_tags ); + } + } } /**