Skip to content

Commit

Permalink
Forms: Properly support formatting options for labels and required te…
Browse files Browse the repository at this point in the history
…xt (#40924)

* Forms: remove formatting options from labels

* update `strip_tags` with `wp_kses_post`

* remove extra param in `wp_kses_post`

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12824476616

Upstream-Ref: Automattic/jetpack@830ba64
  • Loading branch information
ntsekouras authored and matticbot committed Jan 17, 2025
1 parent ec335bb commit b26637a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This is an alpha version! The changes listed here are not final.
- Forms: Fix dropdown icon styling.
- Forms: Fix redirect field styles
- Forms: fix spacing issue in sidebar settings
- Forms: Properly support formatting options for labels and required text
- Upsell nudge: fix click in Safari

## [0.34.6] - 2025-01-13
Expand Down
2 changes: 1 addition & 1 deletion dist/blocks/editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '225ab109b168dbe54a71');
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '4d9251827cfab6618166');
2 changes: 1 addition & 1 deletion dist/blocks/editor.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/contact-form/class-contact-form-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public function render_label( $type, $id, $label, $required, $required_field_tex
class='grunion-field-label{$type_class}" . ( $this->is_error() ? ' form-error' : '' ) . "'"
. $extra_attrs_string
. '>'
. esc_html( $label )
. wp_kses_post( $label )
. ( $required ? '<span class="grunion-label-required" aria-hidden="true">' . $required_field_text . '</span>' : '' )
. "</label>\n";
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ public function render_field( $type, $id, $label, $value, $class, $placeholder,
*
* @param string $var Required field text. Default is "(required)".
*/
$required_field_text = esc_html( apply_filters( 'jetpack_required_field_text', $required_field_text ) );
$required_field_text = wp_kses_post( apply_filters( 'jetpack_required_field_text', $required_field_text ) );

$block_style = 'style="' . $this->block_styles . '"';

Expand Down
4 changes: 2 additions & 2 deletions src/contact-form/class-contact-form-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public static function strip_tags( $data_with_tags ) {
if ( is_array( $data_with_tags ) ) {
foreach ( $data_with_tags as $index => $value ) {
$index = sanitize_text_field( (string) $index );
$value = wp_kses( (string) $value, array() );
$value = wp_kses_post( (string) $value );
$value = str_replace( '&amp;', '&', $value ); // undo damage done by wp_kses_normalize_entities()

$data_without_tags[ $index ] = $value;
}
} else {
$data_without_tags = wp_kses( (string) $data_with_tags, array() );
$data_without_tags = wp_kses_post( (string) $data_with_tags );
$data_without_tags = str_replace( '&amp;', '&', $data_without_tags ); // undo damage done by wp_kses_normalize_entities()
}

Expand Down

0 comments on commit b26637a

Please sign in to comment.