| @@ -10,8 +10,9 @@ | ||
| 10 | 10 | |
| 11 | 11 | use Forge12\DoubleOptIn\EmailTemplates\EmailTemplateRepository; |
| 12 | 12 | use Forge12\DoubleOptIn\Health\StaleConsentFieldCheck; |
| 13 | 13 | use Forge12\DoubleOptIn\Integration\FormIntegrationRegistry; |
| 14 | +use Forge12\DoubleOptIn\Integration\FieldTextProviderInterface; | |
| 14 | 15 | use Forge12\DoubleOptIn\Integration\SubmittedContent; |
| 15 | 16 | use Forge12\Shared\LoggerInterface; |
| 16 | 17 | |
| 17 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -338,8 +339,31 @@ | ||
| 338 | 339 | $fieldsList[] = array( |
| 339 | 340 | 'name' => (string) $name, |
| 340 | 341 | 'label' => $label, |
| 341 | 342 | ); |
| 343 | + } | |
| 344 | + | |
| 345 | + // The wording next to each field, where the integration knows it, | |
| 346 | + // so the consent tab can compare it with the stored consent text. | |
| 347 | + $texts = $integrationInstance instanceof FieldTextProviderInterface ? $integrationInstance->getFieldTexts( $formId ) : array(); | |
| 348 | + /** | |
| 349 | + * Visible text per field name (e.g. the label of a consent checkbox). | |
| 350 | + * | |
| 351 | + * @since 5.9.0 | |
| 352 | + * | |
| 353 | + * @param array<string, string> $texts Field name => plain text. | |
| 354 | + * @param int|string $formId The form ID. | |
| 355 | + * @param string $integration The integration identifier. | |
| 356 | + */ | |
| 357 | + $texts = apply_filters( 'f12_doi_form_field_texts', $texts, $formId, $integrationInstance->getIdentifier() ); | |
| 358 | + if ( is_array( $texts ) ) { | |
| 359 | + foreach ( $fieldsList as &$entry ) { | |
| 360 | + $text = $texts[ $entry['name'] ] ?? ''; | |
| 361 | + if ( is_string( $text ) && trim( $text ) !== '' ) { | |
| 362 | + $entry['text'] = trim( $text ); | |
| 363 | + } | |
| 364 | + } | |
| 365 | + unset( $entry ); | |
| 342 | 366 | } |
| 343 | 367 | |
| 344 | 368 | // Reconcile the stored consent field with the form's real field |
| 345 | 369 | // names. Settings written before 5.3.2 went through |