PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.9.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.9.0
5.9.0 5.8.0 5.8.1 5.7.0 5.6.2 5.6.3 5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 All 42 releases
← All changes | src/Integration/CF7Integration.php +38 -1 5.8.1 → 5.9.0 View file →
@@ -32,9 +32,9 @@
32 32 *
33 33 * Integration for Contact Form 7.
34 34 * Handles opt-in creation, confirmation mail sending, and admin panel.
35 35 */
36 -class CF7Integration extends AbstractFormIntegration implements AdminPanelInterface {
36 +class CF7Integration extends AbstractFormIntegration implements AdminPanelInterface, FieldTextProviderInterface {
37 37
38 38 /**
39 39 * Current OptIn for mail attachment handling.
40 40 *
@@ -906,8 +906,45 @@
906 906 }
907 907 }
908 908
909 909 return $fields;
910 + }
911 +
912 + /**
913 + * The text of each [acceptance]…[/acceptance] tag, as the visitor reads it.
914 + *
915 + * @param int|string $formId
916 + *
917 + * @return array<string, string>
918 + */
919 + public function getFieldTexts( $formId ): array {
920 + $formId = (int) $formId;
921 + $post = get_post( $formId );
922 + if ( ! $post || $post->post_type !== 'wpcf7_contact_form' || ! class_exists( '\WPCF7_ContactForm' ) ) {
923 + return array();
924 + }
925 +
926 + $contactForm = \WPCF7_ContactForm::get_instance( $formId );
927 + if ( ! $contactForm ) {
928 + return array();
929 + }
930 +
931 + $texts = array();
932 + foreach ( $contactForm->scan_form_tags( array( 'basetype' => 'acceptance' ) ) as $tag ) {
933 + $text = self::plainText( (string) ( $tag->content ?? '' ) );
934 + if ( ! empty( $tag->name ) && $text !== '' ) {
935 + $texts[ (string) $tag->name ] = $text;
936 + }
937 + }
938 + return $texts;
939 + }
940 +
941 + /**
942 + * Markup as the visitor reads it: tags removed, whitespace collapsed.
943 + */
944 + public static function plainText( string $html ): string {
945 + $text = html_entity_decode( wp_strip_all_tags( $html ), ENT_QUOTES, 'UTF-8' );
946 + return trim( (string) preg_replace( '/\s+/u', ' ', $text ) );
910 947 }
911 948
912 949 /**
913 950 * Add editor panel to CF7.