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/Frontend/ConfirmationShortcodes.php +34 -0 5.8.1 → 5.9.0 View file →
@@ -7,8 +7,10 @@
7 7 * - [doi_error_message] explains the `?doi_error=<code>` that a refused
8 8 * submission is redirected with. Up to 5.7 nothing read that parameter.
9 9 * - [doi_field name="…"] greets with a value from the form, only in the
10 10 * request that confirmed it.
11 + * - [doi_if status="…"]…[/doi_if] shows its content only for the listed
12 + * validation statuses, so one page can carry a text per outcome.
11 13 *
12 14 * Without a shortcode on the page, a failed link still gets its message in
13 15 * front of the content — the new integration system set the status but
14 16 * showed it nowhere.
@@ -53,8 +55,9 @@
53 55 public function register(): void {
54 56 add_shortcode( 'doi_confirmation_status', array( $this, 'renderStatus' ) );
55 57 add_shortcode( 'doi_error_message', array( $this, 'renderError' ) );
56 58 add_shortcode( 'doi_field', array( $this, 'renderField' ) );
59 + add_shortcode( 'doi_if', array( $this, 'renderIf' ) );
57 60
58 61 add_action( 'f12_cf7_doubleoptin_after_confirm', array( $this, 'rememberConfirmed' ), 1, 2 );
59 62 // After do_shortcode (11): by then a [doi_confirmation_status] on the page has run.
60 63 add_filter( 'the_content', array( $this, 'prependFallbackNotice' ), 12 );
@@ -187,8 +190,39 @@
187 190 return $default;
188 191 }
189 192
190 193 return esc_html( (string) $value );
194 + }
195 +
196 + /**
197 + * [doi_if status="confirmed,already_confirmed"]…[/doi_if]
198 + *
199 + * Statuses are those of [doi_confirmation_status]; "none" matches a visit
200 + * without a confirmation link. Content shown for a real status counts as
201 + * the page's status message, so the fallback notice stays away.
202 + *
203 + * @param mixed $atts Shortcode attributes.
204 + * @param string|null $content Enclosed content.
205 + */
206 + public function renderIf( $atts = array(), $content = null ): string {
207 + if ( ! is_string( $content ) || $content === '' ) {
208 + return '';
209 + }
210 +
211 + $atts = shortcode_atts( array( 'status' => '' ), is_array( $atts ) ? $atts : array(), 'doi_if' );
212 + $wanted = array_filter( array_map( 'trim', explode( ',', strtolower( (string) $atts['status'] ) ) ) );
213 + $status = (string) call_user_func( $this->status );
214 + $key = $status === '' ? 'none' : $status;
215 +
216 + if ( ! in_array( $key, $wanted, true ) ) {
217 + return '';
218 + }
219 +
220 + if ( $key !== 'none' ) {
221 + $this->statusShown = true;
222 + }
223 +
224 + return do_shortcode( $content );
191 225 }
192 226
193 227 /**
194 228 * A failed link on a page without [doi_confirmation_status]: say so first.