diff --git a/projects/packages/forms/changelog/fix-contact-form-ip-field b/projects/packages/forms/changelog/fix-contact-form-ip-field new file mode 100644 index 0000000000000..ce607e9f4098c --- /dev/null +++ b/projects/packages/forms/changelog/fix-contact-form-ip-field @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Form submissions table: ensure the IP address is displayed for each submission, when available. diff --git a/projects/packages/forms/package.json b/projects/packages/forms/package.json index 60f0aa9f14a7d..bd0667764d9f3 100644 --- a/projects/packages/forms/package.json +++ b/projects/packages/forms/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-forms", - "version": "0.32.4", + "version": "0.32.5-alpha", "description": "Jetpack Forms", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme", "bugs": { diff --git a/projects/packages/forms/src/class-jetpack-forms.php b/projects/packages/forms/src/class-jetpack-forms.php index 3c8ae28b8e232..0546a8eb4a3ec 100644 --- a/projects/packages/forms/src/class-jetpack-forms.php +++ b/projects/packages/forms/src/class-jetpack-forms.php @@ -15,7 +15,7 @@ */ class Jetpack_Forms { - const PACKAGE_VERSION = '0.32.4'; + const PACKAGE_VERSION = '0.32.5-alpha'; /** * Load the contact form module. diff --git a/projects/packages/forms/src/contact-form/class-admin.php b/projects/packages/forms/src/contact-form/class-admin.php index 83a428d658b2e..5d37d93caac14 100644 --- a/projects/packages/forms/src/contact-form/class-admin.php +++ b/projects/packages/forms/src/contact-form/class-admin.php @@ -738,6 +738,18 @@ public function grunion_manage_post_column_response( $post ) { } } + // Extract IP address if we still do not have it at this point. + if ( + ! isset( $content_fields['_feedback_ip'] ) + && is_array( $chunks ) + && ! empty( $chunks[0] ) + ) { + preg_match( '/^IP: (.+)$/m', $chunks[0], $matches ); + if ( ! empty( $matches[1] ) ) { + $content_fields['_feedback_ip'] = $matches[1]; + } + } + $response_fields = array_diff_key( $response_fields, array_flip( $non_printable_keys ) ); echo '
'; @@ -757,7 +769,7 @@ public function grunion_manage_post_column_response( $post ) { echo '
'; echo '
'; - if ( isset( $content_fields['_feedback_ip'] ) ) { + if ( ! empty( $content_fields['_feedback_ip'] ) ) { echo '
' . esc_html__( 'IP', 'jetpack-forms' ) . '
'; echo '
' . esc_html( $content_fields['_feedback_ip'] ) . '
'; }