/** * in widget form update hook * @param unknown $instance * @param unknown $new_instance * @param unknown $old_instance */ public static function _hwbtw_in_widget_form_update($instance, $new_instance, $old_instance) { global $wp_registered_widgets; $widget_obj = $wp_registered_widgets[$new_instance['hwbtw-widget-id']]; //re-create this class assign to current widget $hwbtw = new self($widget_obj['callback'][0], $new_instance); //this not work if has more than one button toggle, just only save for first toggle $expandoptions_field = $hwbtw->generate_name('expandoptions', true); session_start(); $_SESSION['a1'] = $widget_obj['callback']; if (isset($new_instance[$expandoptions_field])) { $instance[$expandoptions_field] = $new_instance[$expandoptions_field]; //save expand options } return $instance; }