Skip to content

Commit

Permalink
Contact Form: Add IP & date to CSV Export (#14304)
Browse files Browse the repository at this point in the history
Add feedback's IP & date to csv export
  • Loading branch information
airdrummer authored and kraftbj committed Jan 10, 2020
1 parent c99e4c9 commit 6fec780
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions modules/contact-form/grunion-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,13 @@ public function get_post_content_for_csv_export( $post_id ) {
* @param int $post_id Id of the post to fetch meta data for.
*
* @return mixed
*
* @codeCoverageIgnore - No need to be covered.
*/
public function get_post_meta_for_csv_export( $post_id ) {
return get_post_meta( $post_id, '_feedback_extra_fields', true );
$md = get_post_meta( $post_id, '_feedback_extra_fields', true );
$md['feedback_date'] = get_the_date( DATE_RFC3339, $post_id );
$content_fields = self::parse_fields_from_content( $post_id );
$md['feedback_ip'] = ( isset( $content_fields['_feedback_ip'] ) ) ? $content_fields['_feedback_ip'] : 0;
return $md;
}

/**
Expand Down Expand Up @@ -888,6 +890,7 @@ public function map_parsed_field_contents_of_post_to_field_names( $parsed_post_c
'_feedback_author_email' => '2_Email',
'_feedback_author_url' => '3_Website',
'_feedback_main_comment' => '4_Comment',
'_feedback_author_ip' => '5_IP',
);

foreach ( $field_mapping as $parsed_field_name => $field_name ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ public function test_personal_data_exporter() {
$this->assertSame( 'feedback', $data['group_id'], 'group_id matches' );
$this->assertSame( 'Feedback', $data['group_label'], 'group_label matches' );
$this->assertSame( true, ! empty( $data['item_id'] ), 'has item_id key' );
$this->assertSame( 6, count( $data['data'] ), 'has total expected data keys' );
$this->assertSame( 8, count( $data['data'] ), 'has total expected data keys' );
}
}

Expand Down

0 comments on commit 6fec780

Please sign in to comment.