PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.12.0 5.13.0 5.13.1 5.11.0 5.10.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 All 47 releases
← All changes | core/review.php +129 -76 3.1.0 → 5.5.0 View file →
@@ -1,91 +1,144 @@
1 1 <?php
2 -add_action( 'admin_notices', 'f12_cf7_doubleoptin_maybe_show_review_notice' );
3 -add_action( 'admin_init', 'f12_cf7_doubleoptin_handle_review_actions' );
4 2
5 -/**
6 - * Prüft, ob die Review-Notice angezeigt werden soll.
7 - */
8 -function f12_cf7_doubleoptin_maybe_show_review_notice() {
9 - // Nur Admins sehen die Notice
10 - if ( ! current_user_can( 'manage_options' ) ) {
11 - return;
12 - }
3 +namespace forge12\contactform7\CF7DoubleOptIn;
13 4
14 - $installed_at = (int) get_option( 'f12_cf7_doubleoptin_installed_at', time() );
15 - $optin_counters = get_option( 'f12_cf7_doubleoptin_telemetry_counters', [] );
16 - $confirmed_optins = isset( $optin_counters['confirmed_optins'] ) ? (int) $optin_counters['confirmed_optins'] : 0;
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
17 8
18 - $dismissed = get_option( 'f12_cf7_doubleoptin_review_dismissed', false );
19 - $remind_later = (int) get_option( 'f12_cf7_doubleoptin_review_remind_later', 0 );
20 - $remind_count = (int) get_option( 'f12_cf7_doubleoptin_review_remind_count', 0 );
9 +// Prevent double-registration when Free + Pro are both active
10 +if ( ! function_exists( __NAMESPACE__ . '\\f12_cf7_doubleoptin_maybe_show_review_notice' ) ) {
21 11
22 - // Bedingungen:
23 - // - mindestens 10 Tage installiert
24 - // - mindestens 20 Spamversuche blockiert
25 - if ( ( time() - $installed_at ) < DAY_IN_SECONDS * 10 ) {
26 - return;
12 + add_action( 'admin_notices', __NAMESPACE__ . '\\f12_cf7_doubleoptin_maybe_show_review_notice' );
13 + add_action( 'admin_init', __NAMESPACE__ . '\\f12_cf7_doubleoptin_handle_review_actions' );
14 +
15 + /**
16 + * Show review notice if conditions are met.
17 + */
18 + function f12_cf7_doubleoptin_maybe_show_review_notice() {
19 + if ( ! current_user_can( 'manage_options' ) ) {
20 + return;
21 + }
22 +
23 + $installed_at = (int) get_option( 'f12_cf7_doubleoptin_installed_at', time() );
24 + $optin_counters = get_option( 'f12_cf7_doubleoptin_telemetry_counters', [] );
25 + $confirmed_optins = isset( $optin_counters['confirmed_optins'] ) ? (int) $optin_counters['confirmed_optins'] : 0;
26 +
27 + $dismissed = get_option( 'f12_cf7_doubleoptin_review_dismissed', false );
28 + $remind_later = (int) get_option( 'f12_cf7_doubleoptin_review_remind_later', 0 );
29 + $remind_count = (int) get_option( 'f12_cf7_doubleoptin_review_remind_count', 0 );
30 +
31 + // Conditions:
32 + // - installed for at least 10 days
33 + // - at least 25 confirmed opt-ins
34 + //
35 + // The threshold used to be 3. Three confirmations is a site that has
36 + // barely started; asking for a public review at that point is asking
37 + // someone to vouch for something they have not seen work yet.
38 + if ( ( time() - $installed_at ) < DAY_IN_SECONDS * 10 ) {
39 + return;
40 + }
41 +
42 + if ( $confirmed_optins < 25 ) {
43 + return;
44 + }
45 +
46 + if ( $dismissed ) {
47 + return;
48 + }
49 +
50 + if ( $remind_later > 0 && ( time() < $remind_later ) ) {
51 + return;
52 + }
53 +
54 + // Max 2 reminders
55 + if ( $remind_count >= 2 ) {
56 + return;
57 + }
58 +
59 + // Claim this screen. The credit-link notice runs later on the same hook
60 + // and stands down when it sees this — asking a site owner for two
61 + // favours at once is how a plugin earns a one-star review, and the
62 + // review request is the more valuable of the two.
63 + $GLOBALS['f12_doi_review_notice_shown'] = true;
64 +
65 + ?>
66 + <div class="notice notice-info is-dismissible f12-cf7-doubleoptin-review-notice">
67 + <p>
68 + <?php printf(
69 + wp_kses(
70 + /* translators: %d: number of confirmed opt-ins. */
71 + __(
72 + '<strong>Double Opt-In for WordPress</strong> has already confirmed <strong>%d email subscriptions</strong>. Would you support us with a quick review?',
73 + 'double-opt-in'
74 + ),
75 + array( 'strong' => array() )
76 + ),
77 + (int) $confirmed_optins
78 + ); ?>
79 + </p>
80 + <p>
81 + <a href="https://wordpress.org/support/plugin/double-opt-in/reviews/#new-post"
82 + target="_blank"
83 + class="button button-primary">
84 + <?php _e( 'Leave a review now', 'double-opt-in' ); ?>
85 + </a>
86 + <?php
87 + // The only path out of this notice used to be a public review.
88 + // Someone who is unhappy has no other outlet, so the feedback
89 + // lands as a one-star rating that nobody can answer. This gives
90 + // them somewhere to say it to us instead.
91 + ?>
92 + <a href="<?php echo esc_url( get_feedback_url( 'review-notice' ) ); ?>"
93 + target="_blank"
94 + rel="noopener"
95 + class="button">
96 + <?php esc_html_e( 'Something not working? Tell us', 'double-opt-in' ); ?>
97 + </a>
98 + <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'f12_cf7_doubleoptin_review_remind', '1' ), 'doi_review_action' ) ); ?>"
99 + class="button">
100 + <?php _e( 'Remind me later', 'double-opt-in' ); ?>
101 + </a>
102 + <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'f12_cf7_doubleoptin_review_dismissed', '1' ), 'doi_review_action' ) ); ?>"
103 + class="button">
104 + <?php _e( "Don't ask again", 'double-opt-in' ); ?>
105 + </a>
106 + </p>
107 + </div>
108 + <?php
27 109 }
28 110
29 - if ( $confirmed_optins < 3 ) {
30 - return;
31 - }
111 + /**
112 + * Handle review notice actions (dismiss / remind later).
113 + */
114 + function f12_cf7_doubleoptin_handle_review_actions() {
115 + if ( ! current_user_can( 'manage_options' ) ) {
116 + return;
117 + }
32 118
33 - // Bereits dauerhaft dismissed?
34 - if ( $dismissed ) {
35 - return;
36 - }
119 + $is_dismiss = isset( $_GET['f12_cf7_doubleoptin_review_dismissed'] );
120 + $is_remind = isset( $_GET['f12_cf7_doubleoptin_review_remind'] );
37 121
38 - // Reminder-Delay aktiv?
39 - if ( $remind_later > 0 && ( time() < $remind_later ) ) {
40 - return;
41 - }
122 + if ( ! $is_dismiss && ! $is_remind ) {
123 + return;
124 + }
42 125
43 - // Maximal 2 Wiederholungen
44 - if ( $remind_count >= 2 ) {
45 - return;
46 - }
126 + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'doi_review_action' ) ) {
127 + return;
128 + }
47 129
48 - ?>
49 - <div class="notice notice-info is-dismissible f12-cf7-captcha-review-notice">
50 - <p>
51 - <?php printf(
52 - __(
53 - '<strong>Double Opt-In for WordPress</strong> has already confirmed <strong>%d email subscriptions</strong>. Would you support us with a quick review? ❤️',
54 - 'double-opt-in'
55 - ),
56 - $confirmed_optins
57 - ); ?>
58 - </p>
59 - <p>
60 - <a href="https://wordpress.org/support/plugin/double-opt-in/reviews/#new-post"
61 - target="_blank"
62 - class="button button-primary">
63 - <?php _e( 'Leave a review now', 'double-opt-in' ); ?>
64 - </a>
65 - <a href="<?php echo esc_url( add_query_arg( 'f12_cf7_doubleoptin_review_remind', '1' ) ); ?>"
66 - class="button">
67 - <?php _e( 'Remind me later', 'double-opt-in' ); ?>
68 - </a>
69 - <a href="<?php echo esc_url( add_query_arg( 'f12_cf7_doubleoptin_review_dismissed', '1' ) ); ?>"
70 - class="button">
71 - <?php _e( 'Don’t ask again', 'double-opt-in' ); ?>
72 - </a>
73 - </p>
74 - </div>
75 - <?php
76 -}
130 + if ( $is_dismiss ) {
131 + update_option( 'f12_cf7_doubleoptin_review_dismissed', true );
132 + }
77 133
78 -/**
79 - * Verarbeitet Klicks auf die Links der Review-Notice.
80 - */
81 -function f12_cf7_doubleoptin_handle_review_actions() {
82 - if ( isset( $_GET['f12_cf7_doubleoptin_review_dismissed'] ) ) {
83 - update_option( 'f12_cf7_doubleoptin_review_dismissed', true );
84 - }
134 + if ( $is_remind ) {
135 + $remind_count = (int) get_option( 'f12_cf7_doubleoptin_review_remind_count', 0 );
136 + update_option( 'f12_cf7_doubleoptin_review_remind_later', time() + DAY_IN_SECONDS * 7 );
137 + update_option( 'f12_cf7_doubleoptin_review_remind_count', $remind_count + 1 );
138 + }
85 139
86 - if ( isset( $_GET['f12_cf7_doubleoptin_review_remind'] ) ) {
87 - $remind_count = (int) get_option( 'f12_cf7_doubleoptin_review_remind_count', 0 );
88 - update_option( 'f12_cf7_doubleoptin_review_remind_later', time() + DAY_IN_SECONDS * 7 ); // 7 Tage warten
89 - update_option( 'f12_cf7_doubleoptin_review_remind_count', $remind_count + 1 );
140 + // Redirect to remove query parameters from URL
141 + wp_safe_redirect( remove_query_arg( [ 'f12_cf7_doubleoptin_review_dismissed', 'f12_cf7_doubleoptin_review_remind', '_wpnonce' ] ) );
142 + exit;
90 143 }
91 144 }