title: Adding textarea "description box" to widget [Wordpress]
body: <p>My widget is showingmin my admin area but when I click it so that it can drop down so that I may enter information... it only shows the DELETE link, CLOSE link and SAVE button. the widget will not expand. I believe I am missing something in the script for the textarea causing the widget not to function properly. </p>
  
  <pre><code>&lt;?php
  if( !class_exists('smWidget') ):
  class smWidget extends WP_Widget {
  
  // constructor
  function smWidget() {
  // Give widget name here
  $widget_ops = array('description' =&gt; __('Displays a selected post from a selected post type.', 'ci_theme'));
  
  parent::WP_Widget('smWidget', $name='-= SM Item =-', $widget_ops);
  }
  
  
  
  
  // display widget
  function widget($args, $instance) {
      extract( $args );
  
  
  
      $ci_post_id = $instance['postid'];
  
          $post_type_name = $instance['post_type_name'];
  
          if( empty($ci_post_id) or empty($post_type_name) )
              return;
  
          $q = new WP_Query( array(
              'post_type' =&gt; $post_type_name,
              'p' =&gt; $ci_post_id
          ) );
  
          echo $before_widget;
  
  
  
  $title = apply_filters( 'widget_title', empty( $instance['title']) ? '' : $instance['title'], $instance, $this-&gt;id_base );
  
          if ($title)
              echo $before_title . $title . $after_title;
  
          while ( $q-&gt;have_posts() ): $q-&gt;the_post();
              global $post;
  
  
  
  
              if ( get_post_type() == 'testimonial' ) :
                  ?&gt;
  
  &lt;div class="testimonial-wrap"&gt;
    &lt;div class="testimonial-inner"&gt;
      &lt;blockquote&gt; &lt;i class="fa fa-quote-left"&gt;&lt;/i&gt;
        &lt;?php the_content(); ?&gt;
        &lt;cite&gt;
        &lt;?php the_title(); ?&gt;
        &lt;/cite&gt; &lt;/blockquote&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php
              elseif ( get_post_type() == 'video' ) :
                  ?&gt;
  &lt;div &lt;?php post_class('item'); ?&gt;&gt;
    &lt;?php 
                          $video = get_post_meta($post-&gt;ID, 'ci_cpt_video_url', true);
                          echo wp_oembed_get($video);
                      ?&gt;
  &lt;/div&gt;
  &lt;?php
              else :
                  get_template_part('loop', 'item');
              endif;
          endwhile;
          wp_reset_postdata();
  
          echo $after_widget;
  
      }
  
      function update($new_instance, $old_instance)
      {
          $instance = $old_instance;
          $instance['title'] = sanitize_text_field($new_instance['title']);
          $instance['post_type_name'] = sanitize_key($new_instance['post_type_name']);
          $instance['postid'] = absint($new_instance['postid']);
          $instance['teatarea'] = absint($new_instance['textarea']);
          return $instance;
      }
  
  
  
  
  
  
  
  
  
  
  
  function form($instance){
  
          $defaults = array(
              'title' =&gt; '',
              'post_type_name' =&gt; 'post',
              'postid' =&gt; '',
              'textarea' =&gt; '',
          );
  
  
          $instance = wp_parse_args( (array) $instance, $defaults );
  
          $title = $instance['title'];
          $post_type_name = $instance['post_type_name'];
          $post_id = $instance['postid'];
          $textarea = $instance['textarea'];
  
          ?&gt;
  &lt;p&gt;
    &lt;label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"&gt;
      &lt;?php _e('Title (optional):', 'ci_theme'); ?&gt;
    &lt;/label&gt;
    &lt;input 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 esc_attr($title); ?&gt;" class="widefat" /&gt;
  &lt;/p&gt;
  &lt;?php
  
          $post_types = get_post_types( array('public' =&gt; true), 'objects' );
          unset($post_types['attachment'], $post_types['slider']);
          ?&gt;
  &lt;p&gt;
  &lt;label for="&lt;?php echo $this-&gt;get_field_id('post_type_name'); ?&gt;"&gt;
  &lt;?php _e('Show posts from this post type:', 'ci_theme'); ?&gt;
  &lt;label&gt;
  &lt;/p&gt;
  &lt;?php ?&gt;
  &lt;select name="&lt;?php echo $this-&gt;get_field_name('post_type_name'); ?&gt;" id="&lt;?php echo $this-&gt;get_field_id('post_type_name'); ?&gt;" &gt;
    &lt;?php
              foreach( $post_types as $key =&gt; $pt )
              {
          ?&gt;
    &lt;option value="&lt;?php echo esc_attr($key); ?&gt;" &lt;?php selected($key, $post_type_name); ?&gt;&gt;&lt;?php echo $pt-&gt;labels-&gt;name; ?&gt;&lt;/option&gt;
    &lt;?php
              }
          ?&gt;
  &lt;/select&gt;
  &lt;img src="&lt;?php echo get_child_or_parent_file_uri('/panel/img/ajax-loader-16x16.gif'); ?&gt;" class="loading_posts" style="display: none;"&gt;
  &lt;?php
          ?&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;?php
          ?&gt;
  &lt;p&gt;
    &lt;label for="&lt;?php echo $this-&gt;get_field_id('postid'); ?&gt;"&gt;
      &lt;?php _e('Select a post to show:', 'ci_theme'); ?&gt;
    &lt;/label&gt;
  &lt;/p&gt;
  &lt;?php
          ?&gt;
  &lt;p class="ci_widget_post_type_posts_dropdown"&gt;
    &lt;?php
          wp_dropdown_posts(
              array(
                  'post_type' =&gt; $post_type_name,
                  'show_option_none' =&gt; '&amp;nbsp;',
                  'selected' =&gt; $post_id,
                  'class' =&gt; 'widefat'
              ),
              $this-&gt;get_field_name('postid')
          );
          ?&gt;
  &lt;/p&gt;
  &lt;?php 
  
          ?&gt;
  &lt;p&gt;
    &lt;label for="&lt;?php echo $this-&gt;get_field_id('textarea'); ?&gt;"&gt;
      &lt;?php _e('Description:', 'ci_theme'); ?&gt;
    &lt;/label&gt;
    &lt;textarea class="widefat" id="&lt;?php echo $this-&gt;get_field_id('textarea'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('textarea'); ?&gt;" rows="7" cols="20" &gt;&lt;?php echo $textarea; ?&gt;&lt;/textarea&gt;
  &lt;/p&gt;
  &lt;?php
      }
  
  
  static function _ajax_get_posts()
      {
          $post_type_name = sanitize_key($_POST['post_type_name']);
          $name_field = esc_attr($_POST['name_field']);
  
          $str = wp_dropdown_posts(
              array(
                  'echo' =&gt; false,
                  'post_type' =&gt; $post_type_name,
                  'show_option_none' =&gt; '&amp;nbsp;',
                  'class' =&gt; 'widefat'
              ),
              $name_field
          );
  
          echo $str;
          die;
      }
  
  } // class
  
  register_widget('smWidget');
  
  add_action('wp_ajax_ci_widget_post_type_ajax_get_posts', 'smWidget::_ajax_get_posts');
  
  endif; // !class_exists
  
  ?&gt;
  </code></pre>