Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Forms: add browser info to the form response email notification.
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,14 @@ public function process_submission() {
/* translators: Placeholder is the IP address of the person who submitted a form. */
esc_html__( 'IP Address: %1$s', 'jetpack-forms' ),
$comment_author_ip_with_flag
);
}
$footer_browser = null;
if ( $response->get_browser() ) {
$footer_browser = sprintf(
/* translators: Placeholder is the browser and platform used to submit a form. */
esc_html__( 'Browser: %1$s', 'jetpack-forms' ),
$response->get_browser()
) . '<br />';
}

Expand Down Expand Up @@ -2142,6 +2150,7 @@ public function process_submission() {
'<span style="font-size: 12px">',
$footer_time . '<br />',
$footer_ip ? $footer_ip . '<br />' : null,
$footer_browser ? $footer_browser . '<br />' : null,
$footer_url . '<br /><br />',
$footer_mark_as_spam_url ? $footer_mark_as_spam_url . '<br />' : null,
$sent_by_text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,26 @@ public function test_process_submission_will_not_store_ip() {
remove_all_filters( 'jetpack_contact_form_forget_ip_address' );
}

/**
* Tests that the browser information is included in the email message.
*/
public function test_process_submission_includes_browser_in_email() {
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36';
$form = new Contact_Form( array() );
$result = $form->process_submission();

// Processing should be successful and produce the success message.
$this->assertTrue( is_string( $result ) );

$feedback_id = end( Posts::init()->posts )->ID;
$submission = get_post( $feedback_id );

// Browser information should be included in the email.
$email = get_post_meta( $submission->ID, '_feedback_email', true );
$this->assertStringContainsString( 'Browser:', $email['message'] );
$this->assertStringContainsString( 'Chrome', $email['message'] );
}

/**
* Tests that the submission as a whole will produce something in the
* database when some labels are provided.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Forms: add browser info to the form response email notification.
Loading