Grunion_Contact_Form_Plugin::make_csv_row_from_feedback PHP Метод

make_csv_row_from_feedback() защищенный статический Метод

Creates a valid csv row from a post id
Устаревший: This is no longer needed, as of the CSV export rewrite.
protected static make_csv_row_from_feedback ( integer $post_id, array $fields ) : String
$post_id integer The id of the post
$fields array An array containing the names of all the fields of the csv
Результат String The csv row
    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;
    }