mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-20 04:00:29 +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
|
||||
*/
|
||||
public function widgets_init() {
|
||||
register_sidebar( 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(
|
||||
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' => '<div id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h5 class="widget-title">',
|
||||
'after_title' => '</h5>',
|
||||
) );
|
||||
'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' => '<div id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '<h5>',
|
||||
'after_title' => '</h5>',
|
||||
)
|
||||
);
|
||||
}
|
||||
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