public static function get_meta_row($citation = array()) { $fields = CandelaCitation::citation_fields(); if (empty($citation)) { $citation = array_fill_keys(array_keys($fields), ''); } foreach ($fields as $key => $widget) { switch ($widget['type']) { case 'select': if (is_array($citation[$key])) { $fields[$key]['options'] = CandelaCitation::GetOptions($key, $citation[$key]); } else { $fields[$key]['options'] = CandelaCitation::GetOptions($key, array($citation[$key])); } break; default: $fields[$key]['value'] = empty($citation[$key]) ? '' : $citation[$key]; break; } } $row = array(); foreach ($fields as $key => $widget) { $id = 'citation-' . esc_attr($key) . '[%%INDEX%%]'; switch ($widget['type']) { case 'select': $markup = '<select name="' . $id . '" id="' . $id . '">'; foreach ($widget['options'] as $value => $option) { $markup .= '<option value="' . esc_attr($value) . '" ' . ($option['selected'] ? 'selected' : '') . '>' . esc_html($option['label']) . '</option>'; } $markup .= '</select>'; $row[$key] = array('widget' => $markup, 'label' => $widget['label'], 'label-html' => '<label for="citation-' . esc_attr($key) . '[%%INDEX%%]">' . $widget['label'] . '</label>'); break; default: $row[$key] = array('widget' => '<input name="' . $id . '" id="' . $id . '" type="' . $widget['type'] . '" value="' . esc_attr($widget['value']) . '" pattern="[^\\x22]+" title="Sorry, no quotes. Do not ask.">', 'label' => $widget['label'], 'label-html' => '<label for="citation-' . esc_attr($key) . '[%%INDEX%%]">' . $widget['label'] . '</label>'); break; } } return $row; }