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: patch
Type: fixed

Forms: Better handle custom submission message formatting
15 changes: 11 additions & 4 deletions projects/packages/forms/src/contact-form/class-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,8 @@ private static function render_ajax_success_wrapper( $form, $submission_success
"</h4>\n\n";

if ( 'message' === $form->get_attribute( 'customThankyou' ) ) {
$raw_message = wpautop( $form->get_attribute( 'customThankyouMessage' ) );
$raw_message = $form->get_attribute( 'customThankyouMessage' );

// Add more allowed HTML elements for file download links
$allowed_html = array(
'br' => array(),
Expand All @@ -1007,7 +1008,10 @@ private static function render_ajax_success_wrapper( $form, $submission_success
),
);

$html .= wp_kses( $raw_message, $allowed_html );
$message = wp_kses( $raw_message, $allowed_html );
$message = '<div class="jetpack_forms_contact-form-custom-success-message">' . $message . '</div>';

$html .= $message;
} elseif ( ! $disable_summary ) {
$html .= '<template data-wp-each--submission="context.formattedSubmissionData">
<div>
Expand Down Expand Up @@ -1057,7 +1061,8 @@ public static function success_message( $feedback_id, $form ) {
$disable_summary = 'noSummary' === $form->get_attribute( 'customThankyou' );

if ( 'message' === $form->get_attribute( 'customThankyou' ) ) {
$raw_message = wpautop( $form->get_attribute( 'customThankyouMessage' ) );
$raw_message = $form->get_attribute( 'customThankyouMessage' );

// Add more allowed HTML elements for file download links
$allowed_html = array(
'br' => array(),
Expand All @@ -1072,7 +1077,9 @@ public static function success_message( $feedback_id, $form ) {
'style' => array(),
),
);
$message = wp_kses( $raw_message, $allowed_html );

$message = wp_kses( $raw_message, $allowed_html );
$message = '<div class="jetpack_forms_contact-form-custom-success-message">' . $message . '</div>';
} elseif ( ! $disable_summary ) {
$compiled_form = self::get_compiled_form( $feedback_id );
$message = '<p>' . implode( '</p><p>', $compiled_form ) . '</p>';
Expand Down
9 changes: 9 additions & 0 deletions projects/packages/forms/src/contact-form/css/grunion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ that needs to mimic the input element styles */
word-wrap: break-word;
}

.contact-form-submission :where(.jetpack_forms_contact-form-custom-success-message) p {
margin: revert;
}

.contact-form-submission :where(.jetpack_forms_contact-form-custom-success-message) {
white-space: pre-wrap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add text-wrap: pretty; which has pretty wide support and results in nice, balanced multi-line flow. It often is applied already by modern themes, but if not then ours fills the gap for the rest of the themes.

text-wrap: pretty;
}

.contact-form-submission h4 {
margin-top: 32px;
margin-bottom: 32px;
Expand Down
Loading