__('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_widget_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_widget_meta_option($id, 'theme_widget_styles', $style); } function theme_widget_expand_control($id) { global $wp_registered_widget_controls; $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_update_widget_additional($instance) { global $theme_widget_meta_options; foreach ($theme_widget_meta_options as $value) { $id = theme_get_array_value($value, 'id'); if( false === ( $val = theme_get_array_value($_POST, $id) ) ) { continue; } $val = stripslashes($val); $type = theme_get_array_value($value, 'type'); $options = theme_get_array_value($value, 'options'); switch ($type) { case 'checkbox': $val = ($val ? 1 : 0); break; case 'numeric': $val = (int) $val; break; case 'select': if (!in_array($val, array_keys($options))) { $val = reset(array_keys($options)); } break; } $instance[$id] = $val; } return $instance; } function theme_widget_process_control() { global $wp_registered_widget_controls; if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['widget-id'])) { theme_widget_expand_control($_POST['widget-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, $theme_widget_meta_options; $_theme_widget_meta_options = $theme_widget_meta_options; $params = func_get_args(); $widget_id = $params[count($params) - 1]; $widget_controls = theme_get_array_value($wp_registered_widget_controls, $widget_id, array()); if (isset($widget_controls['callback_redirect'])) { $callback = $widget_controls['callback_redirect']; if (is_callable($callback)) { call_user_func_array($callback, $params); } } if (!preg_match('/^(.*[^-])-([0-9]+)$/', $widget_id, $matches) || !isset($matches[1]) || !isset($matches[2])) { return false; } $id = $matches[1] . '-' . $params[0]['number']; if (theme_is_vmenu_widget($id)) { $need_delete = false; foreach($_theme_widget_meta_options as $option_id => $option) { if($option['id'] == 'theme_widget_styles') { $need_delete = true; break; } } if($need_delete) { unset($_theme_widget_meta_options[$option_id]); } } ?>
'vmenu', 'description' => __('Use this widget to add one of your custom menus as a widget.', THEME_NS)); parent::WP_Widget(false, __('Vertical Menu', THEME_NS), $widget_ops); } function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $before_widget; echo $before_title . $title . $after_title; echo theme_get_menu(array( 'source' => $instance['source'], 'depth' => theme_get_option('theme_vmenu_depth'), 'menu' => wp_get_nav_menu_object($instance['nav_menu']), 'class' => 'bf-vmenu' )); echo $after_widget; } function update($new_instance, $old_instance) { $instance['title'] = strip_tags($new_instance['title']); $instance['source'] = $new_instance['source']; $instance['nav_menu'] = (int) $new_instance['nav_menu']; return $instance; } function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('title' => '', 'source' => 'Pages', 'nav_menu' => '')); $title = esc_attr($instance['title']); $source = $instance['source']; $nav_menu = $instance['nav_menu']; // Get menus $menus = get_terms('nav_menu', array('hide_empty' => false)); $sources = array('Pages', 'Categories', 'Custom Menu'); ?>
'login', 'description' => __('Login form', THEME_NS)); $this->WP_Widget(false, __('Login', THEME_NS), $widget_ops); } function widget($args, $instance) { global $user_ID, $user_identity, $user_level, $user_email, $user_login; extract($args); echo $before_widget; echo $before_title; if ($user_ID): echo $user_identity; echo $after_title; ?>