Skip to content

Commit 99909ed

Browse files
author
Mike van den Hoek
committed
sc6629: disable readspeaker for hidden fields
1 parent 225c1b1 commit 99909ed

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

app/GravityForms/GravityForms.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class GravityForms
1111

1212
public function register(): void
1313
{
14+
add_filter('gform_field_content', [$this, 'disableReadSpeakerHiddenField'], 10, 5);
1415
add_action('pre_get_posts', [$this, 'handleLegacyForms']);
1516
add_filter('gform_form_theme_slug', [$this, 'setFormThemeSlug'], 10, 2);
1617
add_filter('gform_incomplete_submissions_expiration_days', fn () => self::INCOMPLETE_SUBMISSIONS_EXPIRATION_DAYS);
@@ -22,6 +23,19 @@ public function register(): void
2223

2324
// Remove the encryption filter for merge tags so the data can be used in emails.
2425
remove_filter('gform_merge_tag_filter', 'gf_encryption_gform_merge_tag_filter', 10, 4);
26+
27+
}
28+
29+
/**
30+
* Disable ReadSpeaker for hidden fields
31+
*/
32+
public function disableReadSpeakerHiddenField(string $content, GF_Field $field, $value, int $lead_id, int $form_id): string
33+
{
34+
if ('hidden' === $field->type) {
35+
$content = str_replace('<input', '<input class="rs_skip"', $content);
36+
}
37+
38+
return $content;
2539
}
2640

2741
/**

0 commit comments

Comments
 (0)