title: How to create WordPress widget using custom menu select
body: <p>I'm creating a custom widget for WordPress but am wanting to use the same select menu as the default Custom Menu widget does. So far what I have works except the selected menu isn't being saved or displayed on the frontend. Any help or direction with this is appreciated. Thanks. </p>
  
  <p>For brevity, I've removed extra widget options, so this is basically going to look very close to the Custom Menu widget:</p>
  
  <pre><code>class kedc_mini_sitemap extends WP_Widget {
  
  /*constructor*/
  function kedc_mini_sitemap() {
      parent::WP_Widget(false, $name = 'Mini Sitemap');
  }
  
  /**/
  function widget($args, $instance) {
      extract( $args );
  
      // widget options
      $title = apply_filters('widget_title', $instance['title']);
      $nav_menu1 = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
      $checkbox = $instance['checkbox'];
  
      echo $before_widget;    
  
      if ($title) {
          echo $before_title . $title . $after_title;
      }
  
      if ($nav_menu1) {
          echo wp_nav_menu( array( 'fallback_cb' =&gt; '', 'menu' =&gt; $nav_menu1 ) );
      }
  
  
      if ($checkbox == true) {
          echo 'This message is displayed if our checkbox is checked.';
      }
  
      echo $after_widget;
  }
  
  /* saves options chosen from the widgets panel */
  function update($new_instance, $old_instance) {
      $instance = $old_instance;
      $instance['title'] = strip_tags($new_instance['title']);
      $instance['nav_menu'] = (int) $new_instance['nav_menu'];
      $instance['checkbox'] = strip_tags($new_instance['checkbox']);
      return $instance;
  }
  
  /* display widget in widgets panel */
  function form($instance) {  
  
      $title = esc_attr($instance['title']);
      $nav_menu1 = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
      $checkbox = esc_attr($instance['checkbox']);
  
      $menus1 = get_terms( 'nav_menu', array( 'hide_empty' =&gt; false ) );
  
      ?&gt;
  
      &lt;p&gt;
          &lt;label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"&gt;&lt;?php _e('Widget Title:'); ?&gt;&lt;/label&gt;
          &lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;" type="text" value="&lt;?php echo $title; ?&gt;" /&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;label for="&lt;?php echo $this-&gt;get_field_id('nav_menu'); ?&gt;"&gt;&lt;?php _e('Select Menu:'); ?&gt;&lt;/label&gt;
          &lt;select id="&lt;?php echo $this-&gt;get_field_id('nav_menu'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('nav_menu'); ?&gt;"&gt;
              &lt;?php
                  foreach ( $menus1 as $menu1 ) {
                      echo '&lt;option value="' . $menu1-&gt;term_id . '"'
                          . selected( $nav_menu, $menu1-&gt;term_id, false )
                          . '&gt;'. $menu1-&gt;name . '&lt;/option&gt;';
                  }
              ?&gt;
          &lt;/select&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;input id="&lt;?php echo $this-&gt;get_field_id('checkbox'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('checkbox'); ?&gt;" type="checkbox" value="1" &lt;?php checked( '1', $checkbox ); ?&gt;/&gt;
          &lt;label for="&lt;?php echo $this-&gt;get_field_id('checkbox'); ?&gt;"&gt;&lt;?php _e('Do you want this to display as 2 columns?'); ?&gt;&lt;/label&gt;
      &lt;/p&gt;
  
      &lt;?php
  }
  
  }
  
  // register widget
  add_action('widgets_init', create_function('', 'return register_widget("kedc_mini_sitemap");'));
  </code></pre>