Meta box for custom sidebar

function ter_create_page_meta_box(){ new TerPageMetaBox(); }

if(is_admin()){
add_action('load-post.php','ter_create_page_meta_box');
add_action('load-post-new.php','ter_create_page_meta_box');
}

class TerPageMetaBox{
public function __construct(){
add_action('add_meta_boxes',array($this,'add_meta_box'));
add_action('save_post',array($this,'save'));
}

public function add_meta_box($post_type){
$post_types = array('page','locations','services','resources');
if(in_array($post_type,$post_types)) add_meta_box('ter_page_meta_box',__('Custom Sidebar HTML','terra'),array($this,'render_meta_box_content'),$post_type,'advanced','high');
}

public function save($post_id){
$post_types = array('page','locations','services','resources');
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if(!in_array($_POST['post_type'],$post_types)) return $post_id;
if(!wp_verify_nonce($_POST['ter_custom_sidebar'],plugin_basename(__FILE__))) return $post_id;
if(!current_user_can('edit_post',$post_id)) return $post_id;
update_post_meta($post_id,'ter_custom_sidebar_html',$_POST['ter_custom_sidebar_html']);
}

public function render_meta_box_content($post){
wp_nonce_field(plugin_basename(__FILE__),'ter_custom_sidebar');
echo '<label>Sidebar HTML:</label><br>';
echo '<textarea style="width:90%" name="ter_custom_sidebar_html">' . esc_attr(get_post_meta($post->ID,'ter_custom_sidebar_html',1)) . '</textarea>';
}
}

Sidebar Register Array

//Register Sidebar Widgets
$sidebars = array('Home','Activity','Members','Groups','Blog');
foreach($sidebars as $sidebar) {
register_sidebar(array('name'=> $sidebar,
'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">',
'after_widget' => '</div></div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}

Register Sidebar

register_sidebars(1,array('name' => 'Magazine','before_widget' => '<div id="%1$s" class="block widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));

Sidebar for wordpress page

//to include the sidebar on your page
<?php include(TEMPLATEPATH . '/sidebar-contact.php'); ?>

//for the sidebar-test.php file
<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( 2 ) ) : ?>

<?php endif; ?>

</div><!-- /sidebar -->

Sidebar category highlighting

/* Sidebar link highlighting for the children of a category */
.widget ul.children li.current-cat a:link, .widget ul.children li.current-cat a:visited {
color: #80552B;
}
/* Sidebar link highlighting for the parent category */
.widget li.current-cat a:link, .widget li.current-cat a:visited {
color: #80552B;
}
/* Overwrite the rule that highlights all the children of the parent */
.widget ul.children li a:link, .widget ul.children li a:visited {
color: #2D2F31;
}