/**
  * Renders the widget form field and returns markup as string
  *
  * @param     AbstractWidget $widget The widget to render the field for
  * @param     array $instance The current widget instance
  * @param     string $fieldName The name of the field to render
  *
  * @return    string                      The field markup
  */
 public static function renderField(AbstractWidget $widget, array $instance, $fieldName)
 {
     $field = $widget->getField($fieldName);
     $field['value'] = $instance[$fieldName];
     try {
         $field = self::validateField($field, $widget, $instance);
     } catch (InvalidArgumentException $e) {
         add_notice($e->getMessage(), 'error');
         return '';
     }
     extract($field);
     /**
      * Variables defined by extract( $field )
      *
      * @var     $name     string
      * @var     $type     string
      * @var     $wp_id    string
      * @var     $wp_name  string
      * @var     $value    mixed
      * @var     $options  array
      * @var     $caption  string
      */
     $placeholder = (isset($default_placeholder) and $default_placeholder === true and $widget->getShortcode() instanceof AbstractShortcode) ? 'placeholder="' . $widget->getShortcode()->getDefaultAttribute($name) . '"' : null;
     ob_start();
     /** Start of Field Element */
     echo '<p>';
     /** Field Label */
     if (isset($caption) and !empty($caption) and $type != 'checkbox') {
         echo '<label for="' . $wp_id . '">' . $caption . '</label>';
     }
     switch ($type) {
         /** Field Types: text, date, time, 'email', 'url' */
         case 'text':
         case 'date':
         case 'time':
         case 'email':
         case 'url':
             echo '<input class="widefat" type="' . $type . '" id="' . $wp_id . '" name="' . $wp_name . '" value="' . $value . '" ' . $placeholder . ' />';
             break;
             /** Field Type: textarea */
         /** Field Type: textarea */
         case 'textarea':
             echo '<textarea class="widefat" id="' . $wp_id . '" name="' . $wp_name . '" ' . $placeholder . '>' . $value . '</textarea>';
             break;
             /** Field Types: select, select-multi */
         /** Field Types: select, select-multi */
         case 'select':
         case 'select-multi':
             $is_multi = $type == 'select-multi';
             $multi = $is_multi ? 'multiple="multiple"' : null;
             $size = $is_multi ? 5 : 1;
             $wp_name = $is_multi ? $wp_name . '[]' : $wp_name;
             $style = $is_multi ? 'style="height: 50px;"' : null;
             echo '<select class="widefat" id="' . $wp_id . '" name="' . $wp_name . '" size="' . $size . '" ' . $style . ' ' . $multi . '>';
             foreach ($options as $key => $caption) {
                 $selected = 'selected="selected"';
                 if ($is_multi) {
                     $selected = in_array($key, (array) $value) ? $selected : null;
                 } else {
                     $selected = $key == $value ? $selected : null;
                 }
                 echo '<option value="' . $key . '" ' . $selected . '>' . $caption . '</option>';
             }
             echo '</select>';
             break;
             /** Field Type: checkbox (single) */
         /** Field Type: checkbox (single) */
         case 'checkbox':
             $checked = $value !== null ? 'checked="checked"' : null;
             echo '<label for="' . $wp_id . '">';
             echo '<input type="checkbox" name="' . $wp_name . '" id="' . $wp_id . '" ' . $checked . ' />';
             echo $caption;
             echo '</label>';
             break;
     }
     if (isset($description) and is_string($description)) {
         echo '<span class="op-widget-description">' . $description . '</span>';
     }
     echo '</p>';
     $output = ob_get_contents();
     ob_clean();
     return $output;
 }