__('sidebar default', THEME_NS), 'block' => __('block', THEME_NS), 'post' => __('post', THEME_NS), 'simple' => __('simple text', THEME_NS) ); function theme_get_widget_style($id, $style = null) { if(theme_is_vmenu_widget($id)) return 'vmenu'; $result = theme_get_meta_option($id, 'theme_widget_styles'); global $theme_widgets_style; if (!in_array($result, array_keys($theme_widgets_style))) { $result = 'default'; } if ($style != null) { if (!in_array($style,array('block', 'post', 'simple'))) { $style = 'block'; } if($result == 'default') { $result = $style; } } return $result; } function theme_set_widget_style($id, $style) { global $theme_widgets_style; if (!in_array($style, array_keys($theme_widgets_style))) { $style = 'default'; } theme_set_meta_option($id, 'theme_widget_styles', $style); } function theme_widget_expand_control($id) { global $wp_registered_widget_controls; if (theme_is_vmenu_widget($id)) return; $controls = &$wp_registered_widget_controls[$id]; $controls['params'][] = $id; if (isset($controls['callback'])){ $controls['callback_redirect']=$controls['callback']; } $controls['callback']='theme_widget_extra_control'; } function theme_widget_process_control() { global $wp_registered_widget_controls; if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['widget-id']) ) { $id = $_POST['widget-id']; $id_disp = 'widget-style'; if (isset($_POST[$id_disp])){ theme_set_widget_style($id, $_POST[$id_disp]); } theme_widget_expand_control($id); return; } foreach ( $wp_registered_widget_controls as $id => $widget ) { theme_widget_expand_control($id); } } function theme_widget_extra_control() { global $wp_registered_widget_controls, $theme_widgets_style; $params = func_get_args(); $id = $params[count($params)-1]; $id_disp = 'widget-style'; $val = theme_get_widget_style($id); $widget_controls = theme_get_array_value($wp_registered_widget_controls, $id, array()); if (isset($widget_controls['callback_redirect'])){ $callback = $widget_controls['callback_redirect']; if (is_callable($callback)) { call_user_func_array($callback, $params); } } ?>