mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-21 04:11:59 +08:00
improved semantic html - widgets - revision1
This commit is contained in:
parent
74ec0499bd
commit
d41f4037df
1 changed files with 46 additions and 31 deletions
|
@ -125,41 +125,56 @@ if ( ! class_exists( 'Storefront' ) ) :
|
||||||
*
|
*
|
||||||
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
|
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
|
||||||
*/
|
*/
|
||||||
public function widgets_init() {
|
public function widgets_init() {
|
||||||
register_sidebar( array(
|
$sidebar_args['header'] = array(
|
||||||
'name' => __( 'Sidebar', 'storefront' ),
|
|
||||||
'id' => 'sidebar-1',
|
|
||||||
'description' => '',
|
|
||||||
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
||||||
'after_widget' => '</div>',
|
|
||||||
'before_title' => '<h5 class="widget-title">',
|
|
||||||
'after_title' => '</h5>',
|
|
||||||
) );
|
|
||||||
|
|
||||||
register_sidebar( array(
|
|
||||||
'name' => __( 'Below Header', 'storefront' ),
|
'name' => __( 'Below Header', 'storefront' ),
|
||||||
'id' => 'header-1',
|
'id' => 'header-1',
|
||||||
'description' => 'Widgets added to this region will appear beneath the header and above the main content.',
|
'description' => 'Widgets added to this region will appear beneath the header and above the main content.'
|
||||||
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
);
|
||||||
'after_widget' => '</div>',
|
|
||||||
'before_title' => '<h5 class="widget-title">',
|
|
||||||
'after_title' => '</h5>',
|
|
||||||
) );
|
|
||||||
|
|
||||||
$footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 );
|
$sidebar_args['sidebar'] = array(
|
||||||
|
'name' => __( 'Sidebar', 'storefront' ),
|
||||||
|
'id' => 'sidebar-1',
|
||||||
|
'description' => ''
|
||||||
|
);
|
||||||
|
|
||||||
for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) {
|
$footer_widget_regions = apply_filters( 'storefront_footer_widget_regions', 4 );
|
||||||
register_sidebar( array(
|
|
||||||
'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ),
|
for ( $i = 1; $i <= intval( $footer_widget_regions ); $i++ ) {
|
||||||
'id' => sprintf( 'footer-%d', $i ),
|
$footer = sprintf( 'footer_%d', $i );
|
||||||
'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i ),
|
|
||||||
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
$sidebar_args[ $footer ] = array(
|
||||||
'after_widget' => '</div>',
|
'name' => sprintf( __( 'Footer %d', 'storefront' ), $i ),
|
||||||
'before_title' => '<h5>',
|
'id' => sprintf( 'footer-%d', $i ),
|
||||||
'after_title' => '</h5>',
|
'description' => sprintf( __( 'Widgetized Footer Region %d.', 'storefront' ), $i )
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
foreach ( $sidebar_args as $sidebar => $args ) {
|
||||||
|
$widget_tags = array(
|
||||||
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
||||||
|
'after_widget' => '</div>',
|
||||||
|
'before_title' => '<span class="widget-title">',
|
||||||
|
'after_title' => '</span>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue