<?php


/**
 * Register widgetized area and update sidebar with default widgets
 */





function shrk_init_extra_sidebars() {

	if ( isset ( $_POST ) && isset ( $_POST['action'] ) && $_POST['action'] == 'heartbeat' ) {
		// Buh bye!
		return;
	}

	$sidebars = shrk_get_sidebars();

	if ( !empty( $sidebars ) ) {
		foreach ($sidebars as $sidebar_id => $sidebar_name) {
			register_sidebar( array(
				'id'            => $sidebar_id,
				'name'          => $sidebar_name,
				'before_widget' => '<div id="%1$s" class="widget clearfix %2$s">', 
				'after_widget'  => '</div>', 
				'before_title'  => '<h3 class="widget-title">', 
				'after_title'   => '</h3>', 
			) );
		}
	}
}
add_action( 'widgets_init', 'shrk_init_extra_sidebars', 20 );