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.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 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 All 35 releases
double-opt-in / compatibility / cf7 / templates / admin-panel.php

admin-panel.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at compatibility/cf7/templates/admin-panel.php

349 lines 13.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CF7 Double Opt-In Admin Panel Template
4 *
5 * @package Forge12\DoubleOptIn\Integration
6 * @since 4.0.0
7 *
8 * @var \WPCF7_ContactForm $post The contact form.
9 * @var array $metadata The form metadata.
10 * @var string $id The field ID prefix.
11 * @var array $tags The form field tags.
12 */
13
14 use forge12\contactform7\CF7DoubleOptIn\Category;
15 use forge12\contactform7\CF7DoubleOptIn\HTMLSelect;
16 use Forge12\DoubleOptIn\EmailTemplates\PlaceholderMapper;
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 // Get available templates
23 $templateOptions = [
24 'blank' => 'blank',
25 'newsletter_en' => 'newsletter_en',
26 'newsletter_en_2' => 'newsletter_en_2',
27 'newsletter_en_3' => 'newsletter_en_3',
28 ];
29
30 try {
31 $container = \Forge12\DoubleOptIn\Container\Container::getInstance();
32 $integration = $container->get( \Forge12\DoubleOptIn\EmailTemplates\EmailTemplateIntegration::class );
33 $custom = $integration->getCustomTemplates();
34
35 foreach ( $custom as $template ) {
36 $templateOptions[ 'custom_' . $template['id'] ] = $template['title'] . ' (' . __( 'Custom', 'double-opt-in' ) . ')';
37 }
38 } catch ( \Exception $e ) {
39 // Ignore if custom templates not available
40 }
41
42 // Get categories
43 $atts = [
44 'perPage' => -1,
45 'orderBy' => 'name',
46 'order' => 'ASC',
47 ];
48 $categories = Category::get_list( $atts, $numberOfPages );
49 ?>
50 <div class="forge12-plugin" style="padding-top:0;">
51 <div class="forge12-plugin-content" style="margin-top:0;">
52 <div class="forge12-plugin-content-main">
53 <div class="box" style="width:100%;">
54 <h2><?php esc_html_e( 'Opt-In Formular Settings', 'double-opt-in' ); ?></h2>
55 <div class="option">
56 <div class="label">
57 <label for="doubleoptin[enable]">
58 <?php esc_html_e( 'Enable', 'double-opt-in' ); ?>
59 </label>
60 </div>
61 <div class="input">
62 <input type="checkbox" name="doubleoptin[enable]" id="doubleoptin"
63 value="1" <?php checked( isset( $metadata['enable'] ) && $metadata['enable'] == 1 ); ?> >
64 <span><?php esc_html_e( 'Yes', 'double-opt-in' ); ?></span>
65 <p><?php esc_html_e( 'Enable this checkbox to activate the Double-Opt-In Mail for this formular.', 'double-opt-in' ); ?></p>
66 </div>
67 </div>
68
69 <div class="option">
70 <div class="label">
71 <label for="doubleoptin[category]">
72 <?php esc_html_e( 'Category', 'double-opt-in' ); ?>
73 </label>
74 </div>
75 <div class="input">
76 <?php
77 $categoryOptions = '<option value="0">' . esc_html__( 'Please select', 'double-opt-in' ) . '</option>';
78 foreach ( $categories as $category ) {
79 $selected = ( $category->get_id() == $metadata['category'] ) ? 'selected="selected"' : '';
80 $categoryOptions .= '<option value="' . esc_attr( $category->get_id() ) . '" ' . $selected . '>' . esc_html( $category->get_name() ) . '</option>';
81 }
82 ?>
83 <select name="doubleoptin[category]"><?php echo wp_kses( $categoryOptions, [ 'option' => [ 'value' => [], 'selected' => [] ] ] ); ?></select>
84 <span><?php esc_html_e( 'Assign the Opt-In to a Category for an easier administration.', 'double-opt-in' ); ?></span>
85 </div>
86 </div>
87
88 <div class="option">
89 <div class="label">
90 <label for="doubleoptin[page]">
91 <?php esc_html_e( 'Dynamic Condition', 'double-opt-in' ); ?>
92 </label>
93 </div>
94 <div class="input">
95 <span><?php esc_html_e( 'Enable the Opt-In only when the field ', 'double-opt-in' ); ?></span>
96 <?php
97 $conditionOptions = array_merge( [ 'disable' => __( 'Disabled', 'double-opt-in' ) ], $tags );
98 $conditionList = new HTMLSelect( $id . '[conditions]', $conditionOptions, [
99 'id' => [ $id . '-conditions' ],
100 'class' => [ 'large-text', 'code' ],
101 ] );
102 $conditionList->setOptionSelectedByKey( $metadata['conditions'] );
103 echo wp_kses( $conditionList->get(), [ 'select' => [ 'name' => [] ], 'option' => [ 'value' => [], 'selected' => [] ] ] );
104 ?>
105 <span><?php esc_html_e( 'has been filled/checked by the visitor.', 'double-opt-in' ); ?></span>
106 </div>
107 </div>
108
109 <div class="option">
110 <div class="label">
111 <label for="doubleoptin[page]">
112 <?php esc_html_e( 'Confirmation Page', 'double-opt-in' ); ?>
113 </label>
114 </div>
115 <div class="input">
116 <?php wp_dropdown_pages( [
117 'show_option_none' => __( 'default', 'double-opt-in' ),
118 'name' => 'doubleoptin[page]',
119 'selected' => $metadata['page'],
120 ] ); ?>
121 <p><?php esc_html_e( 'Select the page that should be displayed after the user clicks on the confirmation link', 'double-opt-in' ); ?></p>
122 </div>
123 </div>
124
125 <div class="option">
126 <div class="label">
127 <label for="doubleoptin[error_page]">
128 <?php esc_html_e( 'Error Redirect Page', 'double-opt-in' ); ?>
129 </label>
130 </div>
131 <div class="input">
132 <?php wp_dropdown_pages( [
133 'show_option_none' => __( 'default', 'double-opt-in' ),
134 'name' => 'doubleoptin[error_page]',
135 'selected' => $metadata['error_page'] ?? -1,
136 ] ); ?>
137 <p><?php esc_html_e( 'Select the page to redirect to when an error occurs (e.g. rate limit). Leave on default for toast notification.', 'double-opt-in' ); ?></p>
138 </div>
139 </div>
140
141 <?php
142 echo apply_filters( 'f12_cf7_formular_settings_after_cf7', '', $metadata );
143 do_action( 'f12_cf7_formular_settings_after', 'cf7', $metadata );
144 ?>
145 </div>
146
147 <div class="box" style="width:100%;">
148 <h2><?php esc_html_e( 'Customize your Opt-In Mail', 'double-opt-in' ); ?></h2>
149 <div class="option">
150 <div class="label">
151 <label for="<?php echo esc_attr( $id ); ?>-recipient">
152 <?php esc_html_e( 'To', 'double-opt-in' ); ?>
153 </label>
154 </div>
155 <div class="input">
156 <input type="text" id="<?php echo esc_attr( $id ); ?>-recipient"
157 name="<?php echo esc_attr( $id ); ?>[recipient]"
158 class="large-text code" size="70"
159 value="<?php echo esc_attr( $metadata['recipient'] ); ?>"/>
160 <p><?php esc_html_e( 'This field defines who will receive the Double-Opt-In mail. Enter one of the following tags that represents the mail for the customer:', 'double-opt-in' ); ?></p>
161 <p>
162 <code>
163 <?php
164 $tagsList = [];
165 foreach ( $tags as $key => $value ) {
166 $tagsList[] = '[' . esc_html( $value ) . ']';
167 }
168 echo esc_html( implode( ',', array_filter( $tagsList ) ) );
169 ?>
170 </code>
171 </p>
172 </div>
173 </div>
174
175 <div class="option">
176 <div class="label">
177 <label for="<?php echo esc_attr( $id ); ?>-sender">
178 <?php esc_html_e( 'From', 'double-opt-in' ); ?>
179 </label>
180 </div>
181 <div class="input">
182 <input type="text" id="<?php echo esc_attr( $id ); ?>-sender"
183 name="<?php echo esc_attr( $id ); ?>[sender]"
184 class="large-text code" size="70"
185 value="<?php echo esc_attr( $metadata['sender'] ); ?>"/>
186 <p><?php esc_html_e( 'This field defines who will sent the mail. You can either enter the e-Mail (e.g.: your-email@yourdomain.de) or use a placeholder (e.g.: [_site_admin_email]).', 'double-opt-in' ); ?></p>
187 </div>
188 </div>
189
190 <div class="option">
191 <div class="label">
192 <label for="<?php echo esc_attr( $id ); ?>-sender_name">
193 <?php esc_html_e( 'From Name', 'double-opt-in' ); ?>
194 </label>
195 </div>
196 <div class="input">
197 <input type="text" id="<?php echo esc_attr( $id ); ?>-sender_name"
198 name="<?php echo esc_attr( $id ); ?>[sender_name]"
199 class="large-text code" size="70"
200 value="<?php echo esc_attr( $metadata['sender_name'] ); ?>"/>
201 <p><?php esc_html_e( 'This field defines the name of the sender (e.g. Max Mustermann).', 'double-opt-in' ); ?></p>
202 </div>
203 </div>
204
205 <div class="option">
206 <div class="label">
207 <label for="<?php echo esc_attr( $id ); ?>-subject">
208 <?php esc_html_e( 'Subject', 'double-opt-in' ); ?>
209 </label>
210 </div>
211 <div class="input">
212 <input type="text" id="<?php echo esc_attr( $id ); ?>-subject"
213 name="<?php echo esc_attr( $id ); ?>[subject]"
214 class="large-text code" size="70"
215 value="<?php echo esc_attr( $metadata['subject'] ); ?>"/>
216 <p><?php esc_html_e( 'Enter a custom subject for the Double-Opt-In mail (e.g.: Please confirm your registration).', 'double-opt-in' ); ?></p>
217 </div>
218 </div>
219
220 <div class="option">
221 <div class="label">
222 <label for="<?php echo esc_attr( $id ); ?>-body">
223 <?php esc_html_e( 'Template', 'double-opt-in' ); ?>
224 </label>
225 </div>
226 <div class="input">
227 <div class="preview">
228 <?php
229 $builtInTemplates = [ 'blank', 'newsletter_en', 'newsletter_en_2', 'newsletter_en_3' ];
230 foreach ( $builtInTemplates as $template ) :
231 $isActive = $metadata['template'] === $template ? 'active' : '';
232 ?>
233 <div class="preview-item">
234 <div class="preview-item-inner <?php echo esc_attr( $isActive ); ?>">
235 <img src="<?php echo esc_url( plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'mails/' . $template . '.png' ); ?>"
236 class="f12-cf7-templateloader-preview" data-template="<?php echo esc_attr( $template ); ?>"
237 title="<?php echo esc_attr( ucfirst( str_replace( '_', ' ', $template ) ) ); ?>"/>
238 </div>
239 </div>
240 <?php endforeach; ?>
241 </div>
242 <?php
243 $templateList = new HTMLSelect( $id . '[template]', $templateOptions, [
244 'class' => [ 'f12-cf7-templateloader' ],
245 'style' => [ 'display:none;' ],
246 ] );
247 $templateList->setOptionSelectedByKey( $metadata['template'] );
248 echo wp_kses( $templateList->get(), [ 'select' => [ 'style' => [], 'class' => [], 'name' => [] ], 'option' => [ 'value' => [], 'selected' => [] ] ] );
249
250 do_action( 'f12_cf7_doubleoptin_admin_panel_templates', $metadata, $id );
251 ?>
252 </div>
253 </div>
254
255 <div class="option">
256 <div class="label">
257 <label for="<?php echo esc_attr( $id ); ?>-body">
258 <?php esc_html_e( 'Message body', 'double-opt-in' ); ?>
259 </label>
260 </div>
261 <div class="input">
262 <textarea id="<?php echo esc_attr( $id ); ?>-body"
263 name="<?php echo esc_attr( $id ); ?>[body]"
264 cols="100" rows="18"
265 class="large-text code"><?php echo esc_textarea( $metadata['body'] ); ?></textarea>
266 <p><?php esc_html_e( 'Enter the Message you want to sent to your customer. Do not forget to add the Double-Opt-In tag ([doubleoptinlink]) e.g.:', 'double-opt-in' ); ?>
267 <code>&lt;a href="[doubleoptinlink]"&gt;Confirm the registration&lt;/a&gt;</code>
268 </p>
269 <p><?php esc_html_e( 'These placeholders are available for the opt-in Message body: ', 'double-opt-in' ); ?></p>
270 <p>
271 <code>[doubleoptinlink],[doubleoptin_form_url],[doubleoptin_form_subject],[doubleoptin_form_date],[doubleoptin_form_time],[_site_admin_email],<?php echo esc_html( implode( ',', $tagsList ) ); ?></code>
272 </p>
273 </div>
274 </div>
275 </div>
276
277 <?php
278 // Render placeholder mapping UI
279 if ( class_exists( PlaceholderMapper::class ) ) {
280 $formFields = array_keys( $tags );
281 $standardPlaceholders = PlaceholderMapper::getStandardPlaceholders();
282 $autoMapping = PlaceholderMapper::autoDetectMapping( $formFields );
283 $customMapping = PlaceholderMapper::getCustomMapping( $post->id(), 'cf7' );
284 $effectiveMapping = array_merge( $autoMapping, $customMapping );
285 ?>
286 <div class="box" style="width:100%;">
287 <h2><?php esc_html_e( 'Standard Placeholders Mapping', 'double-opt-in' ); ?></h2>
288 <p class="description" style="margin-bottom: 15px;">
289 <?php esc_html_e( 'Map your form fields to standard placeholders. This allows you to use the same email template across different forms.', 'double-opt-in' ); ?>
290 </p>
291
292 <table class="widefat" style="margin-bottom: 20px;">
293 <thead>
294 <tr>
295 <th style="width: 200px;"><?php esc_html_e( 'Standard Placeholder', 'double-opt-in' ); ?></th>
296 <th style="width: 150px;"><?php esc_html_e( 'Auto-Detected', 'double-opt-in' ); ?></th>
297 <th><?php esc_html_e( 'Custom Mapping (Override)', 'double-opt-in' ); ?></th>
298 </tr>
299 </thead>
300 <tbody>
301 <?php foreach ( $standardPlaceholders as $placeholder => $config ) :
302 $autoDetected = $autoMapping[ $placeholder ] ?? '';
303 $customValue = $customMapping[ $placeholder ] ?? '';
304 ?>
305 <tr>
306 <td>
307 <code>[<?php echo esc_html( $placeholder ); ?>]</code>
308 <br><small style="color: #666;"><?php echo esc_html( $config['label'] ); ?></small>
309 </td>
310 <td>
311 <?php if ( $autoDetected ) : ?>
312 <span style="color: #46b450;"><code>[<?php echo esc_html( $autoDetected ); ?>]</code></span>
313 <?php else : ?>
314 <span style="color: #999;"><?php esc_html_e( 'Not detected', 'double-opt-in' ); ?></span>
315 <?php endif; ?>
316 </td>
317 <td>
318 <select name="doubleoptin[placeholder_mapping][<?php echo esc_attr( $placeholder ); ?>]" style="width: 100%; max-width: 300px;">
319 <option value="">
320 <?php
321 if ( $autoDetected ) {
322 printf( esc_html__( 'Use auto-detected: [%s]', 'double-opt-in' ), esc_html( $autoDetected ) );
323 } else {
324 esc_html_e( '-- Select field --', 'double-opt-in' );
325 }
326 ?>
327 </option>
328 <?php foreach ( $formFields as $field ) : ?>
329 <option value="<?php echo esc_attr( $field ); ?>" <?php selected( $customValue, $field ); ?>>
330 [<?php echo esc_html( $field ); ?>]
331 </option>
332 <?php endforeach; ?>
333 </select>
334 </td>
335 </tr>
336 <?php endforeach; ?>
337 </tbody>
338 </table>
339 </div>
340 <?php } ?>
341
342 <?php
343 do_action( 'f12_cf7_doubleoptin_admin_panel', $post, $metadata, $id );
344 wp_nonce_field( 'f12_cf7_doubleoptin_save_form_action', 'f12_cf7_doubleoptin_save_form_nonce' );
345 ?>
346 </div>
347 </div>
348 </div>
349