Hey all,
I have multi-widget that allows user to select a style for the code, but I cannot get the widget to save to value of the selected radio button. I'm wondering if anybody can spot an error in my code at all?
Thanks.
/** @see WP_Widget::update */
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['testimonials_style'] = strip_tags($new_instance['testimonials_style']);
return $instance;
}
/** @see WP_Widget::form */
function form($instance){
$title = esc_attr($instance['title']);
$testimonials_style = esc_attr($instance['testimonials_style']);
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>">
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
</label>
</p>
<?php _e('Use the following style:'); ?>
<p>
<label for="<?php echo $this->get_field_id('style_sidebar'); ?>">
<?php _e('Sidebar:'.$testimonials_style); ?>
<input class="" id="<?php echo $this->get_field_id('style_sidebar'); ?>" name="<?php echo $this->get_field_id('testimonials_style'); ?>" type="radio" value="style_sidebar" <?php if($testimonials_style === 'style_sidebar'){ echo 'checked="checked"'; } ?> />
</label>
<label for="<?php echo $this->get_field_id('style_box'); ?>">
<?php _e('Box:'.$testimonials_style); ?>
<input class="" id="<?php echo $this->get_field_id('style_box'); ?>" name="<?php echo $this->get_field_id('testimonials_style'); ?>" type="radio" value="style_box" <?php if($style_sidebar === 'style_box'){ echo 'checked="checked"'; } ?> />
</label>
</p>
<?php
}