protected static function make_csv_row_from_feedback($post_id, $fields)
{
$content_fields = self::parse_fields_from_content($post_id);
$all_fields = array();
if (isset($content_fields['_feedback_all_fields'])) {
$all_fields = $content_fields['_feedback_all_fields'];
}
// Overwrite the parsed content with the content we stored in post_meta in a better format.
$extra_fields = get_post_meta($post_id, '_feedback_extra_fields', true);
foreach ($extra_fields as $extra_field => $extra_value) {
$all_fields[$extra_field] = $extra_value;
}
// The first element in all of the exports will be the subject
$row_items[] = $content_fields['_feedback_subject'];
// Loop the fields array in order to fill the $row_items array correctly
foreach ($fields as $field) {
if ($field === __('Contact Form', 'jetpack')) {
// the first field will ever be the contact form, so we can continue
continue;
} elseif (array_key_exists($field, $all_fields)) {
$row_items[] = $all_fields[$field];
} else {
$row_items[] = '';
}
}
return $row_items;
}