'aspen_vertical_menu', 'description' => 'Use this widget to add one of your custom menus as a widget.' . ' Use Aspen Menu Bar settings to display simple Rollover vertical menu.' ); parent::WP_Widget( 'aspen_pro_nav_menu', 'Aspen Vertical Menu' , $widget_ops ); } function widget($args, $instance) { // Get menu $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] ); $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $type = $instance['menu_style']; if (!$type) $type='vertical'; $wrap = 'menu_widget'; $class = 'menu_bar'; // most will use menubar as the base style switch ($type) { case 'vertical': // simple, no popoup vertical menu $class = 'menu-vertical'; break; case 'left': // pop-out to the left side $wrap = 'menu_pop_left'; break; case 'right': // pop-out to the right side $wrap = 'menu_pop_right'; break; default: break; } echo $args['before_widget']; if ( !empty($instance['title']) ) echo $args['before_title'] . $instance['title'] . $args['after_title']; echo aspen_pro_extra_menu_generate_code($nav_menu, $wrap, $class ); echo $args['after_widget']; } function update( $new_instance, $old_instance ) { $instance['title'] = strip_tags( stripslashes($new_instance['title']) ); $instance['nav_menu'] = (int) $new_instance['nav_menu']; $instance['menu_style'] = $new_instance['menu_style']; return $instance; } function form( $instance ) { $title = isset( $instance['title'] ) ? $instance['title'] : ''; $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; $menu_style = isset( $instance['menu_style'] ) ? $instance['menu_style'] : ''; // Get menus $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); $styles = array ('Vertical' => 'vertical', 'Pop Out to Left' => 'left', 'Pop Out to Right' => 'right', 'Horizontal' => 'horizontal'); // If no menus exists, direct the user to go and create some. if ( !$menus ) { echo '
'. sprintf( 'No menus have been created yet. Create some.', admin_url('nav-menus.php') ) .'
'; return; } ?>
'primary', // default menu name 'style' => 'menu-vertical', // default menu style id (should be class) 'width' => '', 'border_color' => '', 'css' => '', 'wrap' => 'extra_menu' ), $args)); return aspen_pro_extra_menu_generate_code($menu,$wrap , $style, $border_color,$css,$width); } function aspen_pro_extra_menu_generate_code($menu, $wrap = 'extra_menu', $style='menu-vertical', $border_color='',$css='',$width='',$id='') { $container_class = $wrap; if ($style[0] == '.') $style = substr($style,1); $wstyle = $width ? 'width:' . $width . ';' : ''; if ($border_color == '') $bstyle = ''; else $bstyle = 'border: 1px solid ' . $border_color .';'; if ($bstyle != '' || $css != '' || $wstyle != '' ) $add_style = ' style="' . $bstyle . $css . $wstyle .'"'; else $add_style = ''; $out = '