Remove empty titles in wordpress sidebar widgets

admin

Administrator
Staff member
I have registered a wordpress sidebar like so:

Code:
register_sidebar( array(
    'name' => __( 'First Sidebar', 'theme_name' ),
    'id' => 'primary-widget-area',
    'description' => __( 'The primary widget area', 'theme_name' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

The problem is that when the title is empty, the <strong>h3</strong>'s still get rendered. Is there a way to remove these when the title is left blank?