Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Form: Add IP & date to CSV Export #14304

Merged
merged 6 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
airdrummer marked this conversation as resolved.
Show resolved Hide resolved
*/
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