6 ) :
// Four widgets per row if there are exactly four or more than six
$widget_classes .= ' col-md-3';
elseif ( 6 == $widget_count ) :
// If two widgets are published
$widget_classes .= ' col-md-2';
elseif ( $widget_count >= 3 ) :
// Three widgets per row if there's three or more widgets
$widget_classes .= ' col-md-4';
elseif ( 2 == $widget_count ) :
// If two widgets are published
$widget_classes .= ' col-md-6';
elseif ( 1 == $widget_count ) :
// If just on widget is active
$widget_classes .= ' col-md-12';
endif;
return $widget_classes;
endif;
}
}
add_action( 'widgets_init', 'understrap_widgets_init' );
if ( ! function_exists( 'understrap_widgets_init' ) ) {
/**
* Initializes themes widgets.
*/
function understrap_widgets_init() {
register_sidebar( array(
'name' => __( 'Right Sidebar', 'understrap' ),
'id' => 'right-sidebar',
'description' => 'Right sidebar widget area',
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Left Sidebar', 'understrap' ),
'id' => 'left-sidebar',
'description' => 'Left sidebar widget area',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Hero Slider', 'understrap' ),
'id' => 'hero',
'description' => 'Hero slider area. Place two or more widgets here and they will slide!',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => __( 'Hero Static', 'understrap' ),
'id' => 'statichero',
'description' => 'Static Hero widget. no slider functionallity',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'understrap' ),
'id' => 'footer1',
'description' => 'Widget area below main content and above footer',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'understrap' ),
'id' => 'footer2',
'description' => 'Widget area below main content and above footer',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 3', 'understrap' ),
'id' => 'footer3',
'description' => 'Widget area below main content and above footer',
'before_widget' => '',
'before_title' => '',
) );
}
} // endif function_exists( 'understrap_widgets_init' ).